Integrate CYLTabBar center scan button and unify UIKit navigation.
Add CYLTabBarController with a global scan entry, promote MainTabBarController to the window root after login, replace RouterPath-based navigation with AppNavigator, and fix Profile diffable cell reconfiguration crashes. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
58
suixinkan_iosTests/MainScanPlusButtonTests.swift
Normal file
58
suixinkan_iosTests/MainScanPlusButtonTests.swift
Normal file
@ -0,0 +1,58 @@
|
||||
//
|
||||
// MainScanPlusButtonTests.swift
|
||||
// suixinkanTests
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import suixinkan_ios
|
||||
|
||||
/// 主 TabBar 中间扫码按钮测试,覆盖 CYL PlusButton 配置。
|
||||
@MainActor
|
||||
final class MainScanPlusButtonTests: XCTestCase {
|
||||
|
||||
/// 测试扫码按钮位于订单与数据 Tab 之间的视觉槽位。
|
||||
func testIndexOfPlusButtonInTabBarIsBetweenOrdersAndStatistics() {
|
||||
XCTAssertEqual(MainScanPlusButton.indexOfPlusButtonInTabBar(), 2)
|
||||
}
|
||||
|
||||
/// 测试扫码按钮 accessibility 标识与参考工程一致。
|
||||
func testPlusButtonAccessibilityIdentifier() {
|
||||
guard let button = MainScanPlusButton.plusButton() as? UIButton else {
|
||||
XCTFail("plusButton 应返回 UIButton 实例")
|
||||
return
|
||||
}
|
||||
|
||||
XCTAssertEqual(button.accessibilityIdentifier, "main.scan")
|
||||
XCTAssertEqual(button.accessibilityLabel, "扫码核销")
|
||||
}
|
||||
|
||||
/// 测试主 Tab 容器加载时,CYL 控制器数组与 Tab 属性数组保持一致。
|
||||
func testMainTabBarControllerLoadsWithMatchingCYLAttributes() {
|
||||
let services = AppServices(apiClient: APIClient(session: MainTabRecordingURLSession()))
|
||||
let controller = MainTabBarController(services: services)
|
||||
|
||||
controller.loadViewIfNeeded()
|
||||
|
||||
for tab in AppTab.allCases {
|
||||
XCTAssertNotNil(controller.navigationController(for: tab))
|
||||
XCTAssertEqual(
|
||||
controller.navigationController(for: tab)?.tabBarItem.accessibilityIdentifier,
|
||||
"main.tab.\(tab.rawValue)"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// 主 Tab 测试使用的空网络会话,确保容器加载不触发真实请求。
|
||||
private final class MainTabRecordingURLSession: URLSessionProtocol {
|
||||
/// 返回空成功响应。
|
||||
func data(for request: URLRequest) async throws -> (Data, URLResponse) {
|
||||
let response = HTTPURLResponse(
|
||||
url: request.url ?? URL(string: "https://example.com")!,
|
||||
statusCode: 200,
|
||||
httpVersion: nil,
|
||||
headerFields: nil
|
||||
)!
|
||||
return (Data(), response)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user