import XCTest @testable import suixinkan /// 两个正式入口共用真实交付控制器,只替换网络和上传边界。 @MainActor enum DroneDockDeliveryNavigationFixtures { /// 构造对应订单的两条可交付任务,进入页面不应触发上传或写接口。 static func controller(context: DroneDockHomeContext, order: DroneDockHomeOrder, taskID: Int?) throws -> (DroneDockDeliveryViewController, MockURLSession) { let number = order.orderNumber ?? order.orderID let detail: [String: Any] = ["order_number": number, "order_status": 20, "can_upload_film": true, "project_name": "测试交付套餐", "shoot_count": 5, "shot_count": 1, "remaining_count": 4, "spot": [["scenic_spot_id": 201, "scenic_spot_name": "测试点位一"], ["scenic_spot_id": 202, "scenic_spot_name": "测试点位二"]]] let tasks: [[String: Any]] = [1, 2].map { id in ["id": id, "task_id": id, "order_number": number, "scenic_spot_id": id == 1 ? 201 : 202, "scenic_spot_name": id == 1 ? "测试点位一" : "测试点位二", "flight_status": 30, "materials": [], "film": NSNull()] } let taskData: [String: Any] = ["order_number": number, "total": tasks.count, "list": tasks] let responses = try [detail, taskData].map { try JSONSerialization.data(withJSONObject: ["code": 100000, "msg": "success", "data": $0]) } let session = MockURLSession(responses: responses) let client = APIClient(environment: .testing, session: session, notificationCenter: NotificationCenter()) client.bindAuthTokenProvider { "delivery-navigation-test-token" } let model = DroneDockDeliveryViewModel(context: context, order: order, service: DroneDockDeliveryAPI(client: client), uploader: NavigationUploader(), initialTaskID: taskID, currentContext: { context }) return (DroneDockDeliveryViewController(viewModel: model), session) } /// 入口导航不得自行上传或触发任何交付写操作。 @MainActor private final class NavigationUploader: DroneDockFilmUploading { func upload(video: DroneDockDeliveryVideo, scenicID: Int, onProgress: @escaping @MainActor @Sendable (Int) -> Void) async throws -> String { XCTFail("进入交付页不应自动上传") throw CancellationError() } } }