From b68cd923077981a317820ed1d52162cd99df9c3c Mon Sep 17 00:00:00 2001 From: Daniel Arantes Loverde Date: Wed, 12 Aug 2026 10:43:47 -0300 Subject: [PATCH] [batch-f] Extend CardSelectionSheet test into PaymentCardView MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- PediFoodsUITests/CartCheckoutFlowTests.swift | 33 ++++++++++++++------ 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/PediFoodsUITests/CartCheckoutFlowTests.swift b/PediFoodsUITests/CartCheckoutFlowTests.swift index 170d579..0a1fae2 100644 --- a/PediFoodsUITests/CartCheckoutFlowTests.swift +++ b/PediFoodsUITests/CartCheckoutFlowTests.swift @@ -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 {