test: pin the transfers' creation dates, renumber rows no transfer holds (#521)

The creation date of a restored transfer is now compared against a value
set apart from the clock, so a restore that wrote its own would show.
The file whose rows do not keep their ids now gives a duplicate id to
two rows no transfer holds: the linked rows come back unchanged in the
file, and only the renumbering by SQLite unlinks them, which the preview
must announce too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
le king fu 2026-11-04 22:34:12 -05:00
commit 32b7c2e518

View file

@ -483,6 +483,9 @@ describe("restoring a profile that holds a Bilan transfer (#521)", () => {
// As « Lier transferts » links them, by the real service.
await linkTransfer(CELI, contribution, "in", "Cotisation d'octobre");
await linkTransfer(REER, withdrawal, "out");
// Dates of creation set apart from the clock: a restore that wrote its own would show.
profile.prepare("UPDATE balance_account_transfers SET created_at = '2026-10-04 09:15:00' WHERE id = 1").run();
profile.prepare("UPDATE balance_account_transfers SET created_at = '2026-10-06 18:30:00' WHERE id = 2").run();
transfersBefore = transfersOf(profile);
expect(transfersBefore.map((t) => [t.id, t.account_id, t.transaction_id, t.direction])).toEqual([
[1, CELI, contribution, "in"],
@ -565,12 +568,13 @@ describe("restoring a profile that holds a Bilan transfer (#521)", () => {
[],
],
[
"its rows do not keep their ids (two share one, no split line)",
// The two linked rows come back unchanged in the file, but SQLite renumbers every row.
"its rows do not keep their ids (« PAIE » bears the id of « LOYER », no split line)",
(data) => ({
...data,
transactions: (data.transactions ?? [])
.filter((tx) => tx.parent_transaction_id === null)
.map((tx) => (tx.id === 7 ? { ...tx, id: 6 } : { ...tx, is_split: 0 })),
.map((tx) => ({ ...tx, id: tx.id === 3 ? 2 : tx.id, is_split: 0 })),
}),
[],
],