集成 MJRefresh 并重构主 TabBar 为系统 TabView 样式。
新增 SwiftUI 桥接层与单元测试,更新 Tab 图标资源命名和多倍图,同步调整 UI Test 的 Tab/扫码定位逻辑。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -59,17 +59,20 @@ final class OrdersFlowUITests: AuthenticatedUITestCase {
|
||||
}
|
||||
}
|
||||
|
||||
/// 测试扫码页可打开并关闭。
|
||||
func testScannerCanOpenAndClose() {
|
||||
TabBarNavigator.select(.orders, app: app)
|
||||
/// 测试全局扫码页可打开关闭,关闭后仍停留在打开前的 Tab。
|
||||
func testScannerCanOpenAndCloseWithoutChangingCurrentTab() {
|
||||
TabBarNavigator.select(.home, app: app)
|
||||
|
||||
let scanButton = app.application.buttons["main.scan"]
|
||||
let scanButton = TabBarNavigator.scannerButton(in: app)
|
||||
XCTAssertTrue(scanButton.waitForExistence(timeout: 6))
|
||||
scanButton.tap()
|
||||
|
||||
let closeButton = app.application.buttons["scanner.close"]
|
||||
XCTAssertTrue(closeButton.waitForExistence(timeout: 8))
|
||||
closeButton.tap()
|
||||
NavigationAssertions.waitForNavigationTitle("订单", in: app)
|
||||
XCTAssertTrue(
|
||||
app.application.staticTexts["常用应用"].waitForExistence(timeout: 8)
|
||||
|| app.application.staticTexts["请选择景区"].exists
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,10 +78,7 @@ final class SuixinkanApp {
|
||||
|
||||
/// 判断主 Tab 是否已出现。
|
||||
var isOnMainTabs: Bool {
|
||||
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
|
||||
TabBarNavigator.isVisible(in: self)
|
||||
}
|
||||
|
||||
/// 等待冷启动后进入登录页或主 Tab。
|
||||
|
||||
@ -37,7 +37,31 @@ enum TabBarNavigator {
|
||||
app.waitForGlobalLoadingToDisappear()
|
||||
}
|
||||
|
||||
/// 在底部自定义 TabBar 中定位唯一可点击的 Tab 按钮。
|
||||
/// 获取主界面的扫码入口按钮。
|
||||
static func scannerButton(in app: SuixinkanApp) -> XCUIElement {
|
||||
let identifiedButton = app.application.buttons["main.scan"]
|
||||
if identifiedButton.exists {
|
||||
return identifiedButton
|
||||
}
|
||||
|
||||
let systemTabButton = app.application.tabBars.buttons["扫码核销"]
|
||||
if systemTabButton.exists {
|
||||
return systemTabButton
|
||||
}
|
||||
|
||||
return bottomTabButton(named: "扫码核销", in: app)
|
||||
}
|
||||
|
||||
/// 判断主 Tab 是否已经出现在界面上。
|
||||
static func isVisible(in app: SuixinkanApp) -> Bool {
|
||||
Tab.allCases.contains { tab in
|
||||
app.application.tabBars.buttons[tab.rawValue].exists
|
||||
|| app.application.buttons[tab.identifier].exists
|
||||
|| app.application.buttons[tab.rawValue].exists
|
||||
}
|
||||
}
|
||||
|
||||
/// 在底部系统 TabBar 或旧自定义 TabBar 中定位唯一可点击的 Tab 按钮。
|
||||
private static func bottomTabButton(named title: String, in app: SuixinkanApp) -> XCUIElement {
|
||||
if let tab = Tab(rawValue: title) {
|
||||
let identifiedButton = app.application.buttons[tab.identifier]
|
||||
@ -46,6 +70,11 @@ enum TabBarNavigator {
|
||||
}
|
||||
}
|
||||
|
||||
let systemTabButton = app.application.tabBars.buttons[title]
|
||||
if systemTabButton.exists {
|
||||
return systemTabButton
|
||||
}
|
||||
|
||||
let candidates = app.application.buttons.matching(NSPredicate(format: "label == %@", title))
|
||||
let screenHeight = app.application.windows.element(boundBy: 0).frame.height
|
||||
var bestMatch: XCUIElement?
|
||||
|
||||
Reference in New Issue
Block a user