From 4ac71915fb6683dd3b80867f63c228c3102c1c67 Mon Sep 17 00:00:00 2001 From: mercury Date: Thu, 22 Oct 2026 12:20:31 +0000 Subject: [PATCH] fix(portability): report only the upgrade in the import notice (#35) The import screen already states what it restored, and the migration notice restated the same count, so the on-screen notice read as two stacked sentences saying one thing. The notice now only describes the upgrade, and a unit test fails if it starts restating the restored count again. --- src/domain.js | 4 +++- tests/portability.test.js | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/domain.js b/src/domain.js index fac7817..13aa75a 100644 --- a/src/domain.js +++ b/src/domain.js @@ -240,8 +240,10 @@ export function importLedgerBackup(text) { const rawContributions = Array.isArray(parsed.contributions) ? parsed.contributions : []; const contributions = rawContributions.map(sanitizeContribution).filter(Boolean); const migrated = fromVersion < LEDGER_EXPORT_VERSION; + // The caller already says what it restored, so this notice only reports the upgrade. Restating the + // restored count here made the on-screen notice read as two stacked sentences saying one thing. const notices = migrated - ? [`Restored ${entries.length} ${entries.length === 1 ? 'log' : 'logs'} from a version ${fromVersion} backup and upgraded it to version ${LEDGER_EXPORT_VERSION}.`] + ? [`Upgraded from version ${fromVersion} to version ${LEDGER_EXPORT_VERSION}; fields the old file did not record are left empty.`] : []; // Skipping an unreadable receipt silently would tell someone their opt-in vanished. Say it. const skipped = rawContributions.length - contributions.length; diff --git a/tests/portability.test.js b/tests/portability.test.js index 0be05ef..1991697 100644 --- a/tests/portability.test.js +++ b/tests/portability.test.js @@ -68,6 +68,9 @@ test('a version 1 backup imports its confirmed values and reports the upgrade', assert.equal(result.entries[0].provenance, null, 'a pre-provenance backup must not be given a source it never recorded'); assert.match(result.notices.join(' '), /version 1/i); assert.match(result.notices.join(' '), /upgraded/i); + // The import screen already reports what was restored; a notice that restates the count renders as + // a duplicated sentence on screen, so the upgrade notice must only describe the upgrade. + assert.doesNotMatch(result.notices.join(' '), /Restored \d+ logs?/); assert.equal(importLedger(legacyBackup).length, 1, 'the plain entry import still works'); });