迁移合作订单完整能力,并统一 AppRoleCode 角色权限与首页菜单展示。
新增 CooperationOrder 模块(双 Tab 列表、获客员绑定、主 Tab 扫码)、订单来源/带客单绑定及配套 API 测试;同步引入 roleCode 权限匹配与相关单元测试。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -18,7 +18,7 @@ final class StatisticsViewModelTests: XCTestCase {
|
||||
api.dailyResponses = [try TestFixture.payload(DataListPayload<StatisticsDailyItem>.self, named: "statistics_daily_page1_total3")]
|
||||
let viewModel = StatisticsViewModel()
|
||||
|
||||
try await viewModel.reload(api: api, scenicId: 88, roleId: nil)
|
||||
try await viewModel.reload(api: api, scenicId: 88, appRole: nil)
|
||||
|
||||
XCTAssertEqual(viewModel.summary.orderCount, 18)
|
||||
XCTAssertEqual(viewModel.dailyItems.map(\.date), ["2026-05-23"])
|
||||
@ -44,11 +44,11 @@ final class StatisticsViewModelTests: XCTestCase {
|
||||
]
|
||||
let viewModel = StatisticsViewModel()
|
||||
|
||||
try await viewModel.reload(api: api, scenicId: 88, roleId: nil)
|
||||
try await viewModel.loadMore(api: api, scenicId: 88, roleId: nil)
|
||||
try await viewModel.reload(api: api, scenicId: 88, appRole: nil)
|
||||
try await viewModel.loadMore(api: api, scenicId: 88, appRole: nil)
|
||||
XCTAssertEqual(viewModel.dailyItems.count, 3)
|
||||
|
||||
try await viewModel.selectPeriod(.sevenDays, api: api, scenicId: 88, roleId: nil)
|
||||
try await viewModel.selectPeriod(.sevenDays, api: api, scenicId: 88, appRole: nil)
|
||||
|
||||
XCTAssertEqual(viewModel.selectedPeriod, .sevenDays)
|
||||
XCTAssertEqual(viewModel.dailyItems.map(\.date), ["2026-05-23"])
|
||||
@ -70,8 +70,8 @@ final class StatisticsViewModelTests: XCTestCase {
|
||||
]
|
||||
let viewModel = StatisticsViewModel()
|
||||
|
||||
try await viewModel.reload(api: api, scenicId: 88, roleId: nil)
|
||||
try await viewModel.loadMore(api: api, scenicId: 88, roleId: nil)
|
||||
try await viewModel.reload(api: api, scenicId: 88, appRole: nil)
|
||||
try await viewModel.loadMore(api: api, scenicId: 88, appRole: nil)
|
||||
|
||||
XCTAssertEqual(viewModel.dailyItems.map(\.date), ["2026-05-23", "2026-05-22", "2026-05-21"])
|
||||
XCTAssertFalse(viewModel.hasMore)
|
||||
@ -86,11 +86,11 @@ final class StatisticsViewModelTests: XCTestCase {
|
||||
api.dailyResponses = [try TestFixture.payload(DataListPayload<StatisticsDailyItem>.self, named: "statistics_daily_page1_total3")]
|
||||
let viewModel = StatisticsViewModel()
|
||||
|
||||
try await viewModel.reload(api: api, scenicId: 88, roleId: nil)
|
||||
try await viewModel.reload(api: api, scenicId: 88, appRole: nil)
|
||||
api.nextDailyError = APIError.httpStatus(500, "server error")
|
||||
|
||||
do {
|
||||
try await viewModel.loadMore(api: api, scenicId: 88, roleId: nil)
|
||||
try await viewModel.loadMore(api: api, scenicId: 88, appRole: nil)
|
||||
XCTFail("Expected load more to fail")
|
||||
} catch APIError.httpStatus(let statusCode, _) {
|
||||
XCTAssertEqual(statusCode, 500)
|
||||
@ -110,10 +110,10 @@ final class StatisticsViewModelTests: XCTestCase {
|
||||
api.dailyResponses = [try TestFixture.payload(DataListPayload<StatisticsDailyItem>.self, named: "statistics_daily_page1_total3")]
|
||||
let viewModel = StatisticsViewModel()
|
||||
|
||||
try await viewModel.reload(api: api, scenicId: 88, roleId: nil)
|
||||
try await viewModel.reload(api: api, scenicId: 88, appRole: nil)
|
||||
XCTAssertEqual(viewModel.summary.orderCount, 18)
|
||||
|
||||
try await viewModel.reload(api: api, scenicId: nil, roleId: nil)
|
||||
try await viewModel.reload(api: api, scenicId: nil, appRole: nil)
|
||||
|
||||
XCTAssertEqual(api.summaryCalls.count, 1)
|
||||
XCTAssertEqual(viewModel.summary.orderCount, 0)
|
||||
|
||||
Reference in New Issue
Block a user