feat(drone-dock): 接入素材下载并限制拍满后游客确认
This commit is contained in:
@@ -170,6 +170,8 @@ final class DroneDockOrdersViewTests: XCTestCase {
|
||||
/// 确认主按钮进入正式共用页面,来源列表不自动出码,也不进入演示确认页面。
|
||||
func testConfirmationRoutesToInjectedPageWithoutWritingFromOrders() async throws {
|
||||
var order = record("ACTIONS", status: "processing")
|
||||
order["shot_count"] = 5
|
||||
order["remaining_count"] = 0
|
||||
order["can_create_task"] = false
|
||||
order["can_confirm"] = true
|
||||
order["can_upload_film"] = true
|
||||
@@ -186,6 +188,9 @@ final class DroneDockOrdersViewTests: XCTestCase {
|
||||
let list = try collection(in: controller)
|
||||
try await settle(window) { controller.viewModel.total == 1 }
|
||||
let cell = try await card(at: 0, in: list, window: window)
|
||||
let summary = try XCTUnwrap(find(in: cell, id: "drone.orders.order.TEST-ORDER-ACTIONS.confirmation") as? UIControl)
|
||||
XCTAssertFalse(hidden(summary))
|
||||
XCTAssertTrue(summary.isEnabled)
|
||||
let control = try XCTUnwrap(find(in: cell, id: "drone.orders.order.TEST-ORDER-ACTIONS.primary") as? UIControl)
|
||||
XCTAssertTrue(control.isEnabled)
|
||||
control.sendActions(for: .touchUpInside)
|
||||
@@ -197,6 +202,95 @@ final class DroneDockOrdersViewTests: XCTestCase {
|
||||
assertOnlyOrders(session)
|
||||
}
|
||||
|
||||
/// 未拍满、零套餐或未知计数均隐藏确认摘要,后端权限和旧完成标记不能绕过次数限制。
|
||||
func testIncompleteOrdersHideConfirmationEvenWhenServerAllowsIt() async throws {
|
||||
let counts: [(Int?, Int?)] = [(5, 4), (5, 0), (0, 0), (nil, 5), (5, nil)]
|
||||
let records = counts.enumerated().map { index, pair in
|
||||
var value = record("INCOMPLETE-\(index)", status: "completed")
|
||||
value["shoot_count"] = pair.0.map { $0 as Any } ?? NSNull()
|
||||
value["shot_count"] = pair.1.map { $0 as Any } ?? NSNull()
|
||||
value["can_confirm"] = true
|
||||
value["can_upload_film"] = true
|
||||
return value
|
||||
}
|
||||
var confirmations = 0
|
||||
let (controller, session) = makeController(responses: [try envelope(records, total: records.count)], confirmationFactory: { _, _ in
|
||||
confirmations += 1
|
||||
return UIViewController()
|
||||
})
|
||||
let window = makeWindow(root: controller)
|
||||
defer { close(window) }
|
||||
let list = try collection(in: controller)
|
||||
try await settle(window) { controller.viewModel.orders.count == records.count }
|
||||
for index in records.indices {
|
||||
let cell = try await card(at: index, in: list, window: window)
|
||||
let id = "drone.orders.order.TEST-ORDER-INCOMPLETE-\(index)"
|
||||
let control = try XCTUnwrap(find(in: cell, id: id + ".confirmation") as? UIControl)
|
||||
XCTAssertTrue(hidden(control))
|
||||
control.sendActions(for: .touchUpInside)
|
||||
XCTAssertFalse(visibleTexts(in: cell).contains("邀请确认"))
|
||||
XCTAssertFalse(visibleTexts(in: cell).contains("请游客确认"))
|
||||
XCTAssertTrue(controller.navigationController?.topViewController === controller)
|
||||
}
|
||||
XCTAssertEqual(confirmations, 0)
|
||||
XCTAssertEqual(session.requests.count, 1)
|
||||
assertOnlyOrders(session)
|
||||
}
|
||||
|
||||
/// 同一张卡从拍满更新为未拍满时撤下旧入口,强制触发隐藏控件也不会调用确认。
|
||||
func testReusedOrderCardRemovesPreviouslyAvailableConfirmation() throws {
|
||||
let card = DroneShootingOrderCardView()
|
||||
var value = record("REUSE", status: "processing")
|
||||
value["shot_count"] = 5
|
||||
value["remaining_count"] = 0
|
||||
value["can_create_task"] = false
|
||||
value["can_confirm"] = true
|
||||
var confirmations = 0
|
||||
card.onConfirmationTap = { confirmations += 1 }
|
||||
let complete = try JSONDecoder().decode(DroneDockHomeOrder.self, from: JSONSerialization.data(withJSONObject: value))
|
||||
card.apply(homeOrder: complete)
|
||||
let confirmation = try XCTUnwrap(find(in: card, id: "drone.orders.order.TEST-ORDER-REUSE.confirmation") as? UIControl)
|
||||
XCTAssertFalse(hidden(confirmation))
|
||||
confirmation.sendActions(for: .touchUpInside)
|
||||
XCTAssertEqual(confirmations, 1)
|
||||
|
||||
value["shot_count"] = 4
|
||||
value["remaining_count"] = 1
|
||||
let incomplete = try JSONDecoder().decode(DroneDockHomeOrder.self, from: JSONSerialization.data(withJSONObject: value))
|
||||
card.apply(homeOrder: incomplete)
|
||||
XCTAssertTrue(hidden(confirmation))
|
||||
confirmation.sendActions(for: .touchUpInside)
|
||||
try button(in: card, id: "drone.orders.order.TEST-ORDER-REUSE.primary").sendActions(for: .touchUpInside)
|
||||
XCTAssertEqual(confirmations, 1)
|
||||
}
|
||||
|
||||
/// 拍摄已满但尚不允许确认时,不显示可操作的邀请按钮,也不绕过后端权限进入确认页。
|
||||
func testCompletedQuotaWithoutConfirmationPermissionCannotNavigate() async throws {
|
||||
var order = record("NO-CONFIRM", status: "processing")
|
||||
order["shot_count"] = 5
|
||||
order["remaining_count"] = 0
|
||||
order["can_create_task"] = false
|
||||
order["can_upload_film"] = true
|
||||
order["can_confirm"] = false
|
||||
var confirmations = 0
|
||||
let (controller, session) = makeController(responses: [try envelope([order], total: 1)], confirmationFactory: { _, _ in
|
||||
confirmations += 1
|
||||
return UIViewController()
|
||||
})
|
||||
let window = makeWindow(root: controller)
|
||||
defer { close(window) }
|
||||
let list = try collection(in: controller)
|
||||
try await settle(window) { controller.viewModel.total == 1 }
|
||||
let cell = try await card(at: 0, in: list, window: window)
|
||||
let confirmation = try XCTUnwrap(find(in: cell, id: "drone.orders.order.TEST-ORDER-NO-CONFIRM.confirmation") as? UIControl)
|
||||
XCTAssertFalse(confirmation.isEnabled)
|
||||
confirmation.sendActions(for: .touchUpInside)
|
||||
XCTAssertEqual(try button(in: cell, id: "drone.orders.order.TEST-ORDER-NO-CONFIRM.primary").title(for: .normal), "交付成片")
|
||||
XCTAssertEqual(confirmations, 0)
|
||||
XCTAssertTrue(controller.navigationController?.topViewController === controller)
|
||||
XCTAssertEqual(session.requests.count, 1)
|
||||
}
|
||||
|
||||
/// 主、副交付按钮先展示方式弹窗;选择云端后才在弹窗内读取真实交付数据。
|
||||
func testDeliveryButtonsOpenSharedPageWithoutPreselectingTask() async throws {
|
||||
for hasShootingPermission in [true, false] {
|
||||
|
||||
Reference in New Issue
Block a user