优化 UI Test 路由直达与会话复用,提升自定义 TabBar 下的稳定性。
新增启动参数直达首页与个人中心页面,引入 AppUITestRouteDriver 与 UITestSession 共享登录,并重构各模块用例的导航断言逻辑。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -18,10 +18,26 @@ enum NavigationAssertions {
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line
|
||||
) -> Bool {
|
||||
let navigationBar = app.application.navigationBars[title]
|
||||
let exists = navigationBar.waitForExistence(timeout: timeout)
|
||||
XCTAssertTrue(exists, "未找到导航标题:\(title)", file: file, line: line)
|
||||
return exists
|
||||
let deadline = Date().addingTimeInterval(timeout)
|
||||
while Date() < deadline {
|
||||
if app.application.navigationBars[title].exists {
|
||||
return true
|
||||
}
|
||||
|
||||
let topBar = app.application.navigationBars.element(boundBy: 0)
|
||||
if topBar.staticTexts[title].exists {
|
||||
return true
|
||||
}
|
||||
|
||||
if app.application.staticTexts[title].exists {
|
||||
return true
|
||||
}
|
||||
|
||||
RunLoop.current.run(until: Date().addingTimeInterval(0.2))
|
||||
}
|
||||
|
||||
XCTAssertTrue(false, "未找到导航标题:\(title)", file: file, line: line)
|
||||
return false
|
||||
}
|
||||
|
||||
/// 等待任意一个导航标题出现。
|
||||
@ -39,6 +55,15 @@ enum NavigationAssertions {
|
||||
if app.application.navigationBars[title].exists {
|
||||
return title
|
||||
}
|
||||
|
||||
let topBar = app.application.navigationBars.element(boundBy: 0)
|
||||
if topBar.staticTexts[title].exists {
|
||||
return title
|
||||
}
|
||||
|
||||
if app.application.staticTexts[title].exists {
|
||||
return title
|
||||
}
|
||||
}
|
||||
RunLoop.current.run(until: Date().addingTimeInterval(0.2))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user