fix(uitests): give the product add button an explicit accessibility identifier

quickDiagnostics finally showed the real state at the timeout: Store
Detail had genuinely loaded (store header, category tabs, a real priced
product 'Alcatra' R$ 14,00 all visible) - 'product list never loaded'
was simply the wrong diagnosis. The test was matching
app.images.matching(identifier: "plus") against the product row's add
button, relying entirely on SF Symbol systemName being exposed as an
implicit accessibility identifier - which wasn't holding on this Xcode
26/iOS 26 CI environment, and is inherently ambiguous anyway since
CartView's own quantity stepper reuses the same "plus" systemName.

Added a real .accessibilityIdentifier("storeDetailProductAddButton")
to the product row's add Button in StoreDetailView+Components.swift (an
app-source change, not just a test workaround), and updated the test to
match on that instead.

See decisions/2026-09-11-ui-test-shared-login-session.md follow-up.
This commit is contained in:
2026-09-11 11:14:08 -03:00
parent ea6a3da78b
commit 2ebe97e078
2 changed files with 19 additions and 14 deletions

View File

@@ -345,6 +345,11 @@ extension StoreDetailView {
.disabled(isStoreOpen == false) .disabled(isStoreOpen == false)
.opacity(isStoreOpen ? 1 : 0.65) .opacity(isStoreOpen ? 1 : 0.65)
.offset(x: 7, y: 7) .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) .padding(12)

View File

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