diff --git a/PediFoods/Views/Main/StoreDetailView+Components.swift b/PediFoods/Views/Main/StoreDetailView+Components.swift index 379aa93..5044940 100644 --- a/PediFoods/Views/Main/StoreDetailView+Components.swift +++ b/PediFoods/Views/Main/StoreDetailView+Components.swift @@ -345,6 +345,11 @@ extension StoreDetailView { .disabled(isStoreOpen == false) .opacity(isStoreOpen ? 1 : 0.65) .offset(x: 7, y: 7) + // Explicit, unique identifier for UI tests - the inner + // "plus" SF Symbol's implicit/auto-generated identifier is + // ambiguous (the same systemName is reused for CartView's + // quantity stepper) and unreliable to match against. + .accessibilityIdentifier("storeDetailProductAddButton") } } .padding(12) diff --git a/PediFoodsUITests/CartCheckoutFlowTests.swift b/PediFoodsUITests/CartCheckoutFlowTests.swift index 9028e6d..47b5aaa 100644 --- a/PediFoodsUITests/CartCheckoutFlowTests.swift +++ b/PediFoodsUITests/CartCheckoutFlowTests.swift @@ -228,20 +228,20 @@ final class CartCheckoutFlowTests: XCTestCase { ) storeCard.tap() - // A plain (non-addon, non-pizza) product row's "+" control adds - // directly with no sheet. Once a product's quantity is > 0, its - // outer Button's identifier moves off itself - the same badge- - // merging bug already fixed for the tab bar's cart icon - because - // the row's own quantity Text becomes the Button's accessible - // label/identity instead. The QA account's cart has genuinely - // accumulated real quantities across many runs today, so - // app.buttons.matching(identifier: "plus") stopped matching once - // the first several products all had quantity > 0 (confirmed via - // screenshot: the "+" controls were clearly visible on screen - // while the buttons-only query found nothing). The nested Image - // keeps identifier "plus" regardless of quantity, so target that - // directly instead - same fix pattern as the cart-tab icon. - let addButton = app.images.matching(identifier: "plus").firstMatch + // The product row's add button carries an explicit + // `.accessibilityIdentifier("storeDetailProductAddButton")` + // (StoreDetailView+Components.swift) - added after discovering + // that matching on the inner "plus" SF Symbol's implicit/ + // auto-generated identifier was unreliable: `quickDiagnostics`'s + // visible-text dump showed a real product ("Alcatra", R$ 14,00) + // clearly rendered on screen while `images.matching(identifier: + // "plus")` still found nothing, and the same "plus" systemName is + // separately reused by CartView's quantity stepper, making it an + // ambiguous identifier to search by in the first place. Matching + // the button itself (not a nested image) also sidesteps the + // quantity-badge accessibility-label-merging issue that affected + // the tab bar's cart icon elsewhere in this suite. + let addButton = app.buttons.matching(identifier: "storeDetailProductAddButton").firstMatch XCTAssertTrue( addButton.waitForExistence(timeout: 25), "Store Detail's product list never loaded. \(quickDiagnostics(app))"