[batch-f] Extend Checkout coverage: payment method selection + Alterar
Adds testCheckoutPaymentMethodSelectionAndAddressAlterar, exercising CheckoutView's payment-method row selection and the address picker's "Alterar" entry point without ever tapping "Confirmar e Pagar" - deliberately not submitting a real order (explicit user direction: cover the screen, don't create real order data in the QA account). Extracted the shared reach-checkout steps from testAddProductToCartAndReachCheckout into a private helper, reachCheckoutWithOneItem, reused by both tests. Fixed the same "not hittable" Back-button bug (already documented in UITestSupport.swift) inline here too - tapping a Back button that exists but is mid pop-transition throws a fatal, uncatchable failure; needs an .isHittable check with a short poll, not just .exists. Verified stable across 2 consecutive class-level runs.
This commit is contained in:
@@ -17,6 +17,67 @@ final class CartCheckoutFlowTests: XCTestCase {
|
|||||||
func testAddProductToCartAndReachCheckout() throws {
|
func testAddProductToCartAndReachCheckout() throws {
|
||||||
let app = XCUIApplication()
|
let app = XCUIApplication()
|
||||||
app.launch()
|
app.launch()
|
||||||
|
try reachCheckoutWithOneItem(app)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Exercises CheckoutView's payment-method selection and the address
|
||||||
|
/// picker's "Alterar" entry point without ever tapping "Confirmar e
|
||||||
|
/// Pagar" - deliberately not submitting a real order (per explicit
|
||||||
|
/// user direction: cover the screen, don't create real order data).
|
||||||
|
func testCheckoutPaymentMethodSelectionAndAddressAlterar() throws {
|
||||||
|
let app = XCUIApplication()
|
||||||
|
app.launch()
|
||||||
|
try reachCheckoutWithOneItem(app)
|
||||||
|
|
||||||
|
XCTAssertTrue(app.staticTexts["MÉTODO DE PAGAMENTO"].waitForExistence(timeout: 5))
|
||||||
|
|
||||||
|
// PIX is the default selection; only tap an alternative if this
|
||||||
|
// store's real catalog actually offers one - don't assume Cartão
|
||||||
|
// de Crédito exists (in-app payment methods depend on real store
|
||||||
|
// config, already found to vary - see the standing-account state
|
||||||
|
// notes in decisions/2026-08-06-ui-test-account-and-app-attest-bypass.md).
|
||||||
|
let creditCardRow = app.buttons.matching(NSPredicate(format: "label CONTAINS[c] %@", "Cartão de Crédito")).firstMatch
|
||||||
|
if creditCardRow.exists {
|
||||||
|
creditCardRow.tap()
|
||||||
|
}
|
||||||
|
|
||||||
|
XCTAssertTrue(app.staticTexts["TIPO DE ENTREGA"].waitForExistence(timeout: 5))
|
||||||
|
|
||||||
|
app.buttons["Alterar"].tap()
|
||||||
|
XCTAssertTrue(
|
||||||
|
app.staticTexts["Meus Endereços"].waitForExistence(timeout: 10),
|
||||||
|
"Alterar never opened the address picker"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Dismiss without changing anything, back to Checkout. .isHittable,
|
||||||
|
// not just .exists: a Back button that exists but is mid-transition
|
||||||
|
// throws a fatal, uncatchable "not hittable" failure on tap - same
|
||||||
|
// issue already fixed in UITestSupport.reachProfileTabRegardlessOfAuthState.
|
||||||
|
// Poll briefly since the push-in animation can still be settling
|
||||||
|
// right after "Meus Endereços" first becomes visible.
|
||||||
|
let backButton = app.buttons.matching(NSPredicate(format: "label == %@", "Back")).firstMatch
|
||||||
|
var dismissed = false
|
||||||
|
for _ in 0..<10 {
|
||||||
|
if backButton.exists, backButton.isHittable {
|
||||||
|
backButton.tap()
|
||||||
|
dismissed = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
usleep(200_000)
|
||||||
|
}
|
||||||
|
if dismissed == false {
|
||||||
|
app.swipeDown()
|
||||||
|
}
|
||||||
|
if app.staticTexts["Finalizar Pedido"].waitForExistence(timeout: 10) == false {
|
||||||
|
let dir = "/private/tmp/claude-501/-Users-loverde-co-Documents-Loverde-JOBs-Producao-Loverde-Co-LC-RAG-Struct-projects-PediFoods-ios/4a9ec4f7-c3ad-4cf5-8dad-073446f6fd81/scratchpad"
|
||||||
|
try? app.screenshot().pngRepresentation.write(to: URL(fileURLWithPath: "\(dir)/after_alterar_dismiss.png"))
|
||||||
|
}
|
||||||
|
XCTAssertTrue(app.staticTexts["Finalizar Pedido"].exists, "Never returned to Checkout")
|
||||||
|
|
||||||
|
// Deliberately not tapping "Confirmar e Pagar" - see doc comment.
|
||||||
|
}
|
||||||
|
|
||||||
|
private func reachCheckoutWithOneItem(_ app: XCUIApplication) throws {
|
||||||
XCTAssertTrue(app.ensureLoggedIn(), "Login never completed")
|
XCTAssertTrue(app.ensureLoggedIn(), "Login never completed")
|
||||||
|
|
||||||
// ensureLoggedIn can land on whichever tab it detected the
|
// ensureLoggedIn can land on whichever tab it detected the
|
||||||
|
|||||||
Reference in New Issue
Block a user