修正拍摄任务状态并优化素材提示显示
区分整单状态与关联任务状态,素材上传中的任务不再占用继续查看入口。列表仅展示上传中或失败提示,保留交付确认入口,并补充状态和卡片复用回归。同步 Build 号至 2020202。
This commit is contained in:
@@ -38,6 +38,7 @@ final class DroneDockOrdersViewTests: XCTestCase {
|
||||
for canCreate in [true, false] {
|
||||
var order = record("ACTIVE", status: "processing")
|
||||
order["active_task_id"] = 801; order["active_task_status"] = 20
|
||||
order["shot_count"] = 5; order["remaining_count"] = 0
|
||||
order["can_create_task"] = canCreate; order["can_upload_film"] = true
|
||||
var ended = order; ended["active_task_id"] = NSNull(); ended["active_task_status"] = NSNull()
|
||||
var taskSession: MockURLSession?
|
||||
@@ -84,6 +85,52 @@ final class DroneDockOrdersViewTests: XCTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
/// 上传任务覆盖滞后的素材完成或失败文案;拍满后提供交付,仍有次数才进入隔离的准备页。
|
||||
func testUploadingActiveTaskDoesNotNavigateToFlightAndKeepsAvailableActions() async throws {
|
||||
for remaining in [0, 1] {
|
||||
var order = record("UPLOADING", status: "processing")
|
||||
order["shoot_count"] = 2; order["shot_count"] = 2 - remaining; order["remaining_count"] = remaining
|
||||
order["order_status"] = 20; order["material_status"] = remaining == 0 ? 1 : 3
|
||||
order["active_task_id"] = 21; order["active_task_status"] = 25
|
||||
order["can_create_task"] = remaining > 0; order["can_upload_film"] = true
|
||||
var openedFlights = 0
|
||||
var openedPreparations = 0
|
||||
let preparation = UIViewController()
|
||||
let (controller, session) = makeController(responses: [try envelope([order], total: 1)],
|
||||
deliveryFactory: { _, _, _ in UIViewController() },
|
||||
taskFactory: { _, _, _ in openedFlights += 1; return UIViewController() },
|
||||
factory: { selected, _ in
|
||||
openedPreparations += 1
|
||||
XCTAssertEqual(selected.activeTaskID, 21)
|
||||
XCTAssertNil(selected.activeFlightTaskID)
|
||||
return preparation
|
||||
})
|
||||
let window = makeWindow(root: controller)
|
||||
defer { close(window) }
|
||||
let list = try collection(in: controller)
|
||||
try await settle(window) { controller.viewModel.orders.count == 1 }
|
||||
let cell = try await card(at: 0, in: list, window: window)
|
||||
XCTAssertTrue(visibleTexts(in: cell).contains("执行中"))
|
||||
XCTAssertTrue(visibleTexts(in: cell).contains("素材上传中"))
|
||||
XCTAssertFalse(visibleTexts(in: cell).contains("上传完成"))
|
||||
XCTAssertFalse(visibleTexts(in: cell).contains("上传失败"))
|
||||
XCTAssertFalse(visibleTexts(in: cell).contains("继续查看任务"))
|
||||
let primary = try button(in: cell, id: "drone.orders.order.TEST-ORDER-UPLOADING.primary")
|
||||
XCTAssertEqual(primary.title(for: .normal), remaining > 0 ? "开始拍摄" : "交付成片")
|
||||
primary.sendActions(for: .touchUpInside)
|
||||
if remaining > 0 {
|
||||
try await settle(window) { controller.navigationController?.topViewController === preparation }
|
||||
XCTAssertEqual(openedPreparations, 1)
|
||||
} else {
|
||||
try await settle(window) { self.deliveryNavigation(from: controller) != nil }
|
||||
XCTAssertEqual(openedPreparations, 0)
|
||||
}
|
||||
XCTAssertEqual(openedFlights, 0)
|
||||
XCTAssertEqual(session.requests.count, 1)
|
||||
assertOnlyOrders(session)
|
||||
}
|
||||
}
|
||||
|
||||
/// 四个状态分别向服务端查询且从第一页加载,不在已加载页面上本地筛选。
|
||||
func testEachStatusFilterStartsAtPageOneAndKeepsServerResults() async throws {
|
||||
let payloads = try [envelope([record("ALL")], total: 1),
|
||||
@@ -315,6 +362,58 @@ final class DroneDockOrdersViewTests: XCTestCase {
|
||||
XCTAssertEqual(confirmations, 1)
|
||||
}
|
||||
|
||||
/// 复用卡片仅显示上传或失败提示;无提示时折叠整行,但保留独立的邀请确认和历史记录。
|
||||
func testReusedCardHidesMaterialNoticeWithoutRemovingConfirmation() throws {
|
||||
let card = DroneShootingOrderCardView(frame: CGRect(x: 0, y: 0, width: 358, height: 360))
|
||||
let cases: [(Int?, Int?, Bool, Bool, String?)] = [
|
||||
(0, 25, false, false, "素材上传中"),
|
||||
(0, nil, false, false, nil), (1, nil, false, false, nil),
|
||||
(nil, nil, false, false, nil), (99, nil, false, false, nil),
|
||||
(2, nil, false, false, "上传中"), (3, nil, false, false, "上传失败"),
|
||||
(0, nil, true, false, nil), (1, nil, true, true, nil),
|
||||
(nil, 25, false, false, "素材上传中"), (0, nil, false, false, nil)
|
||||
]
|
||||
for (materialStatus, activeStatus, fullQuota, confirmed, notice) in cases {
|
||||
var value = record("NOTICE", status: "processing")
|
||||
value["material_status"] = materialStatus
|
||||
value["active_task_status"] = activeStatus
|
||||
value["active_task_id"] = 21
|
||||
value["shot_count"] = fullQuota ? 5 : 1
|
||||
value["remaining_count"] = fullQuota ? 0 : 4
|
||||
value["can_confirm"] = fullQuota
|
||||
value["order_status"] = confirmed ? 30 : 20
|
||||
value["confirm_status"] = confirmed ? 2 : 0
|
||||
card.resetForReuse()
|
||||
card.apply(homeOrder: try JSONDecoder().decode(DroneDockHomeOrder.self,
|
||||
from: JSONSerialization.data(withJSONObject: value)))
|
||||
let size = card.systemLayoutSizeFitting(CGSize(width: 358, height: 0),
|
||||
withHorizontalFittingPriority: .required, verticalFittingPriority: .fittingSizeLevel)
|
||||
card.frame.size = size
|
||||
card.setNeedsLayout()
|
||||
card.layoutIfNeeded()
|
||||
let prefix = "drone.orders.order.TEST-ORDER-NOTICE"
|
||||
let material = try XCTUnwrap(find(in: card, id: prefix + ".materials") as? UIControl)
|
||||
let confirmation = try XCTUnwrap(find(in: card, id: prefix + ".confirmation") as? UIControl)
|
||||
let row = try XCTUnwrap(material.superview as? UIStackView)
|
||||
XCTAssertEqual(material.isHidden, notice == nil)
|
||||
XCTAssertEqual(confirmation.isHidden, !fullQuota)
|
||||
XCTAssertEqual(row.isHidden, notice == nil && !fullQuota)
|
||||
if let notice {
|
||||
XCTAssertTrue(visibleTexts(in: material).contains(notice))
|
||||
XCTAssertFalse(hidden(material))
|
||||
} else {
|
||||
XCTAssertTrue(visibleTexts(in: material).isEmpty)
|
||||
}
|
||||
if fullQuota {
|
||||
XCTAssertFalse(hidden(confirmation))
|
||||
XCTAssertTrue(confirmation.isEnabled)
|
||||
XCTAssertTrue(visibleTexts(in: confirmation).contains(confirmed ? "查看记录" : "邀请确认"))
|
||||
} else if notice == nil {
|
||||
XCTAssertEqual(row.bounds.height, 0, accuracy: 0.5, "没有摘要内容时不保留空白底栏")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// 拍摄已满但尚不允许确认时,不显示可操作的邀请按钮,也不绕过后端权限进入确认页。
|
||||
func testCompletedQuotaWithoutConfirmationPermissionCannotNavigate() async throws {
|
||||
var order = record("NO-CONFIRM", status: "processing")
|
||||
@@ -486,7 +585,9 @@ final class DroneDockOrdersViewTests: XCTestCase {
|
||||
/// 素材入口按选中订单进入真实页面,页面出现后才读取摘要与任务,不创建任务。
|
||||
func testMaterialsLoadsSelectedOrderDetailAndTasksAfterNavigation() async throws {
|
||||
var materialsSession: MockURLSession?
|
||||
let (controller, session) = makeController(responses: [try envelope([record("FIRST"), record("SECOND")], total: 2)],
|
||||
var second = record("SECOND")
|
||||
second["material_status"] = 2
|
||||
let (controller, session) = makeController(responses: [try envelope([record("FIRST"), second], total: 2)],
|
||||
materialsFactory: { order, context in
|
||||
let result = try! DroneDockMaterialsNavigationFixtures.controller(context: context, order: order)
|
||||
materialsSession = result.1
|
||||
@@ -499,6 +600,7 @@ final class DroneDockOrdersViewTests: XCTestCase {
|
||||
try await settle(window) { controller.viewModel.orders.count == 2 }
|
||||
let cell = try await card(at: 1, in: list, window: window)
|
||||
let control = try XCTUnwrap(find(in: cell, id: "drone.orders.order.TEST-ORDER-SECOND.materials") as? UIControl)
|
||||
XCTAssertFalse(hidden(control))
|
||||
control.sendActions(for: .touchUpInside)
|
||||
try await settle(window) {
|
||||
(controller.navigationController?.topViewController as? DroneDockMaterialsViewController)?.viewModel.total == 0
|
||||
|
||||
Reference in New Issue
Block a user