[batch-f] Extend CardSelectionSheet test into PaymentCardView
testConfirmarEPagarWithCreditCardOpensCardSelectionWithoutSubmitting now also taps CardSelectionSheet's "Adicionar novo cartão", which opens PaymentCardView (CheckoutView.swift's own card-entry form - a distinct struct from AddCardFormView.swift, which is a separate screen reached from Profile -> Meus Cartões and already covered). Doesn't fill or submit anything, just reaches the form and dismisses back through both sheets. Extracted the shared "x" close-button dismiss logic (used by both CardSelectionSheet and PaymentCardView) into a private dismissViaCloseButton helper. Verified stable across 2 consecutive class-level runs.
This commit is contained in:
@@ -96,22 +96,37 @@ final class CartCheckoutFlowTests: XCTestCase {
|
||||
app.buttons["Confirmar e Pagar"].tap()
|
||||
XCTAssertTrue(app.staticTexts["Selecionar Cartão"].waitForExistence(timeout: 10), "Never reached the card selection sheet")
|
||||
|
||||
// Dismiss via the sheet's own "x" close button - never selects a
|
||||
// card, never submits anything.
|
||||
// "Adicionar novo cartão" opens PaymentCardView (CheckoutView.swift's
|
||||
// own card-entry form - a different struct from AddCardFormView.swift,
|
||||
// reached from Profile -> Meus Cartões, needs its own coverage) as a
|
||||
// sheet on top. Only fills nothing and dismisses - no card saved, no
|
||||
// order created.
|
||||
app.buttons["Adicionar novo cartão"].tap()
|
||||
XCTAssertTrue(
|
||||
app.staticTexts["Novo Cartão"].waitForExistence(timeout: 10),
|
||||
"Adicionar novo cartão never opened PaymentCardView"
|
||||
)
|
||||
dismissViaCloseButton(app)
|
||||
XCTAssertTrue(app.staticTexts["Selecionar Cartão"].waitForExistence(timeout: 10), "Never returned to card selection")
|
||||
|
||||
dismissViaCloseButton(app)
|
||||
XCTAssertTrue(app.staticTexts["Finalizar Pedido"].waitForExistence(timeout: 10), "Never returned to Checkout")
|
||||
}
|
||||
|
||||
/// Dismisses via the topmost sheet's "x" close button
|
||||
/// (`identifier: "xmark"`) - shared by `CardSelectionSheet` and
|
||||
/// `PaymentCardView`. `.firstMatch` tolerates a lower sheet's own
|
||||
/// close button still existing underneath in the accessibility tree.
|
||||
private func dismissViaCloseButton(_ app: XCUIApplication) {
|
||||
let closeButton = app.buttons.matching(identifier: "xmark").firstMatch
|
||||
var dismissed = false
|
||||
for _ in 0..<10 {
|
||||
if closeButton.exists, closeButton.isHittable {
|
||||
closeButton.tap()
|
||||
dismissed = true
|
||||
break
|
||||
return
|
||||
}
|
||||
usleep(200_000)
|
||||
}
|
||||
if dismissed == false {
|
||||
app.swipeDown()
|
||||
}
|
||||
XCTAssertTrue(app.staticTexts["Finalizar Pedido"].waitForExistence(timeout: 10), "Never returned to Checkout")
|
||||
app.swipeDown()
|
||||
}
|
||||
|
||||
private func reachCheckoutWithOneItem(_ app: XCUIApplication) throws {
|
||||
|
||||
Reference in New Issue
Block a user