Files
honeyDueKMP/iosApp/MyCribUITests/SimpleLoginTest.swift
Trey t 56b1f57ec7 Add comprehensive UI test suite with XCUITest
Added complete UI test suite covering authentication, residences, tasks,
and contractors. Tests follow best practices with helper methods, proper
waits, and accessibility identifier usage.

New test files:
- UITestHelpers.swift: Shared helper methods for login, navigation, waits
- AuthenticationTests.swift: Login, registration, logout flow tests
- ComprehensiveResidenceTests.swift: Full residence CRUD and validation tests
- ComprehensiveTaskTests.swift: Task creation, editing, completion tests
- ComprehensiveContractorTests.swift: Contractor management and edge case tests
- ResidenceTests.swift: Additional residence-specific scenarios
- TaskTests.swift: Additional task scenarios
- SimpleLoginTest.swift: Basic smoke test for CI/CD
- MyCribUITests.swift: Base test class setup
- AccessibilityIdentifiers.swift: Test target copy of identifiers

Test coverage:
- Authentication: Login, registration, logout, error handling
- Residences: Create, edit, delete, validation, multi-field scenarios
- Tasks: Create, complete, edit, cancel, status changes
- Contractors: Create with minimal/full data, phone formats, specialties

All tests use accessibility identifiers for reliable element location and
include proper waits for asynchronous operations.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 23:06:57 -06:00

64 lines
2.4 KiB
Swift

import XCTest
/// Simple test to verify basic app launch and login screen
/// This is the foundation test - if this works, we can build more complex tests
final class SimpleLoginTest: XCTestCase {
var app: XCUIApplication!
override func setUpWithError() throws {
continueAfterFailure = false
app = XCUIApplication()
app.launch()
// CRITICAL: Ensure we're logged out before each test
ensureLoggedOut()
}
override func tearDownWithError() throws {
app = nil
}
// MARK: - Helper Methods
/// Ensures the user is logged out and on the login screen
private func ensureLoggedOut() {
UITestHelpers.ensureLoggedOut(app: app)
}
// MARK: - Tests
/// Test 1: App launches and shows login screen (or logs out if needed)
func testAppLaunchesAndShowsLoginScreen() {
// After ensureLoggedOut(), we should be on login screen
let welcomeText = app.staticTexts["Welcome Back"]
XCTAssertTrue(welcomeText.exists, "Login screen with 'Welcome Back' text should appear after logout")
// Also check that we have a username field
let usernameField = app.textFields.containing(NSPredicate(format: "placeholderValue CONTAINS[c] 'email'")).firstMatch
XCTAssertTrue(usernameField.exists, "Username/email field should exist")
}
/// Test 2: Can type in username and password fields
func testCanTypeInLoginFields() {
// Already logged out from setUp
// Find and tap username field
let usernameField = app.textFields.containing(NSPredicate(format: "placeholderValue CONTAINS[c] 'email'")).firstMatch
XCTAssertTrue(usernameField.waitForExistence(timeout: 10), "Username field should exist")
usernameField.tap()
usernameField.typeText("testuser")
// Find password field (could be TextField or SecureField)
let passwordField = app.secureTextFields.containing(NSPredicate(format: "placeholderValue CONTAINS[c] 'password'")).firstMatch
XCTAssertTrue(passwordField.exists, "Password field should exist")
passwordField.tap()
passwordField.typeText("testpass123")
// Verify we can see a Sign In button
let signInButton = app.buttons.containing(NSPredicate(format: "label CONTAINS[c] 'Sign In'")).firstMatch
XCTAssertTrue(signInButton.exists, "Sign In button should exist")
}
}