模块化 AppStore 并完善素材管理与个人空间设置。
将会话、权限、位置、收款与排队存储拆分为独立模块,同步更新各 ViewModel 与单元测试,并补充素材管理 UI 与个人空间设置交互。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -11,10 +11,10 @@ import XCTest
|
||||
final class StatisticsViewModelTests: XCTestCase {
|
||||
|
||||
override func tearDown() {
|
||||
AppStore.shared.roleCode = ""
|
||||
AppStore.shared.roleName = ""
|
||||
AppStore.shared.currentScenicId = 0
|
||||
AppStore.shared.currentStoreId = 0
|
||||
AppStore.shared.session.roleCode = ""
|
||||
AppStore.shared.session.roleName = ""
|
||||
AppStore.shared.session.currentScenicId = 0
|
||||
AppStore.shared.session.currentStoreId = 0
|
||||
super.tearDown()
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ final class StatisticsViewModelTests: XCTestCase {
|
||||
{"code":100000,"msg":"success","data":{"total":0,"data":[]}}
|
||||
""".data(using: .utf8)!
|
||||
|
||||
AppStore.shared.currentScenicId = 10
|
||||
AppStore.shared.session.currentScenicId = 10
|
||||
let session = MockURLSession(responses: [listJSON])
|
||||
let api = StatisticsAPI(client: APIClient(environment: .testing, session: session))
|
||||
let viewModel = StatisticsViewModel()
|
||||
@ -93,7 +93,7 @@ final class StatisticsViewModelTests: XCTestCase {
|
||||
{"code":100000,"msg":"success","data":{"total":1,"data":[{"date":"2025-12-09","order_count":2,"order_price":"50","refund":"10","received":"90"}]}}
|
||||
""".data(using: .utf8)!
|
||||
|
||||
AppStore.shared.currentScenicId = 10
|
||||
AppStore.shared.session.currentScenicId = 10
|
||||
let session = MockURLSession(responses: [summaryJSON, listJSON])
|
||||
let api = StatisticsAPI(client: APIClient(environment: .testing, session: session))
|
||||
let viewModel = StatisticsViewModel()
|
||||
@ -120,8 +120,8 @@ final class StatisticsViewModelTests: XCTestCase {
|
||||
{"code":100000,"msg":"success","data":{"total":0,"data":[]}}
|
||||
""".data(using: .utf8)!
|
||||
|
||||
AppStore.shared.roleCode = AppRoleCode.scenicAdmin.rawValue
|
||||
AppStore.shared.currentScenicId = 20
|
||||
AppStore.shared.session.roleCode = AppRoleCode.scenicAdmin.rawValue
|
||||
AppStore.shared.session.currentScenicId = 20
|
||||
let session = MockURLSession(responses: [summaryJSON, listJSON])
|
||||
let api = StatisticsAPI(client: APIClient(environment: .testing, session: session))
|
||||
let viewModel = StatisticsViewModel()
|
||||
@ -141,8 +141,8 @@ final class StatisticsViewModelTests: XCTestCase {
|
||||
{"code":100000,"msg":"success","data":{"total":0,"data":[]}}
|
||||
""".data(using: .utf8)!
|
||||
|
||||
AppStore.shared.roleCode = AppRoleCode.storeAdmin.rawValue
|
||||
AppStore.shared.currentStoreId = 30
|
||||
AppStore.shared.session.roleCode = AppRoleCode.storeAdmin.rawValue
|
||||
AppStore.shared.session.currentStoreId = 30
|
||||
let session = MockURLSession(responses: [summaryJSON, listJSON])
|
||||
let api = StatisticsAPI(client: APIClient(environment: .testing, session: session))
|
||||
let viewModel = StatisticsViewModel()
|
||||
@ -156,8 +156,8 @@ final class StatisticsViewModelTests: XCTestCase {
|
||||
}
|
||||
|
||||
func testStoreAdminWithoutStoreIdDoesNotRequest() async {
|
||||
AppStore.shared.roleCode = AppRoleCode.storeAdmin.rawValue
|
||||
AppStore.shared.currentStoreId = 0
|
||||
AppStore.shared.session.roleCode = AppRoleCode.storeAdmin.rawValue
|
||||
AppStore.shared.session.currentStoreId = 0
|
||||
let session = MockURLSession(responses: [])
|
||||
let api = StatisticsAPI(client: APIClient(environment: .testing, session: session))
|
||||
let viewModel = StatisticsViewModel()
|
||||
@ -175,7 +175,7 @@ final class StatisticsViewModelTests: XCTestCase {
|
||||
{"code":100000,"msg":"success","data":{"total":1,"data":[{"date":"2025-12-09","order_count":1,"order_price":"10","refund":"0","received":"10"}]}}
|
||||
""".data(using: .utf8)!
|
||||
|
||||
AppStore.shared.currentScenicId = 10
|
||||
AppStore.shared.session.currentScenicId = 10
|
||||
let session = MockURLSession(responses: [page1JSON])
|
||||
let api = StatisticsAPI(client: APIClient(environment: .testing, session: session))
|
||||
let viewModel = StatisticsViewModel()
|
||||
|
||||
Reference in New Issue
Block a user