fix(uitests): move forced logout to class setUp, fix ambiguous Ver Detalhes match
Previous commit's per-test logoutIfAuthenticated() in HomeGuestFlowTests
and ProfileLoggedOutFlowTests ran the guest address-picker navigation
dance (reachProfileTabRegardlessOfAuthState) twice back-to-back per test
- once in the new launch helper, once again inside reachGuestHome/
reachLoggedOutProfile - doubling exposure to that dance's known race
and regressing 5 previously-stable tests ('Login never completed' was
fixed, but new failures appeared in its place).
Moved the forced logout into override class func setUp() so it runs
once per class instead of once per test; test bodies are back to the
plain XCUIApplication()+launch() pattern.
Also fixed OrderDetailsFlowTests: 'Ver Detalhes' now matches multiple
elements once the QA account has more than one real order (previously
masked because login itself was failing first). Switched to a label
predicate + .firstMatch.
See decisions/2026-09-11-ui-test-shared-login-session.md follow-ups.
This commit is contained in:
@@ -3,23 +3,32 @@ import XCTest
|
||||
/// Covers the Profile tab's logged-out state (`ProfileLoggedOutView`) and
|
||||
/// the auth intro screen (`LoginView`) it opens.
|
||||
final class ProfileLoggedOutFlowTests: XCTestCase {
|
||||
/// Authenticated-flow tests no longer log out after themselves (see
|
||||
/// decisions/2026-09-11-ui-test-shared-login-session.md), so this
|
||||
/// class must force a clean logged-out state before its tests run,
|
||||
/// rather than assume one. Done once per class, not once per test:
|
||||
/// the underlying navigate-to-Profile-tab dance
|
||||
/// (`reachProfileTabRegardlessOfAuthState`) is a known race against
|
||||
/// the guest address-picker sheet (see
|
||||
/// decisions/2026-08-06-ui-test-account-and-app-attest-bypass.md) -
|
||||
/// running it a second time back-to-back inside every test (once
|
||||
/// here, once again inside `reachLoggedOutProfile`'s own callers)
|
||||
/// doubled exposure to that race and broke tests that were
|
||||
/// previously stable.
|
||||
override class func setUp() {
|
||||
super.setUp()
|
||||
let app = XCUIApplication()
|
||||
app.launch()
|
||||
app.logoutIfAuthenticated()
|
||||
}
|
||||
|
||||
override func setUpWithError() throws {
|
||||
continueAfterFailure = false
|
||||
}
|
||||
|
||||
/// Authenticated-flow tests no longer log out after themselves (see
|
||||
/// decisions/2026-09-11-ui-test-shared-login-session.md), so
|
||||
/// logged-out tests must force a clean state themselves right after
|
||||
/// launch, rather than assume one.
|
||||
private func launchLoggedOutApp() -> XCUIApplication {
|
||||
func testLoggedOutProfileShowsLoginPrompt() throws {
|
||||
let app = XCUIApplication()
|
||||
app.launch()
|
||||
app.logoutIfAuthenticated()
|
||||
return app
|
||||
}
|
||||
|
||||
func testLoggedOutProfileShowsLoginPrompt() throws {
|
||||
let app = launchLoggedOutApp()
|
||||
XCTAssertTrue(app.reachLoggedOutProfile(), "Never reached the logged-out profile screen")
|
||||
|
||||
XCTAssertTrue(app.staticTexts["Entre na sua conta"].exists)
|
||||
@@ -32,7 +41,8 @@ final class ProfileLoggedOutFlowTests: XCTestCase {
|
||||
/// a working way back out (its `LCENavigationView` back button, which
|
||||
/// sets `root = .main`).
|
||||
func testAuthIntroScreenShowsChoicesAndCanGoBack() throws {
|
||||
let app = launchLoggedOutApp()
|
||||
let app = XCUIApplication()
|
||||
app.launch()
|
||||
XCTAssertTrue(app.reachLoggedOutProfile())
|
||||
|
||||
app.buttons["Entrar ou Cadastrar"].tap()
|
||||
@@ -54,7 +64,8 @@ final class ProfileLoggedOutFlowTests: XCTestCase {
|
||||
/// app's standard `AppBackButtonIcon` via `LCENavigationView`, not the
|
||||
/// oversized iOS 26 system glass back button.
|
||||
func testPushedAuthScreensUseAppBackButton() throws {
|
||||
let app = launchLoggedOutApp()
|
||||
let app = XCUIApplication()
|
||||
app.launch()
|
||||
XCTAssertTrue(app.reachLoggedOutProfile())
|
||||
app.buttons["Entrar ou Cadastrar"].tap()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user