fix(portability): report only the upgrade in the import notice (#35)
Quality gates / quality (push) Successful in 29m22s
Quality gates / quality (push) Successful in 29m22s
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.
This commit is contained in:
1 parent
5a15fa660e
commit
4ac71915fb
2 files changed
+6
-1
No files matched your search
+3
-1
@@ -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;
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user