适配上传中订单并完善机巢操作与订阅兜底
支持订单状态 25 和持续拍摄、交付确认;安全指令点击后直接提交;鉴权超时保留 HTTP 兜底并退避换票重连。补充对应隔离回归测试。
This commit is contained in:
@@ -183,6 +183,23 @@ final class DroneDockPreparationViewModelTests: XCTestCase {
|
||||
XCTAssertNil(model.errorMessage)
|
||||
}
|
||||
|
||||
/// 先前素材上传不阻止继续拍摄,最新购买额度与许可仍独立限制创建。
|
||||
func testUploadingOrderCanPrepareNextShotOnlyWithRemainingQuotaAndPermission() async throws {
|
||||
let service = try ImmediatePreparationService()
|
||||
let model = try makeModel(service: service, orderStatus: 25)
|
||||
for (remaining, canCreate, expected) in [(4, true, true), (0, true, false), (4, false, false)] {
|
||||
service.projectResult = .success(try PreparationFixture.project(remaining: remaining,
|
||||
canCreate: canCreate, orderStatus: 25))
|
||||
await model.refresh()
|
||||
XCTAssertEqual(model.projectInfo?.order.orderStatus, 25)
|
||||
XCTAssertEqual(model.projectInfo?.order.shotRemain, remaining)
|
||||
XCTAssertEqual(model.canCreateTask, expected)
|
||||
if remaining == 0 { XCTAssertEqual(model.primaryButtonTitle, "拍摄次数已用完") }
|
||||
}
|
||||
XCTAssertEqual(service.projectRequests.count, 3)
|
||||
XCTAssertNil(model.createdTask, "只核对准备门禁,不调用创建或召唤")
|
||||
}
|
||||
|
||||
/// 购买权限与次数各自独立,未知或已耗尽不能允许新增任务。
|
||||
func testAdmissionUsesPurchasedPermissionAndKnownQuota() async throws {
|
||||
let service = try ImmediatePreparationService()
|
||||
@@ -559,11 +576,12 @@ final class DroneDockPreparationViewModelTests: XCTestCase {
|
||||
|
||||
/// 每例使用内存订单和会话,不接触真实账号。
|
||||
private func makeModel(service: any DroneDockPreparationServing, scope: PreparationContextBox? = nil,
|
||||
projectID: Int? = 101, planeService: (any DroneDockPlaneStatusServing)? = nil) throws -> DroneDockPreparationViewModel {
|
||||
projectID: Int? = 101, orderStatus: Int? = nil, planeService: (any DroneDockPlaneStatusServing)? = nil) throws -> DroneDockPreparationViewModel {
|
||||
let scope = scope ?? PreparationContextBox(context())
|
||||
var order: [String: Any] = ["order_number": "TEST-PREPARATION-001", "project_name": "旧列表套餐",
|
||||
"shoot_count": 9, "shot_count": 2, "remaining_count": 7]
|
||||
order["project_id"] = projectID
|
||||
order["order_status"] = orderStatus
|
||||
let decoded = try JSONDecoder().decode(DroneDockHomeOrder.self, from: JSONSerialization.data(withJSONObject: order))
|
||||
return DroneDockPreparationViewModel(context: scope.value, order: decoded, service: service,
|
||||
planeStatusService: try planeService ?? DroneDockPlaneStatusTestService(),
|
||||
@@ -585,11 +603,12 @@ private enum PreparationFixture {
|
||||
/// 购买快照使用五次额度,刻意与首页旧数据不同。
|
||||
static func project(spots: [[String: Any]]? = nil, projectID: Int = 101,
|
||||
number: String = "TEST-PREPARATION-001", remaining: Int? = 5,
|
||||
canCreate: Bool = true) throws -> DroneDockProjectInfoResponse {
|
||||
canCreate: Bool = true, orderStatus: Int? = nil) throws -> DroneDockProjectInfoResponse {
|
||||
var value: [String: Any] = ["order_number": number, "project_id": projectID, "project_name": "已购五次套餐",
|
||||
"shoot_count": 5, "shot_count": 0, "can_create_task": canCreate,
|
||||
"spot": spots ?? [point(201), point(202, routes: [401, 402])]]
|
||||
value["remaining_count"] = remaining
|
||||
value["order_status"] = orderStatus
|
||||
return try JSONDecoder().decode(DroneDockProjectInfoResponse.self, from: JSONSerialization.data(withJSONObject: value))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user