Files
honeyDueKMP/iosApp/CaseraUITests/CriticalPath/NavigationCriticalPathTests.swift
Trey t 5e3596db77 Complete re-validation remediation: KMP architecture, iOS platform, XCUITest rewrite
Phases 1-6 of fixes.md — closes all 13 issues from codex_issues_2.md re-validation:

KMP Architecture:
- Fix subscription purchase/restore response contract (VerificationResponse aligned)
- Add feature benefits auth token + APILayer init flow
- Remove ResidenceFormScreen direct API bypass (use APILayer)
- Wire paywall purchase/restore to real SubscriptionApi calls

iOS Platform:
- Add iOS Keychain token storage via Swift KeychainHelper
- Implement Google Sign-In via ASWebAuthenticationSession (GoogleSignInManager)
- DocumentViewModelWrapper observes DataManager for auto-updates
- Add missing accessibility identifiers (document, task columns, Google Sign-In)

XCUITest Rewrite:
- Rewrite test infrastructure: zero sleep() calls, accessibility ID lookups
- Create AuthCriticalPathTests and NavigationCriticalPathTests
- Delete 14 legacy brittle test files (Suite0-10, templates)
- Fix CaseraTests module import (@testable import Casera)

All platforms build clean. TEST BUILD SUCCEEDED.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 18:50:13 -06:00

170 lines
5.3 KiB
Swift

import XCTest
/// Critical path tests for core navigation.
///
/// Validates tab bar navigation, settings access, and screen transitions.
/// Requires a logged-in user. Zero sleep() calls all waits are condition-based.
final class NavigationCriticalPathTests: XCTestCase {
var app: XCUIApplication!
override func setUp() {
super.setUp()
continueAfterFailure = false
app = TestLaunchConfig.launchApp()
ensureLoggedIn()
}
override func tearDown() {
app = nil
super.tearDown()
}
private func ensureLoggedIn() {
let login = LoginScreen(app: app)
if login.emailField.waitForExistence(timeout: 15) {
let user = TestFixtures.TestUser.existing
login.login(email: user.email, password: user.password)
}
let main = MainTabScreen(app: app)
_ = main.residencesTab.waitForExistence(timeout: 15)
}
// MARK: - Tab Navigation
func testAllTabsExist() {
let main = MainTabScreen(app: app)
guard main.residencesTab.waitForExistence(timeout: 10) else {
XCTFail("Main screen did not appear")
return
}
XCTAssertTrue(main.residencesTab.exists, "Residences tab should exist")
XCTAssertTrue(main.tasksTab.exists, "Tasks tab should exist")
XCTAssertTrue(main.contractorsTab.exists, "Contractors tab should exist")
XCTAssertTrue(main.documentsTab.exists, "Documents tab should exist")
}
func testNavigateToTasksTab() {
let main = MainTabScreen(app: app)
guard main.residencesTab.waitForExistence(timeout: 10) else {
XCTFail("Main screen did not appear")
return
}
main.goToTasks()
XCTAssertTrue(main.tasksTab.isSelected, "Tasks tab should be selected")
}
func testNavigateToContractorsTab() {
let main = MainTabScreen(app: app)
guard main.residencesTab.waitForExistence(timeout: 10) else {
XCTFail("Main screen did not appear")
return
}
main.goToContractors()
XCTAssertTrue(main.contractorsTab.isSelected, "Contractors tab should be selected")
}
func testNavigateToDocumentsTab() {
let main = MainTabScreen(app: app)
guard main.residencesTab.waitForExistence(timeout: 10) else {
XCTFail("Main screen did not appear")
return
}
main.goToDocuments()
XCTAssertTrue(main.documentsTab.isSelected, "Documents tab should be selected")
}
func testNavigateBackToResidencesTab() {
let main = MainTabScreen(app: app)
guard main.residencesTab.waitForExistence(timeout: 10) else {
XCTFail("Main screen did not appear")
return
}
main.goToDocuments()
main.goToResidences()
XCTAssertTrue(main.residencesTab.isSelected, "Residences tab should be selected")
}
// MARK: - Settings Access
func testSettingsButtonExists() {
let main = MainTabScreen(app: app)
guard main.residencesTab.waitForExistence(timeout: 10) else {
XCTFail("Main screen did not appear")
return
}
main.goToResidences()
XCTAssertTrue(
main.settingsButton.waitForExistence(timeout: 5),
"Settings button should exist on Residences screen"
)
}
// MARK: - Add Buttons
func testResidenceAddButtonExists() {
let main = MainTabScreen(app: app)
guard main.residencesTab.waitForExistence(timeout: 10) else {
XCTFail("Main screen did not appear")
return
}
main.goToResidences()
let addButton = app.buttons[AccessibilityIdentifiers.Residence.addButton]
XCTAssertTrue(
addButton.waitForExistence(timeout: 5),
"Residence add button should exist"
)
}
func testTaskAddButtonExists() {
let main = MainTabScreen(app: app)
guard main.residencesTab.waitForExistence(timeout: 10) else {
XCTFail("Main screen did not appear")
return
}
main.goToTasks()
let addButton = app.buttons[AccessibilityIdentifiers.Task.addButton]
XCTAssertTrue(
addButton.waitForExistence(timeout: 5),
"Task add button should exist"
)
}
func testContractorAddButtonExists() {
let main = MainTabScreen(app: app)
guard main.residencesTab.waitForExistence(timeout: 10) else {
XCTFail("Main screen did not appear")
return
}
main.goToContractors()
let addButton = app.buttons[AccessibilityIdentifiers.Contractor.addButton]
XCTAssertTrue(
addButton.waitForExistence(timeout: 5),
"Contractor add button should exist"
)
}
func testDocumentAddButtonExists() {
let main = MainTabScreen(app: app)
guard main.residencesTab.waitForExistence(timeout: 10) else {
XCTFail("Main screen did not appear")
return
}
main.goToDocuments()
let addButton = app.buttons[AccessibilityIdentifiers.Document.addButton]
XCTAssertTrue(
addButton.waitForExistence(timeout: 5),
"Document add button should exist"
)
}
}