优化 UI Test 路由直达与会话复用,提升自定义 TabBar 下的稳定性。

新增启动参数直达首页与个人中心页面,引入 AppUITestRouteDriver 与 UITestSession 共享登录,并重构各模块用例的导航断言逻辑。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-26 11:25:36 +08:00
parent 0c01ee26c3
commit aac8458b04
31 changed files with 587 additions and 166 deletions

View File

@ -7,9 +7,8 @@ import XCTest
final class InviteUITests: AuthenticatedUITestCase {
///
func testInviteAndRecordPages() {
DebugMenuNavigator.open(app: app)
DebugMenuNavigator.tapMenu(title: "注册邀请", app: app)
func testInviteAndRecordPages() throws {
app = try UITestSession.relaunch(openMenu: "注册邀请")
NavigationAssertions.waitForNavigationTitle("摄影师邀请", in: app)
let recordEntry = app.application.staticTexts.matching(NSPredicate(format: "label CONTAINS '邀请记录'")).firstMatch
@ -17,9 +16,7 @@ final class InviteUITests: AuthenticatedUITestCase {
recordEntry.tap()
NavigationAssertions.waitForNavigationTitle("邀请记录", in: app)
} else {
BackNavigator.goBack(app: app)
DebugMenuNavigator.open(app: app)
DebugMenuNavigator.tapMenu(title: "邀请记录", app: app)
app = try UITestSession.relaunch(openMenu: "邀请记录")
NavigationAssertions.waitForNavigationTitle("邀请记录", in: app)
}
}

View File

@ -7,9 +7,8 @@ import XCTest
final class LiveUITests: AuthenticatedUITestCase {
///
func testLiveManagementAndCreatePage() {
DebugMenuNavigator.open(app: app)
DebugMenuNavigator.tapMenu(title: "直播管理", app: app)
func testLiveManagementAndCreatePage() throws {
app = try UITestSession.relaunch(openMenu: "直播管理")
NavigationAssertions.waitForNavigationTitle("直播管理", in: app)
let addButton = app.application.buttons.matching(NSPredicate(format: "label CONTAINS '添加'")).firstMatch
@ -21,9 +20,8 @@ final class LiveUITests: AuthenticatedUITestCase {
}
///
func testLiveAlbumPage() {
DebugMenuNavigator.open(app: app)
DebugMenuNavigator.tapMenu(title: "直播相册", app: app)
func testLiveAlbumPage() throws {
app = try UITestSession.relaunch(openMenu: "直播相册")
NavigationAssertions.waitForNavigationTitle("直播相册", in: app)
}
}

View File

@ -7,9 +7,8 @@ import XCTest
final class LocationReportUITests: AuthenticatedUITestCase {
///
func testLocationReportAndHistory() {
DebugMenuNavigator.open(app: app)
DebugMenuNavigator.tapMenu(title: "位置上报", app: app)
func testLocationReportAndHistory() throws {
app = try UITestSession.relaunch(openMenu: "位置上报")
NavigationAssertions.waitForNavigationTitle("位置上报", in: app)
let historyEntry = app.application.staticTexts.matching(NSPredicate(format: "label CONTAINS '历史'")).firstMatch
@ -17,9 +16,7 @@ final class LocationReportUITests: AuthenticatedUITestCase {
historyEntry.tap()
NavigationAssertions.waitForNavigationTitle("位置上报历史", in: app)
} else {
BackNavigator.goBack(app: app)
DebugMenuNavigator.open(app: app)
DebugMenuNavigator.tapMenu(title: "定位上报历史", app: app)
app = try UITestSession.relaunch(openMenu: "定位上报历史")
NavigationAssertions.waitForNavigationTitle("位置上报历史", in: app)
}
}

View File

@ -7,9 +7,8 @@ import XCTest
final class MessageCenterUITests: AuthenticatedUITestCase {
///
func testMessageCenterListAndDetail() {
DebugMenuNavigator.open(app: app)
DebugMenuNavigator.tapMenu(title: "消息中心", app: app)
func testMessageCenterListAndDetail() throws {
app = try UITestSession.relaunch(openMenu: "消息中心")
NavigationAssertions.waitForNavigationTitle("消息中心", in: app)
let firstCell = app.application.cells.element(boundBy: 0)

View File

@ -7,9 +7,8 @@ import XCTest
final class PilotCertificationUITests: AuthenticatedUITestCase {
///
func testPilotCertificationValidation() {
DebugMenuNavigator.open(app: app)
DebugMenuNavigator.tapMenu(title: "飞手认证", app: app)
func testPilotCertificationValidation() throws {
app = try UITestSession.relaunch(openMenu: "飞手认证")
NavigationAssertions.waitForNavigationTitle("飞手认证", in: app)
let submitButton = app.application.buttons.matching(NSPredicate(format: "label CONTAINS '提交'")).firstMatch

View File

@ -7,9 +7,8 @@ import XCTest
final class ProjectsUITests: AuthenticatedUITestCase {
///
func testProjectManagementCreatePage() {
DebugMenuNavigator.open(app: app)
DebugMenuNavigator.tapMenu(title: "项目管理", app: app)
func testProjectManagementCreatePage() throws {
app = try UITestSession.relaunch(openMenu: "项目管理")
NavigationAssertions.waitForNavigationTitle("项目管理", in: app)
let createButton = app.application.buttons.matching(NSPredicate(format: "label CONTAINS '新建'")).firstMatch
@ -21,9 +20,8 @@ final class ProjectsUITests: AuthenticatedUITestCase {
}
///
func testStoreProjectManagementPage() {
DebugMenuNavigator.open(app: app)
DebugMenuNavigator.tapMenu(title: "店铺项目管理", app: app)
func testStoreProjectManagementPage() throws {
app = try UITestSession.relaunch(openMenu: "店铺项目管理")
NavigationAssertions.waitForNavigationTitle("店铺项目管理", in: app)
}
}

View File

@ -7,9 +7,8 @@ import XCTest
final class PunchPointUITests: AuthenticatedUITestCase {
///
func testPunchPointListAndCreatePage() {
DebugMenuNavigator.open(app: app)
DebugMenuNavigator.tapMenu(title: "打卡点管理", app: app)
func testPunchPointListAndCreatePage() throws {
app = try UITestSession.relaunch(openMenu: "打卡点管理")
NavigationAssertions.waitForNavigationTitle("打卡点管理", in: app)
let createButton = app.application.buttons.matching(NSPredicate(format: "label CONTAINS '新增'")).firstMatch

View File

@ -7,9 +7,8 @@ import XCTest
final class QueueManagementUITests: AuthenticatedUITestCase {
///
func testQueueManagementAndSettings() {
DebugMenuNavigator.open(app: app)
DebugMenuNavigator.tapMenu(title: "排队管理", app: app)
func testQueueManagementAndSettings() throws {
app = try UITestSession.relaunch(openMenu: "排队管理")
NavigationAssertions.waitForNavigationTitle("排队管理", in: app)
let settingsEntry = app.application.staticTexts.matching(NSPredicate(format: "label CONTAINS '设置'")).firstMatch

View File

@ -7,9 +7,8 @@ import XCTest
final class ScheduleUITests: AuthenticatedUITestCase {
///
func testScheduleManagementAndAddPage() {
DebugMenuNavigator.open(app: app)
DebugMenuNavigator.tapMenu(title: "日程管理", app: app)
func testScheduleManagementAndAddPage() throws {
app = try UITestSession.relaunch(openMenu: "日程管理")
NavigationAssertions.waitForNavigationTitle("日程管理", in: app)
let addButton = app.application.buttons.matching(NSPredicate(format: "label CONTAINS '添加'")).firstMatch

View File

@ -8,7 +8,7 @@ import XCTest
final class TasksUITests: AuthenticatedUITestCase {
///
func testTaskListDetailAndCreateValidation() throws {
openTaskManagement()
try openTaskManagement()
let firstCell = app.application.cells.element(boundBy: 0)
if firstCell.waitForExistence(timeout: 10) {
@ -19,14 +19,13 @@ final class TasksUITests: AuthenticatedUITestCase {
throw XCTSkip("测试账号暂无任务数据,跳过详情流测试。")
}
DebugMenuNavigator.open(app: app)
DebugMenuNavigator.tapMenu(title: "发布任务", app: app)
app = try UITestSession.relaunch(openMenu: "发布任务")
NavigationAssertions.waitForNavigationTitle("发布任务", in: app)
}
private func openTaskManagement() {
DebugMenuNavigator.open(app: app)
DebugMenuNavigator.tapMenu(title: "任务管理", app: app)
///
private func openTaskManagement() throws {
app = try UITestSession.relaunch(openMenu: "任务管理")
NavigationAssertions.waitForNavigationTitle("任务管理", in: app)
}
}

View File

@ -7,10 +7,10 @@ import XCTest
final class WalletUITests: AuthenticatedUITestCase {
///
func testWalletWithdrawValidation() {
openWallet()
func testWalletWithdrawValidation() throws {
try openWallet()
app.application.staticTexts["提现"].tap()
UITestTapHelper.tapLabel("提现", in: app)
NavigationAssertions.waitForNavigationTitle("提现申请", in: app)
let submitButton = app.application.buttons["提交提现申请"]
@ -23,20 +23,20 @@ final class WalletUITests: AuthenticatedUITestCase {
}
///
func testWalletSecondaryPages() {
openWallet()
func testWalletSecondaryPages() throws {
try openWallet()
app.application.staticTexts["银行卡"].tap()
UITestTapHelper.tapLabel("银行卡", in: app)
NavigationAssertions.waitForNavigationTitle("银行卡设置", in: app)
BackNavigator.goBack(app: app)
app.application.staticTexts["积分兑换"].tap()
UITestTapHelper.tapLabel("积分兑换", in: app)
NavigationAssertions.waitForNavigationTitle("积分兑换", in: app)
}
private func openWallet() {
DebugMenuNavigator.open(app: app)
DebugMenuNavigator.tapMenu(title: "我的钱包", app: app)
///
private func openWallet() throws {
app = try UITestSession.relaunch(openMenu: "我的钱包")
NavigationAssertions.waitForNavigationTitle("我的钱包", in: app)
}
}