为 TabBar 和扫码页补充 accessibilityIdentifier,并在模拟器/UI Test 中禁用真实相机采集。

预初始化各 Tab 路由容器,修正 iOS 17 ContentUnavailableView 调用,提升自定义 TabBar 与扫码流程的 UI Test 稳定性。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-29 09:34:09 +08:00
parent d27438b264
commit 79e735f628
7 changed files with 105 additions and 28 deletions

View File

@ -11,6 +11,7 @@ import XCTest
final class SuixinkanApp {
let application: XCUIApplication
private let resetState: Bool
private var hasLaunched = false
/// UI Test
init(
@ -31,10 +32,15 @@ final class SuixinkanApp {
/// App
@discardableResult
func launch(waitForLoading: Bool = true) -> Self {
if application.state == .runningForeground {
if hasLaunched, application.state == .runningForeground {
application.activate()
} else {
if application.state != .notRunning {
application.terminate()
Thread.sleep(forTimeInterval: 0.5)
}
application.launch()
hasLaunched = true
}
dismissSystemAlertsIfNeeded()
if waitForLoading {
@ -72,12 +78,10 @@ final class SuixinkanApp {
/// Tab
var isOnMainTabs: Bool {
TabBarNavigator.Tab.allCases.contains { tab in
let button = application.buttons.matching(
NSPredicate(format: "label == %@", tab.rawValue)
).firstMatch
return button.waitForExistence(timeout: 1)
}
application.buttons[TabBarNavigator.Tab.home.identifier].exists
|| application.buttons[TabBarNavigator.Tab.orders.identifier].exists
|| application.buttons[TabBarNavigator.Tab.statistics.identifier].exists
|| application.buttons[TabBarNavigator.Tab.profile.identifier].exists
}
/// Tab