完善首页权限申请流程与队列播报体验。
对齐 Android 无权限强制弹窗、角色下拉与申请页交互,补充 UIButton configuration 适配,并增强景区排队 TTS 与相关单元测试。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -123,6 +123,53 @@ final class HomeViewModelTests: XCTestCase {
|
||||
XCTAssertTrue(viewModel.commonMenus.isEmpty)
|
||||
}
|
||||
|
||||
func testPermissionApplyDestinationRoutesReviewingAndRejectedToStatus() async throws {
|
||||
let reviewingJSON = """
|
||||
{"code":100000,"msg":"success","data":[{"code":"AP001","role_id":1,"role_name":"摄影师","scenic_list":[],"status":1,"status_label":"审核中","created_at":"","audit_note":"","audited_at":null,"audited_by":null}]}
|
||||
""".data(using: .utf8)!
|
||||
let rejectedJSON = """
|
||||
{"code":100000,"msg":"success","data":[{"code":"AP002","role_id":1,"role_name":"摄影师","scenic_list":[],"status":3,"status_label":"已驳回","created_at":"","audit_note":"资料不全","audited_at":null,"audited_by":null}]}
|
||||
""".data(using: .utf8)!
|
||||
let session = MockURLSession(responses: [reviewingJSON, rejectedJSON])
|
||||
let api = HomeAPI(client: APIClient(environment: .testing, session: session))
|
||||
let viewModel = HomeViewModel(appStore: appStore)
|
||||
|
||||
let reviewingDestination = await viewModel.resolvePermissionApplyDestination(api: api)
|
||||
let rejectedDestination = await viewModel.resolvePermissionApplyDestination(api: api)
|
||||
XCTAssertEqual(reviewingDestination, .status(applyCode: "AP001"))
|
||||
XCTAssertEqual(rejectedDestination, .status(applyCode: "AP002"))
|
||||
}
|
||||
|
||||
func testPermissionApplyDestinationFallsBackToApply() async throws {
|
||||
let completedJSON = """
|
||||
{"code":100000,"msg":"success","data":[{"code":"AP003","role_id":1,"role_name":"摄影师","scenic_list":[],"status":2,"status_label":"已通过","created_at":"","audit_note":"","audited_at":null,"audited_by":null}]}
|
||||
""".data(using: .utf8)!
|
||||
let emptyJSON = #"{"code":100000,"msg":"success","data":[]}"#.data(using: .utf8)!
|
||||
let session = MockURLSession(responses: [completedJSON, emptyJSON])
|
||||
let api = HomeAPI(client: APIClient(environment: .testing, session: session))
|
||||
let viewModel = HomeViewModel(appStore: appStore)
|
||||
|
||||
let completedDestination = await viewModel.resolvePermissionApplyDestination(api: api)
|
||||
let emptyDestination = await viewModel.resolvePermissionApplyDestination(api: api)
|
||||
XCTAssertEqual(completedDestination, .apply)
|
||||
XCTAssertEqual(emptyDestination, .apply)
|
||||
}
|
||||
|
||||
func testPermissionApplyDestinationFallsBackToApplyOnError() async {
|
||||
let response = HTTPURLResponse(
|
||||
url: URL(string: "https://api-test.zhifly.cn/mock")!,
|
||||
statusCode: 500,
|
||||
httpVersion: nil,
|
||||
headerFields: nil
|
||||
)!
|
||||
let session = MockURLSession(results: [.success((Data(), response))])
|
||||
let api = HomeAPI(client: APIClient(environment: .testing, session: session))
|
||||
let viewModel = HomeViewModel(appStore: appStore)
|
||||
|
||||
let destination = await viewModel.resolvePermissionApplyDestination(api: api)
|
||||
XCTAssertEqual(destination, .apply)
|
||||
}
|
||||
|
||||
func testRolePermissionBuildsCommonMenusAndStoreCardRole() async throws {
|
||||
appStore.session.roleCode = AppRoleCode.storeAdmin.rawValue
|
||||
let permissionResponse = RolePermissionResponse(
|
||||
|
||||
Reference in New Issue
Block a user