优化 UI Test 路由直达与会话复用,提升自定义 TabBar 下的稳定性。
新增启动参数直达首页与个人中心页面,引入 AppUITestRouteDriver 与 UITestSession 共享登录,并重构各模块用例的导航断言逻辑。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -13,12 +13,36 @@ enum AppUITestLaunchState {
|
||||
static let uiTestsArgument = "-suixinkan-ui-tests"
|
||||
/// 冷启动前清理本地登录缓存。
|
||||
static let resetArgument = "-suixinkan-ui-tests-reset-state"
|
||||
/// 登录后直达首页调试菜单项(下一参数为菜单标题)。
|
||||
static let openMenuArgument = "-suixinkan-ui-tests-open-menu"
|
||||
/// 登录后直达个人中心二级页(下一参数为路由名)。
|
||||
static let openProfileArgument = "-suixinkan-ui-tests-open-profile"
|
||||
|
||||
/// 当前进程是否由 XCUITest 启动。
|
||||
static var isRunningUITests: Bool {
|
||||
ProcessInfo.processInfo.arguments.contains(uiTestsArgument)
|
||||
}
|
||||
|
||||
/// 待打开的首页调试菜单标题。
|
||||
static var pendingMenuTitle: String? {
|
||||
argumentValue(following: openMenuArgument)
|
||||
}
|
||||
|
||||
/// 待打开的个人中心路由标识。
|
||||
static var pendingProfileRouteRawValue: String? {
|
||||
argumentValue(following: openProfileArgument)
|
||||
}
|
||||
|
||||
/// 读取启动参数中紧跟在指定 flag 后的值。
|
||||
private static func argumentValue(following flag: String) -> String? {
|
||||
let arguments = ProcessInfo.processInfo.arguments
|
||||
guard let index = arguments.firstIndex(of: flag), index + 1 < arguments.count else {
|
||||
return nil
|
||||
}
|
||||
let value = arguments[index + 1].trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
return value.isEmpty ? nil : value
|
||||
}
|
||||
|
||||
/// 按需在冷启动时清理 token、账号快照和偏好设置。
|
||||
static func resetIfNeeded(arguments: [String] = ProcessInfo.processInfo.arguments) {
|
||||
guard arguments.contains(resetArgument) else { return }
|
||||
|
||||
Reference in New Issue
Block a user