Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion BitMatchTests/ResultPresentationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ final class ResultPresentationTests: XCTestCase {

XCTAssertEqual(presentation.detail, "Copied to 1 destination and verified.")
XCTAssertFalse(presentation.detail.contains("2 destinations"))
XCTAssertEqual(
presentation.sourceGuidance,
"BitMatch read every file on every backup and checked it against the bytes it read from the card."
)
}

func testLiveRowsNameDestinationOnlyWhenBackupsAreMixed() {
Expand Down Expand Up @@ -169,7 +173,11 @@ final class ResultPresentationTests: XCTestCase {
)

XCTAssertEqual(presentation.title, "Transfer failed")
XCTAssertEqual(presentation.sourceGuidance, "Do not erase the card. Nothing here has been confirmed safe.")
XCTAssertEqual(
presentation.detail,
"The transfer did not finish safely. Review any recorded results below."
)
XCTAssertEqual(presentation.sourceGuidance, "Do not erase the card. The transfer did not finish safely.")
}

func testVisibleRowsCapsMoreThanOneThousandIssuesWithoutTrapping() {
Expand Down
28 changes: 28 additions & 0 deletions BitMatchTests/TransferOutcomePresentationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ struct TransferOutcomePresentationTests {
#expect(outcome.verdict.detail == "1 file · 100 bytes verified on A and B · SHA-256 · 1m 15s")
#expect(outcome.destinations.map(\.title) == ["A › Backup", "B › Backup"])
#expect(outcome.finishTitle == "The card is safe to erase")
#expect(outcome.visibleVerdictText.contains("checked it against the bytes it read from the card"))
}

@Test func longBackupNamesAreMiddleTruncatedInTheFinishSubtitle() {
Expand Down Expand Up @@ -444,6 +445,33 @@ struct TransferOutcomePresentationTests {
#expect(outcome.visibleVerdictText.localizedCaseInsensitiveContains("do not erase the card"))
}

@Test func failedFinishKeepsPartialVerifiedResultsVisibleAndCardUnsafe() {
let outcome = make(
state: .failed,
rows: [
row("A001.mov", .verified, backup: backupA),
row("A002.mov", .failed, backup: backupB)
],
hasErrors: true,
errorCount: 1
)

#expect(outcome.counts.verified == 1)
#expect(outcome.finishTitle == "Transfer failed — The card")
#expect(outcome.verdict.detail.contains("Review any recorded results below"))
#expect(outcome.visibleVerdictText.contains("Do not erase the card"))
#expect(!outcome.visibleVerdictText.contains("No files were confirmed"))
}

@Test func failedFinishWithNoRowsDoesNotInventFileResults() {
let outcome = make(state: .failed, rows: [], hasErrors: true, errorCount: 1)

#expect(outcome.counts.total == 0)
#expect(outcome.verdict.detail.contains("Review any recorded results below"))
#expect(!outcome.visibleVerdictText.contains("files verified"))
#expect(outcome.visibleVerdictText.contains("Do not erase the card"))
}

@Test func quickAndNeedsAttentionFinishBannersNameTheCardExactlyOnce() {
let name = "A_CAMERA_CARD_WITH_A_VERY_LONG_DISTINGUISHING_NAME_002"
let quick = TransferOutcomePresentation.make(
Expand Down
6 changes: 3 additions & 3 deletions Shared/Core/Models/CompletionVerdictPresentation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct CompletionVerdictPresentation: Equatable, Sendable {
title: safetyState.headline(cardName: cardName),
detail: "Copied to \(backups) and verified.",
symbol: safetyState.symbol,
sourceGuidance: "Every file on every destination was read back and matched the card."
sourceGuidance: "BitMatch read every file on every backup and checked it against the bytes it read from the card."
)
case .copiedNotVerified:
return Self(
Expand All @@ -53,9 +53,9 @@ struct CompletionVerdictPresentation: Equatable, Sendable {
case .failed:
return Self(
title: safetyState.headline(cardName: cardName),
detail: "No files were confirmed copied and verified.",
detail: "The transfer did not finish safely. Review any recorded results below.",
symbol: safetyState.symbol,
sourceGuidance: "Do not erase \(card). Nothing here has been confirmed safe."
sourceGuidance: "Do not erase \(card). The transfer did not finish safely."
)
case .waiting, .preparing, .copying, .verifying, .finishing, .interrupted:
preconditionFailure("A completion verdict must produce a finish state")
Expand Down
Loading