|
| 1 | +// Copyright 2025 Google LLC |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +// |
| 16 | +// UpgradeAccountUITests.swift |
| 17 | +// UpgradeAccountUITests |
| 18 | +// |
| 19 | +// Created by Russell Wheatley on 05/11/2025. |
| 20 | +// |
| 21 | + |
| 22 | +import XCTest |
| 23 | + |
| 24 | +final class UpgradeAccountUITests: XCTestCase { |
| 25 | + override func setUpWithError() throws { |
| 26 | + continueAfterFailure = false |
| 27 | + } |
| 28 | + |
| 29 | + override func tearDownWithError() throws {} |
| 30 | + |
| 31 | + @MainActor |
| 32 | + func testUpgradeAnonymousAccountWithEmailPassword() async throws { |
| 33 | + // Create a test user first |
| 34 | + let email = createEmail() |
| 35 | + let password = "123456" |
| 36 | + try await createTestUser(email: email, password: password) |
| 37 | + |
| 38 | + // Launch app with anonymous sign-in enabled |
| 39 | + let app = createTestApp() |
| 40 | + app.launchArguments.append("--anonymous-sign-in-enabled") |
| 41 | + app.launch() |
| 42 | + |
| 43 | + // Wait for sign-in screen to appear |
| 44 | + let emailField = app.textFields["email-field"] |
| 45 | + XCTAssertTrue(emailField.waitForExistence(timeout: 6), "Email field should exist") |
| 46 | + emailField.tap() |
| 47 | + emailField.typeText(email) |
| 48 | + |
| 49 | + let passwordField = app.secureTextFields["password-field"] |
| 50 | + XCTAssertTrue(passwordField.exists, "Password field should exist") |
| 51 | + passwordField.tap() |
| 52 | + passwordField.typeText(password) |
| 53 | + |
| 54 | + let signInButton = app.buttons["sign-in-button"] |
| 55 | + XCTAssertTrue(signInButton.exists, "Sign-In button should exist") |
| 56 | + signInButton.tap() |
| 57 | + |
| 58 | + let signedInText = app.staticTexts["signed-in-text"] |
| 59 | + |
| 60 | + // Wait for authentication to complete and signed-in view to appear |
| 61 | + XCTAssertTrue( |
| 62 | + signedInText.waitForExistence(timeout: 30), |
| 63 | + "SignedInView should be visible after signing in with email/password" |
| 64 | + ) |
| 65 | + } |
| 66 | +} |
0 commit comments