合并 9.9.1 机巢工作台与拍摄交付流程 #1
@@ -153,7 +153,7 @@ final class DroneDockDeliveryViewController: BaseViewController {
|
|||||||
if case .point(let id) = item {
|
if case .point(let id) = item {
|
||||||
let cell = list.dequeueReusableCell(withReuseIdentifier: "point", for: path) as! DroneMaterialFilterCell
|
let cell = list.dequeueReusableCell(withReuseIdentifier: "point", for: path) as! DroneMaterialFilterCell
|
||||||
let title = self.viewModel.spots.first { $0.id == id }.map { Self.text($0.name, fallback: "点位 \(id)") } ?? "点位 \(id)"
|
let title = self.viewModel.spots.first { $0.id == id }.map { Self.text($0.name, fallback: "点位 \(id)") } ?? "点位 \(id)"
|
||||||
cell.apply(title: title, id: String(id), selected: self.viewModel.selectedSpotID == id, locked: self.locked)
|
cell.apply(title: title, id: String(id), selected: self.viewModel.selectedSpotID == id, locked: self.locked, wrapsTitle: true)
|
||||||
cell.accessibilityIdentifier = "drone.delivery.point.\(id)"
|
cell.accessibilityIdentifier = "drone.delivery.point.\(id)"
|
||||||
return cell
|
return cell
|
||||||
}
|
}
|
||||||
@@ -207,11 +207,30 @@ final class DroneDockDeliveryViewController: BaseViewController {
|
|||||||
private var locked: Bool { isRefreshing || isPicking || isStartingSubmission || viewModel.isLoading || viewModel.isSubmitting }
|
private var locked: Bool { isRefreshing || isPicking || isStartingSubmission || viewModel.isLoading || viewModel.isSubmitting }
|
||||||
|
|
||||||
private func makeLayout() -> UICollectionViewLayout {
|
private func makeLayout() -> UICollectionViewLayout {
|
||||||
UICollectionViewCompositionalLayout { [weak self] index, _ in
|
UICollectionViewCompositionalLayout { [weak self] index, environment in
|
||||||
guard let self, let source = self.dataSource else { return nil }
|
guard let self, let source = self.dataSource else { return nil }
|
||||||
let sections = source.snapshot().sectionIdentifiers
|
let sections = source.snapshot().sectionIdentifiers
|
||||||
guard sections.indices.contains(index) else { return nil }
|
guard sections.indices.contains(index) else { return nil }
|
||||||
let points = sections[index] == .points
|
let points = sections[index] == .points
|
||||||
|
if points, !self.viewModel.spots.isEmpty {
|
||||||
|
let maximumWidth = min(200, max(1, environment.container.effectiveContentSize.width - 32))
|
||||||
|
let sizes = self.viewModel.spots.map {
|
||||||
|
DroneMaterialFilterCell.wrappedSize(title: Self.text($0.name, fallback: "点位 \($0.id)"), maximumWidth: maximumWidth)
|
||||||
|
}
|
||||||
|
let width = sizes.reduce(0) { $0 + $1.width } + CGFloat(sizes.count - 1) * 10
|
||||||
|
let height = sizes.map(\.height).max() ?? 40
|
||||||
|
let group = NSCollectionLayoutGroup.custom(layoutSize: .init(widthDimension: .absolute(width), heightDimension: .absolute(height))) { _ in
|
||||||
|
var x: CGFloat = 0
|
||||||
|
return sizes.map { size in
|
||||||
|
defer { x += size.width + 10 }
|
||||||
|
return NSCollectionLayoutGroupCustomItem(frame: CGRect(x: x, y: 0, width: size.width, height: size.height))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let section = NSCollectionLayoutSection(group: group)
|
||||||
|
section.contentInsets = .init(top: 0, leading: 16, bottom: 12, trailing: 16)
|
||||||
|
section.orthogonalScrollingBehavior = .continuous
|
||||||
|
return section
|
||||||
|
}
|
||||||
let size = NSCollectionLayoutSize(widthDimension: points ? .estimated(112) : .fractionalWidth(1), heightDimension: points ? .absolute(40) : .estimated(100))
|
let size = NSCollectionLayoutSize(widthDimension: points ? .estimated(112) : .fractionalWidth(1), heightDimension: points ? .absolute(40) : .estimated(100))
|
||||||
let item = NSCollectionLayoutItem(layoutSize: .init(widthDimension: .fractionalWidth(1), heightDimension: points ? .fractionalHeight(1) : .estimated(100)))
|
let item = NSCollectionLayoutItem(layoutSize: .init(widthDimension: .fractionalWidth(1), heightDimension: points ? .fractionalHeight(1) : .estimated(100)))
|
||||||
let group = NSCollectionLayoutGroup.vertical(layoutSize: size, subitems: [item])
|
let group = NSCollectionLayoutGroup.vertical(layoutSize: size, subitems: [item])
|
||||||
@@ -242,6 +261,7 @@ final class DroneDockDeliveryViewController: BaseViewController {
|
|||||||
snapshot.appendItems([.state], toSection: .state)
|
snapshot.appendItems([.state], toSection: .state)
|
||||||
let previous = Set(dataSource.snapshot().itemIdentifiers)
|
let previous = Set(dataSource.snapshot().itemIdentifiers)
|
||||||
snapshot.reconfigureItems(snapshot.itemIdentifiers.filter { previous.contains($0) })
|
snapshot.reconfigureItems(snapshot.itemIdentifiers.filter { previous.contains($0) })
|
||||||
|
collectionView.collectionViewLayout.invalidateLayout()
|
||||||
dataSource.apply(snapshot, animatingDifferences: animated)
|
dataSource.apply(snapshot, animatingDifferences: animated)
|
||||||
updateFooter()
|
updateFooter()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,15 +38,14 @@ final class DroneDockPaymentViewController: BaseViewController {
|
|||||||
private let placeholderDetail = DroneDockStyle.label(size: 12, color: DroneDockStyle.secondary)
|
private let placeholderDetail = DroneDockStyle.label(size: 12, color: DroneDockStyle.secondary)
|
||||||
private let retryButton = UIButton(type: .system)
|
private let retryButton = UIButton(type: .system)
|
||||||
private let reloadImageButton = UIButton(type: .system)
|
private let reloadImageButton = UIButton(type: .system)
|
||||||
private let regenerateButton = UIButton(type: .system)
|
|
||||||
private let retryProjectsButton = UIButton(type: .system)
|
private let retryProjectsButton = UIButton(type: .system)
|
||||||
private let spinner = UIActivityIndicatorView(style: .medium)
|
private let spinner = UIActivityIndicatorView(style: .medium)
|
||||||
private let paymentHint = DroneDockStyle.label("请游客使用微信扫码,到账后核对收款记录\n付款码有效 7 天,失效时请重新生成", size: 11, color: DroneDockStyle.secondary)
|
private let paymentHint = DroneDockStyle.label("请游客使用微信扫码,到账后核对收款记录\n付款码有效 7 天,失效时请重新生成", size: 11, color: DroneDockStyle.secondary)
|
||||||
private let setAmountButton = UIButton(type: .system)
|
private let setAmountButton = UIButton(type: .system)
|
||||||
private let saveButton = UIButton(type: .system)
|
private let saveButton = UIButton(type: .system)
|
||||||
private let checkReceiptsButton = UIButton(type: .system)
|
|
||||||
private let recordsButton = UIButton(type: .system)
|
private let recordsButton = UIButton(type: .system)
|
||||||
private let staffValue = DroneDockStyle.label(size: 13)
|
private let staffValue = DroneDockStyle.label(size: 13)
|
||||||
|
private let merchantValue = DroneDockStyle.label(size: 13)
|
||||||
private let scenicValue = DroneDockStyle.label(size: 13)
|
private let scenicValue = DroneDockStyle.label(size: 13)
|
||||||
private let voiceSwitch = UISwitch()
|
private let voiceSwitch = UISwitch()
|
||||||
|
|
||||||
@@ -246,11 +245,6 @@ final class DroneDockPaymentViewController: BaseViewController {
|
|||||||
paymentHint.numberOfLines = 0
|
paymentHint.numberOfLines = 0
|
||||||
paymentHint.textAlignment = .center
|
paymentHint.textAlignment = .center
|
||||||
stack.addArrangedSubview(paymentHint)
|
stack.addArrangedSubview(paymentHint)
|
||||||
configureButton(checkReceiptsButton, title: "刷新收款记录", identifier: "drone.payment.refreshReceipts", action: #selector(checkReceipts))
|
|
||||||
configureButton(regenerateButton, title: "重新生成", identifier: "drone.payment.regenerateCode", action: #selector(regenerateCode))
|
|
||||||
let codeActions = UIStackView(arrangedSubviews: [checkReceiptsButton, regenerateButton])
|
|
||||||
codeActions.distribution = .fillEqually
|
|
||||||
stack.addArrangedSubview(codeActions)
|
|
||||||
configureButton(setAmountButton, title: "设置金额", identifier: "drone.payment.setAmount", action: #selector(setAmountTapped))
|
configureButton(setAmountButton, title: "设置金额", identifier: "drone.payment.setAmount", action: #selector(setAmountTapped))
|
||||||
configureButton(saveButton, title: "保存二维码", identifier: "drone.payment.saveQR", action: #selector(saveTapped))
|
configureButton(saveButton, title: "保存二维码", identifier: "drone.payment.saveQR", action: #selector(saveTapped))
|
||||||
let actions = UIStackView(arrangedSubviews: [setAmountButton, saveButton])
|
let actions = UIStackView(arrangedSubviews: [setAmountButton, saveButton])
|
||||||
@@ -266,7 +260,9 @@ final class DroneDockPaymentViewController: BaseViewController {
|
|||||||
stack.spacing = 14
|
stack.spacing = 14
|
||||||
stack.addArrangedSubview(infoRow("景区名称", value: scenicValue))
|
stack.addArrangedSubview(infoRow("景区名称", value: scenicValue))
|
||||||
stack.addArrangedSubview(line())
|
stack.addArrangedSubview(line())
|
||||||
stack.addArrangedSubview(infoRow("收款方", value: DroneDockStyle.label("—", size: 13)))
|
merchantValue.accessibilityIdentifier = "drone.payment.merchant"
|
||||||
|
staffValue.accessibilityIdentifier = "drone.payment.staff"
|
||||||
|
stack.addArrangedSubview(infoRow("收款方", value: merchantValue))
|
||||||
stack.addArrangedSubview(line())
|
stack.addArrangedSubview(line())
|
||||||
stack.addArrangedSubview(infoRow("员工 ID", value: staffValue))
|
stack.addArrangedSubview(infoRow("员工 ID", value: staffValue))
|
||||||
return card(stack, insets: 16)
|
return card(stack, insets: 16)
|
||||||
@@ -330,7 +326,8 @@ final class DroneDockPaymentViewController: BaseViewController {
|
|||||||
projectButton.isEnabled = !isLoadingProjectRequest && !viewModel.isLoadingProjects && !isUpdatingCode
|
projectButton.isEnabled = !isLoadingProjectRequest && !viewModel.isLoadingProjects && !isUpdatingCode
|
||||||
amountLabel.isHidden = code == nil
|
amountLabel.isHidden = code == nil
|
||||||
amountLabel.text = code.map { "本次收款 ¥\(Self.money($0.price))" }
|
amountLabel.text = code.map { "本次收款 ¥\(Self.money($0.price))" }
|
||||||
staffValue.text = code.map { String($0.storeUserID) } ?? "—"
|
merchantValue.text = PaymentMerchantInfo.defaultInfo.company
|
||||||
|
staffValue.text = hasCurrentContext ? DroneDockHomeMetric.usableText(viewModel.context.userID) ?? "—" : "—"
|
||||||
let showingProgress = busy || isLoadingImage
|
let showingProgress = busy || isLoadingImage
|
||||||
if showingProgress { spinner.startAnimating() } else { spinner.stopAnimating() }
|
if showingProgress { spinner.startAnimating() } else { spinner.stopAnimating() }
|
||||||
spinner.isHidden = !showingProgress
|
spinner.isHidden = !showingProgress
|
||||||
@@ -365,9 +362,6 @@ final class DroneDockPaymentViewController: BaseViewController {
|
|||||||
qrImageView.isHidden = !hasImage
|
qrImageView.isHidden = !hasImage
|
||||||
placeholder.isHidden = hasImage
|
placeholder.isHidden = hasImage
|
||||||
paymentHint.isHidden = code == nil
|
paymentHint.isHidden = code == nil
|
||||||
checkReceiptsButton.isHidden = code == nil
|
|
||||||
regenerateButton.isHidden = code == nil
|
|
||||||
regenerateButton.isEnabled = code != nil
|
|
||||||
setAmountButton.isEnabled = code != nil
|
setAmountButton.isEnabled = code != nil
|
||||||
saveButton.isEnabled = hasImage
|
saveButton.isEnabled = hasImage
|
||||||
setAmountButton.alpha = code != nil ? 1 : 0.4
|
setAmountButton.alpha = code != nil ? 1 : 0.4
|
||||||
@@ -506,11 +500,6 @@ final class DroneDockPaymentViewController: BaseViewController {
|
|||||||
applyState()
|
applyState()
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc private func regenerateCode() {
|
|
||||||
guard let code = viewModel.payCode, !isUpdatingCode, !isLoadingProjectRequest else { return }
|
|
||||||
generateCode(projectID: code.projectID, price: Self.money(code.price))
|
|
||||||
}
|
|
||||||
|
|
||||||
@objc private func setAmountTapped() {
|
@objc private func setAmountTapped() {
|
||||||
guard let code = viewModel.payCode, !isUpdatingCode else { return }
|
guard let code = viewModel.payCode, !isUpdatingCode else { return }
|
||||||
guard viewModel.context.hasSameIdentity(as: currentContext()) else {
|
guard viewModel.context.hasSameIdentity(as: currentContext()) else {
|
||||||
@@ -557,7 +546,6 @@ final class DroneDockPaymentViewController: BaseViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@objc private func recordsTapped() { navigationController?.pushViewController(makeReceiptsController(), animated: true) }
|
@objc private func recordsTapped() { navigationController?.pushViewController(makeReceiptsController(), animated: true) }
|
||||||
@objc private func checkReceipts() { navigationController?.pushViewController(makeReceiptsController(projectID: viewModel.payCode?.projectID), animated: true) }
|
|
||||||
@objc private func voiceChanged() { AppStore.shared.payment.isOpenReceiveVoice = voiceSwitch.isOn }
|
@objc private func voiceChanged() { AppStore.shared.payment.isOpenReceiveVoice = voiceSwitch.isOn }
|
||||||
@objc private func offlineTapped() { navigationController?.pushViewController(OfflineCollectionRegistrationViewController(), animated: true) }
|
@objc private func offlineTapped() { navigationController?.pushViewController(OfflineCollectionRegistrationViewController(), animated: true) }
|
||||||
|
|
||||||
|
|||||||
@@ -485,7 +485,16 @@ extension DroneDockRemotePreparationViewController: UICollectionViewDelegate {
|
|||||||
viewModel.createdTask == nil, !viewModel.taskCreationOutcomeUnknown,
|
viewModel.createdTask == nil, !viewModel.taskCreationOutcomeUnknown,
|
||||||
let item = dataSource.itemIdentifier(for: indexPath) else { return }
|
let item = dataSource.itemIdentifier(for: indexPath) else { return }
|
||||||
switch item {
|
switch item {
|
||||||
case .point(let id): viewModel.selectSpot(id: id)
|
case .point(let id):
|
||||||
|
viewModel.selectSpot(id: id)
|
||||||
|
applySnapshot(animated: true) { [weak self] in
|
||||||
|
guard let self, self.viewModel.selectedSpotID == id,
|
||||||
|
let path = self.dataSource.indexPath(for: .point(id)) else { return }
|
||||||
|
let pointsWidth = CGFloat(self.viewModel.spots.count) * 200 + CGFloat(max(0, self.viewModel.spots.count - 1)) * 8 + 32
|
||||||
|
guard pointsWidth > collectionView.bounds.width else { return }
|
||||||
|
collectionView.scrollToItem(at: path, at: .centeredHorizontally, animated: true)
|
||||||
|
}
|
||||||
|
return
|
||||||
case .route(let id): viewModel.selectRoute(id: id)
|
case .route(let id): viewModel.selectRoute(id: id)
|
||||||
default: return
|
default: return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,7 +69,9 @@ final class DroneMaterialFilterCell: UICollectionViewCell {
|
|||||||
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
|
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
|
||||||
|
|
||||||
/// 映射筛选名称、选中态与交互许可。
|
/// 映射筛选名称、选中态与交互许可。
|
||||||
func apply(title: String, id: String?, selected: Bool, locked: Bool) {
|
func apply(title: String, id: String?, selected: Bool, locked: Bool, wrapsTitle: Bool = false) {
|
||||||
|
titleLabel.numberOfLines = wrapsTitle ? 0 : 1
|
||||||
|
titleLabel.lineBreakMode = wrapsTitle ? .byWordWrapping : .byTruncatingTail
|
||||||
titleLabel.text = title
|
titleLabel.text = title
|
||||||
titleLabel.textColor = selected ? DroneDockStyle.primary : UIColor(hex: 0x677183)
|
titleLabel.textColor = selected ? DroneDockStyle.primary : UIColor(hex: 0x677183)
|
||||||
contentView.backgroundColor = selected ? DroneDockStyle.primary.withAlphaComponent(0.09) : .white
|
contentView.backgroundColor = selected ? DroneDockStyle.primary.withAlphaComponent(0.09) : .white
|
||||||
@@ -82,6 +84,15 @@ final class DroneMaterialFilterCell: UICollectionViewCell {
|
|||||||
if locked { traits.insert(.notEnabled) }
|
if locked { traits.insert(.notEnabled) }
|
||||||
accessibilityTraits = traits
|
accessibilityTraits = traits
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 云端交付点位在限定宽度内完整换行,短名称保留紧凑卡片。
|
||||||
|
static func wrappedSize(title: String, maximumWidth: CGFloat) -> CGSize {
|
||||||
|
let font = UIFont.systemFont(ofSize: 13, weight: .medium)
|
||||||
|
let width = min(maximumWidth, ceil((title as NSString).size(withAttributes: [.font: font]).width) + 10)
|
||||||
|
let bounds = (title as NSString).boundingRect(with: CGSize(width: max(1, width - 10), height: .greatestFiniteMagnitude),
|
||||||
|
options: [.usesLineFragmentOrigin, .usesFontLeading], attributes: [.font: font], context: nil)
|
||||||
|
return CGSize(width: width, height: max(40, ceil(bounds.height) + 10))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 点位限定入口的只读提示,不将当前任务点位伪装成可切换筛选。
|
/// 点位限定入口的只读提示,不将当前任务点位伪装成可切换筛选。
|
||||||
|
|||||||
@@ -5,6 +5,28 @@ import XCTest
|
|||||||
/// 使用隔离窗口和网络、上传替身验证共用云端交付页。
|
/// 使用隔离窗口和网络、上传替身验证共用云端交付页。
|
||||||
@MainActor
|
@MainActor
|
||||||
final class DroneDockDeliveryViewTests: XCTestCase {
|
final class DroneDockDeliveryViewTests: XCTestCase {
|
||||||
|
/// 云端点位最多 200 点宽,长名称完整换行且仍可选择到对应任务。
|
||||||
|
func testLongPointNamesWrapWithinMaximumCardWidth() async throws {
|
||||||
|
let fixture = try DeliveryUIFixture()
|
||||||
|
let name = "测试景区东南观景平台通往山顶步道的全景航拍游客打卡点"
|
||||||
|
fixture.service.pointNames[0] = name
|
||||||
|
let controller = fixture.controller()
|
||||||
|
let window = show(controller)
|
||||||
|
defer { close(window) }
|
||||||
|
try await settle(window) { controller.viewModel.detail != nil && !controller.viewModel.isLoading }
|
||||||
|
let list = try collection(controller)
|
||||||
|
let point = try XCTUnwrap(find(controller.view, "drone.delivery.point.201") as? UICollectionViewCell)
|
||||||
|
let label = try XCTUnwrap(point.contentView.subviews.first as? UILabel)
|
||||||
|
XCTAssertEqual(label.text, name)
|
||||||
|
XCTAssertEqual(label.numberOfLines, 0)
|
||||||
|
XCTAssertLessThanOrEqual(point.bounds.width, 200)
|
||||||
|
XCTAssertGreaterThan(point.bounds.height, 40)
|
||||||
|
XCTAssertGreaterThanOrEqual(label.bounds.height + 1,
|
||||||
|
label.sizeThatFits(CGSize(width: label.bounds.width, height: .greatestFiniteMagnitude)).height)
|
||||||
|
try select("drone.delivery.point.201", list: list)
|
||||||
|
try await settle(window) { controller.viewModel.selectedSpotID == 201 }
|
||||||
|
capture(window, "云端交付-长点位限定宽度完整换行")
|
||||||
|
}
|
||||||
private weak var previousKeyWindow: UIWindow?
|
private weak var previousKeyWindow: UIWindow?
|
||||||
|
|
||||||
/// 弹窗关闭与普通返回共享处理中确认,取消提示不会结束正在进行的上传。
|
/// 弹窗关闭与普通返回共享处理中确认,取消提示不会结束正在进行的上传。
|
||||||
@@ -347,6 +369,7 @@ private final class DeliveryUIFixture {
|
|||||||
/// 可暂停保存以验证 OSS 成功和业务交付成功的展示边界。
|
/// 可暂停保存以验证 OSS 成功和业务交付成功的展示边界。
|
||||||
@MainActor
|
@MainActor
|
||||||
private final class DeliveryUIService: DroneDockDeliveryServing {
|
private final class DeliveryUIService: DroneDockDeliveryServing {
|
||||||
|
var pointNames = ["测试点位一", "测试点位二"]
|
||||||
var failDetail = false
|
var failDetail = false
|
||||||
var failSaveCount = 0
|
var failSaveCount = 0
|
||||||
var holdSave = false
|
var holdSave = false
|
||||||
@@ -369,7 +392,7 @@ private final class DeliveryUIService: DroneDockDeliveryServing {
|
|||||||
if failDetail { throw URLError(.notConnectedToInternet) }
|
if failDetail { throw URLError(.notConnectedToInternet) }
|
||||||
return try deliveryDecode(["order_number": "TEST-DELIVERY-UI", "user_phone": "130****0001", "project_name": "测试航拍套餐",
|
return try deliveryDecode(["order_number": "TEST-DELIVERY-UI", "user_phone": "130****0001", "project_name": "测试航拍套餐",
|
||||||
"order_status": 20, "can_upload_film": allowed, "shoot_count": 5, "shot_count": 2, "remaining_count": 3,
|
"order_status": 20, "can_upload_film": allowed, "shoot_count": 5, "shot_count": 2, "remaining_count": 3,
|
||||||
"spot": [["scenic_spot_id": 201, "scenic_spot_name": "测试点位一"], ["scenic_spot_id": 202, "scenic_spot_name": "测试点位二"]]])
|
"spot": [["scenic_spot_id": 201, "scenic_spot_name": pointNames[0]], ["scenic_spot_id": 202, "scenic_spot_name": pointNames[1]]]])
|
||||||
}
|
}
|
||||||
func tasks(scenicID: Int, orderNumber: String, spotID: Int?) async throws -> DroneDockMaterialTasks {
|
func tasks(scenicID: Int, orderNumber: String, spotID: Int?) async throws -> DroneDockMaterialTasks {
|
||||||
try deliveryDecode(["order_number": "TEST-DELIVERY-UI", "total": records.count, "list": records])
|
try deliveryDecode(["order_number": "TEST-DELIVERY-UI", "total": records.count, "list": records])
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ final class DroneDockPaymentViewTests: XCTestCase {
|
|||||||
XCTAssertFalse(try button("drone.payment.setAmount", in: controller.view).isEnabled)
|
XCTAssertFalse(try button("drone.payment.setAmount", in: controller.view).isEnabled)
|
||||||
XCTAssertFalse(try button("drone.payment.saveQR", in: controller.view).isEnabled)
|
XCTAssertFalse(try button("drone.payment.saveQR", in: controller.view).isEnabled)
|
||||||
XCTAssertTrue(try button("drone.payment.projectPicker", in: controller.view).isEnabled)
|
XCTAssertTrue(try button("drone.payment.projectPicker", in: controller.view).isEnabled)
|
||||||
|
XCTAssertEqual((find(in: controller.view, identifier: "drone.payment.merchant") as? UILabel)?.text, PaymentMerchantInfo.defaultInfo.company)
|
||||||
|
XCTAssertEqual((find(in: controller.view, identifier: "drone.payment.staff") as? UILabel)?.text, DroneDockPaymentViewFixtures.context.userID)
|
||||||
capture(window, named: "套餐收款-未选套餐无二维码")
|
capture(window, named: "套餐收款-未选套餐无二维码")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,7 +124,7 @@ final class DroneDockPaymentViewTests: XCTestCase {
|
|||||||
XCTAssertTrue(try button("drone.payment.saveQR", in: controller.view).isEnabled)
|
XCTAssertTrue(try button("drone.payment.saveQR", in: controller.view).isEnabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 收款记录与刷新入口都读取服务端记录,不把二维码生成当作游客付款成功。
|
/// 保留独立收款记录入口,正常收款页只展示设置金额与保存二维码操作。
|
||||||
func testReceiptsAndRefreshEntriesUseRealReceiptPageWithoutGeneratingAnotherCode() async throws {
|
func testReceiptsAndRefreshEntriesUseRealReceiptPageWithoutGeneratingAnotherCode() async throws {
|
||||||
let (controller, service) = try makeController()
|
let (controller, service) = try makeController()
|
||||||
let window = makeWindow(root: controller)
|
let window = makeWindow(root: controller)
|
||||||
@@ -146,12 +148,9 @@ final class DroneDockPaymentViewTests: XCTestCase {
|
|||||||
|
|
||||||
navigation.popViewController(animated: false)
|
navigation.popViewController(animated: false)
|
||||||
try await settle(window: window) { navigation.topViewController === controller }
|
try await settle(window: window) { navigation.topViewController === controller }
|
||||||
try button("drone.payment.refreshReceipts", in: controller.view).sendActions(for: .touchUpInside)
|
XCTAssertNil(find(in: controller.view, identifier: "drone.payment.refreshReceipts"))
|
||||||
try await settle(window: window) {
|
XCTAssertNil(find(in: controller.view, identifier: "drone.payment.regenerateCode"))
|
||||||
navigation.topViewController !== controller && service.receiptCalls.count == 2
|
XCTAssertEqual(service.receiptCalls.count, 1)
|
||||||
}
|
|
||||||
XCTAssertEqual(navigation.topViewController?.title, "收款记录")
|
|
||||||
XCTAssertEqual(service.receiptCalls.last?.projectID, 8012)
|
|
||||||
XCTAssertEqual(service.payCodeCalls.count, 1)
|
XCTAssertEqual(service.payCodeCalls.count, 1)
|
||||||
XCTAssertEqual(controller.viewModel.payCode?.payURL, originalURL)
|
XCTAssertEqual(controller.viewModel.payCode?.payURL, originalURL)
|
||||||
}
|
}
|
||||||
@@ -272,8 +271,8 @@ final class DroneDockPaymentViewTests: XCTestCase {
|
|||||||
XCTAssertEqual(try imageView("drone.payment.qr", in: controller.view).image?.pngData(), images.defaultImage.pngData())
|
XCTAssertEqual(try imageView("drone.payment.qr", in: controller.view).image?.pngData(), images.defaultImage.pngData())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 已显示的小程序码也可主动更新;更新沿用确认后的套餐与自定义报价。
|
/// 自定义报价沿用原设置金额入口,并且员工信息不随套餐回包变化。
|
||||||
func testReadyCodeCanRegenerateWithoutLosingConfirmedCustomPrice() async throws {
|
func testReadyCodeUsesAmountActionAndKeepsLoginStaffIdentity() async throws {
|
||||||
let images = DroneDockPaymentImageLoaderStub()
|
let images = DroneDockPaymentImageLoaderStub()
|
||||||
let (controller, service) = try makeController(imageLoader: images)
|
let (controller, service) = try makeController(imageLoader: images)
|
||||||
let window = makeWindow(root: controller)
|
let window = makeWindow(root: controller)
|
||||||
@@ -282,11 +281,9 @@ final class DroneDockPaymentViewTests: XCTestCase {
|
|||||||
try await confirmProject(8012, controller: controller, window: window)
|
try await confirmProject(8012, controller: controller, window: window)
|
||||||
try await setPrice("88.50", controller: controller, window: window)
|
try await setPrice("88.50", controller: controller, window: window)
|
||||||
let previousURL = controller.viewModel.payCode?.payURL
|
let previousURL = controller.viewModel.payCode?.payURL
|
||||||
let regenerate = try button("drone.payment.regenerateCode", in: controller.view)
|
XCTAssertNil(find(in: controller.view, identifier: "drone.payment.regenerateCode"))
|
||||||
XCTAssertFalse(isHiddenByAncestor(regenerate))
|
XCTAssertNil(find(in: controller.view, identifier: "drone.payment.refreshReceipts"))
|
||||||
XCTAssertTrue(regenerate.isEnabled)
|
try await setPrice("88.50", controller: controller, window: window)
|
||||||
|
|
||||||
regenerate.sendActions(for: .touchUpInside)
|
|
||||||
try await settle(window: window) { service.payCodeCalls.count == 3 && !controller.viewModel.isGenerating }
|
try await settle(window: window) { service.payCodeCalls.count == 3 && !controller.viewModel.isGenerating }
|
||||||
|
|
||||||
XCTAssertEqual(service.payCodeCalls.last?.projectID, 8012)
|
XCTAssertEqual(service.payCodeCalls.last?.projectID, 8012)
|
||||||
@@ -296,6 +293,7 @@ final class DroneDockPaymentViewTests: XCTestCase {
|
|||||||
XCTAssertNotEqual(controller.viewModel.payCode?.payURL, previousURL)
|
XCTAssertNotEqual(controller.viewModel.payCode?.payURL, previousURL)
|
||||||
XCTAssertEqual(images.requests.count, 3)
|
XCTAssertEqual(images.requests.count, 3)
|
||||||
XCTAssertTrue(try button("drone.payment.saveQR", in: controller.view).isEnabled)
|
XCTAssertTrue(try button("drone.payment.saveQR", in: controller.view).isEnabled)
|
||||||
|
XCTAssertEqual((find(in: controller.view, identifier: "drone.payment.staff") as? UILabel)?.text, DroneDockPaymentViewFixtures.context.userID)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 新码会使旧图片回调失效;即使服务端复用图片 URL,也必须按请求代次区分。
|
/// 新码会使旧图片回调失效;即使服务端复用图片 URL,也必须按请求代次区分。
|
||||||
@@ -310,7 +308,7 @@ final class DroneDockPaymentViewTests: XCTestCase {
|
|||||||
try await waitForProjects(controller, service: service, window: window)
|
try await waitForProjects(controller, service: service, window: window)
|
||||||
try await confirmProject(8012, controller: controller, window: window)
|
try await confirmProject(8012, controller: controller, window: window)
|
||||||
try await settle(window: window) { images.requests.count == 1 }
|
try await settle(window: window) { images.requests.count == 1 }
|
||||||
try button("drone.payment.regenerateCode", in: controller.view).sendActions(for: .touchUpInside)
|
try await setPrice("88.50", controller: controller, window: window)
|
||||||
try await settle(window: window) { images.requests.count == 2 }
|
try await settle(window: window) { images.requests.count == 2 }
|
||||||
XCTAssertEqual(service.payCodeCalls.count, 2)
|
XCTAssertEqual(service.payCodeCalls.count, 2)
|
||||||
XCTAssertTrue(images.requests[1].forceRefresh, "新报价即使复用图片地址,也不能使用上一付款码的图片缓存")
|
XCTAssertTrue(images.requests[1].forceRefresh, "新报价即使复用图片地址,也不能使用上一付款码的图片缓存")
|
||||||
|
|||||||
@@ -5,6 +5,35 @@ import XCTest
|
|||||||
/// 验证准备页购买快照、独立设备状态、点位航线选择与错误恢复。
|
/// 验证准备页购买快照、独立设备状态、点位航线选择与错误恢复。
|
||||||
@MainActor
|
@MainActor
|
||||||
final class DroneDockPreparationViewTests: XCTestCase {
|
final class DroneDockPreparationViewTests: XCTestCase {
|
||||||
|
/// 点位列表超出页面时将所选中间卡片居中,单点位则保留原位置。
|
||||||
|
func testPointSelectionCentersOnlyWhenHorizontalContentOverflows() async throws {
|
||||||
|
for count in [1, 4] {
|
||||||
|
let spots = (1...count).map { index in
|
||||||
|
var point = DroneDockPreparationViewFixtures.purchasedSpots()[0]
|
||||||
|
point["scenic_spot_id"] = 100 + index
|
||||||
|
point["scenic_spot_name"] = "测试点位\(index)"
|
||||||
|
return point
|
||||||
|
}
|
||||||
|
let (controller, _) = try DroneDockPreparationViewFixtures.controller(
|
||||||
|
context: DroneDockPreparationViewFixtures.context(), order: DroneDockPreparationViewFixtures.order(),
|
||||||
|
responses: [DroneDockPreparationViewFixtures.projectEnvelope(spots: spots)])
|
||||||
|
let window = makeWindow(root: controller)
|
||||||
|
defer { close(window) }
|
||||||
|
try await settle(window) { controller.viewModel.spots.count == count }
|
||||||
|
let list = try collection(in: controller)
|
||||||
|
let path = IndexPath(item: count == 1 ? 0 : 1, section: 1)
|
||||||
|
let originalOffset = list.contentOffset
|
||||||
|
try select(path, in: list)
|
||||||
|
try await settle(window) {
|
||||||
|
guard let cell = list.cellForItem(at: path) else { return false }
|
||||||
|
let frame = cell.convert(cell.bounds, to: list)
|
||||||
|
return abs(frame.midX - (count == 1 ? 116 : list.bounds.midX)) < 2
|
||||||
|
}
|
||||||
|
XCTAssertEqual(list.contentOffset.y, originalOffset.y, accuracy: 1)
|
||||||
|
XCTAssertEqual(controller.viewModel.selectedSpotID, count == 1 ? 101 : 102)
|
||||||
|
capture(window, name: count == 1 ? "准备页-单点位保持位置" : "准备页-选中点位居中")
|
||||||
|
}
|
||||||
|
}
|
||||||
/// 长点位名称完整换行,卡片与航线标题均按实际文本增高。
|
/// 长点位名称完整换行,卡片与航线标题均按实际文本增高。
|
||||||
func testLongPointNameFitsCardAndRouteHeading() async throws {
|
func testLongPointNameFitsCardAndRouteHeading() async throws {
|
||||||
let name = "测试景区东南观景平台通往山顶步道的全景航拍打卡点"
|
let name = "测试景区东南观景平台通往山顶步道的全景航拍打卡点"
|
||||||
|
|||||||
Reference in New Issue
Block a user