fix(uitests): stop logging out after every authenticated test

All 7 authenticated-flow XCTestCase classes logged out for real in
tearDown, forcing a real OTP round trip against the production backend
on the next authenticated test. Under CI's back-to-back suite run this
produced ~9 real logins to the same QA phone number in ~9 minutes -
the first few succeeded (~30-40s each) but every one after that failed
to complete within timeout, cascading into 'Login never completed'
across CartCheckoutFlowTests, HomeFiltersFlowTests,
OrderDetailsFlowTests, SavedCardsFlowTests, UserProfileFlowTests.

Removed the per-test logout so the QA account's Keychain-backed session
persists across the whole suite (ensureLoggedIn already no-ops when
already authenticated). Moved the 'must start logged out' guarantee to
the two classes that actually need it - HomeGuestFlowTests and
ProfileLoggedOutFlowTests now force logout themselves right after
app.launch() via a small launch helper, instead of relying on whichever
authenticated class happened to run last.

See decisions/2026-09-11-ui-test-shared-login-session.md.
This commit is contained in:
2026-09-11 09:45:26 -03:00
parent 240cb288bf
commit 0fb948c9f6
9 changed files with 42 additions and 36 deletions

View File

@@ -10,9 +10,19 @@ final class HomeGuestFlowTests: XCTestCase {
continueAfterFailure = false
}
func testHomeRendersSearchAndGreeting() throws {
/// Authenticated-flow tests no longer log out after themselves (see
/// decisions/2026-09-11-ui-test-shared-login-session.md), so guest
/// tests must force a clean logged-out state themselves right after
/// launch, rather than assume one.
private func launchGuestApp() -> XCUIApplication {
let app = XCUIApplication()
app.launch()
app.logoutIfAuthenticated()
return app
}
func testHomeRendersSearchAndGreeting() throws {
let app = launchGuestApp()
XCTAssertTrue(app.reachGuestHome(), "Never reached Home's search field")
XCTAssertTrue(app.staticTexts["ENTREGAR EM:"].exists)
@@ -21,8 +31,7 @@ final class HomeGuestFlowTests: XCTestCase {
}
func testHomeShowsDefaultCategoryChip() throws {
let app = XCUIApplication()
app.launch()
let app = launchGuestApp()
XCTAssertTrue(app.reachGuestHome())
XCTAssertTrue(app.staticTexts["Categories"].exists)
@@ -30,8 +39,7 @@ final class HomeGuestFlowTests: XCTestCase {
}
func testHomeShowsGuestLocationPromptWhenNoLocationChosen() throws {
let app = XCUIApplication()
app.launch()
let app = launchGuestApp()
XCTAssertTrue(app.reachGuestHome())
// No guest state/city selected -> Home's own inline message, not
@@ -40,8 +48,7 @@ final class HomeGuestFlowTests: XCTestCase {
}
func testTappingAddressChipReopensLocationPicker() throws {
let app = XCUIApplication()
app.launch()
let app = launchGuestApp()
XCTAssertTrue(app.reachGuestHome())
// The "ENTREGAR EM:" address button re-opens the same address