Add networking layer and wire up v9 login flow with unit tests.
Introduce APIClient/AuthAPI, complete login with multi-account selection, and polish the login card UI with shadow and keyboard dismiss. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
29
suixinkanTests/APIErrorTests.swift
Normal file
29
suixinkanTests/APIErrorTests.swift
Normal file
@ -0,0 +1,29 @@
|
||||
//
|
||||
// APIErrorTests.swift
|
||||
// suixinkanTests
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import suixinkan
|
||||
|
||||
/// 网络错误测试,覆盖登录凭证失效判断。
|
||||
final class APIErrorTests: XCTestCase {
|
||||
func testAuthenticationExpiredForUnauthorizedHTTPStatus() {
|
||||
XCTAssertTrue(APIError.isAuthenticationExpired(APIError.httpStatus(401, "Unauthorized")))
|
||||
XCTAssertTrue(APIError.isAuthenticationExpired(APIError.httpStatus(403, "Forbidden")))
|
||||
}
|
||||
|
||||
func testAuthenticationExpiredForAndroidTokenInvalidCodes() {
|
||||
for code in [180024, 100091, 100090, 100060] {
|
||||
XCTAssertTrue(
|
||||
APIError.isAuthenticationExpired(APIError.serverCode(code, "token 失效")),
|
||||
"code \(code) 应识别为 token 失效"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
func testNetworkErrorIsNotAuthenticationExpired() {
|
||||
XCTAssertFalse(APIError.isAuthenticationExpired(APIError.networkFailed("请求超时,请稍后重试")))
|
||||
XCTAssertFalse(APIError.isAuthenticationExpired(APIError.serverCode(100001, "密码错误")))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user