Files
suixinkan_ios_new/suixinkanUITests/Auth/ZLoginSmokeUITests.swift
汉秋 5bdf4a7dbf 同步 Android 启动页到 iOS,并在冷启动期间静默恢复登录态。
新增 SplashView、SplashCoordinator 与 Launch Screen 资源,移除冷启动 Lottie;LoginView 加载 App 配置。同时将 token 存储迁移至 UserDefaults,并更新相关测试与文档。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-29 14:59:44 +08:00

72 lines
2.6 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// ZLoginSmokeUITests.swift
// suixinkanUITests
//
// Z UserDefaults
//
import XCTest
final class ZLoginSmokeUITests: XCTestCase {
override func setUp() {
super.setUp()
continueAfterFailure = false
UITestSession.invalidate()
}
override func tearDown() {
UITestSession.invalidate()
super.tearDown()
}
///
func testFreshLaunchShowsLoginScreen() {
let app = SuixinkanApp(resetState: true).launch(waitForLoading: false)
XCTAssertTrue(app.application.staticTexts["login.title"].waitForExistence(timeout: 8))
XCTAssertTrue(app.application.textFields["login.username"].exists)
XCTAssertTrue(
app.application.secureTextFields["login.password"].exists
|| app.application.textFields["login.password"].exists
)
XCTAssertTrue(app.application.buttons["login.submit"].exists)
XCTAssertTrue(app.application.buttons["login.userAgreement"].exists)
XCTAssertTrue(app.application.buttons["login.privacyPolicy"].exists)
app.application.terminate()
}
///
func testLoginRequiresPrivacyAgreement() throws {
let app = SuixinkanApp(resetState: true).launch(waitForLoading: false)
defer { app.application.terminate() }
guard UITestLaunchConfiguration.credentials != nil else {
throw XCTSkip("缺少 UI Test 账号。")
}
let usernameField = app.application.textFields["login.username"]
XCTAssertTrue(usernameField.waitForExistence(timeout: 8))
XCTAssertFalse(app.application.buttons["login.submit"].isEnabled)
}
///
func testEmptyPasswordDoesNotLeaveLoginScreen() throws {
let app = SuixinkanApp(resetState: true).launch(waitForLoading: false)
defer { app.application.terminate() }
let credentials = try UITestLaunchConfiguration.requireCredentials()
let usernameField = app.application.textFields["login.username"]
XCTAssertTrue(usernameField.waitForExistence(timeout: 8))
usernameField.tap()
usernameField.typeText(credentials.phone)
let privacyToggle = app.application.buttons["login.privacy"]
if privacyToggle.exists {
privacyToggle.tap()
}
app.application.buttons["login.submit"].tap()
app.waitForGlobalLoadingToDisappear(timeout: 5)
XCTAssertTrue(app.isOnLoginScreen)
}
}