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
8 changes: 8 additions & 0 deletions packages/runtime/src/seed-loader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1119,6 +1119,8 @@ describe('SeedLoaderService', () => {

expect(result.success).toBe(true);
expect(result.summary.totalErrored).toBe(0);
// One record ⇒ one write; a repeat here would be a double seed (#15607).
expect(engine.insert).toHaveBeenCalledTimes(1);
expect(engine.insert).toHaveBeenCalledWith(
'note',
expect.objectContaining({ name: 'N1', author: 'usr_system' }),
Expand Down Expand Up @@ -1152,6 +1154,8 @@ describe('SeedLoaderService', () => {

expect(result.success).toBe(true);
expect(result.summary.totalErrored).toBe(0);
// One record ⇒ one write; a repeat here would be a double seed (#15607).
expect(engine.insert).toHaveBeenCalledTimes(1);
expect(engine.insert).toHaveBeenCalledWith(
'note',
expect.objectContaining({ name: 'N1', author: null }),
Expand Down Expand Up @@ -1180,6 +1184,10 @@ describe('SeedLoaderService', () => {
});

expect(result.success).toBe(true);
// One record, mode 'insert' ⇒ exactly ONE engine write. Seed application is
// the very path where a doubled collect writes twice and stays green under
// `toHaveBeenCalledWith` (#15607).
expect(engine.insert).toHaveBeenCalledTimes(1);
expect(engine.insert).toHaveBeenCalledWith(
'note',
expect.objectContaining({ org_label: 'org_123' }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,10 @@ describe('createSysFileReapGuard', () => {
{ id: 'f1', key: 'attachments/f1.bin', status: 'deleted', scope: 'attachments' },
]);

// ONE tombstoned row in ⇒ exactly ONE irreversible byte delete: the count IS
// the contract for a sweep that re-runs, and `toHaveBeenCalledWith` alone is
// satisfied by a repeat just as well as by a single call (#15607).
expect(s.delete).toHaveBeenCalledTimes(1);
expect(s.delete).toHaveBeenCalledWith('attachments/f1.bin');
expect(confirmed).toEqual(['f1']);
});
Expand Down Expand Up @@ -467,6 +471,9 @@ describe('createSysFileReapGuard', () => {
{ id: 'f1', key: 'user/f1.png', status: 'deleted', scope: 'user', ref_object: null, ref_id: null },
]);

// One released field file, one open gate ⇒ exactly one byte delete; a second
// call would be a re-reap of a key already gone (#15607).
expect(s.delete).toHaveBeenCalledTimes(1);
expect(s.delete).toHaveBeenCalledWith('user/f1.png');
expect(confirmed).toEqual(['f1']);
});
Expand Down Expand Up @@ -566,6 +573,8 @@ describe('createSysFileReapGuard', () => {
{ id: 'p1', key: 'user/p1.bin', status: 'pending' },
]);

// Best-effort cleanup of ONE abandoned upload — exactly one delete (#15607).
expect(s.delete).toHaveBeenCalledTimes(1);
expect(s.delete).toHaveBeenCalledWith('user/p1.bin');
expect(confirmed).toEqual(['p1']);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ describe('the reclamation gate refuses to delete bytes while a deviation stands
});

expect(await guard('sys_file', [{ ...RELEASED_FIELD_FILE }])).toEqual(['f1']);
// The guard ran TWICE in this test: withheld first, authorised second. So the
// count is the whole point — 1 proves the withheld pass deleted nothing, and
// `toHaveBeenCalledWith` alone would pass just the same if it had (#15607).
expect(s.delete).toHaveBeenCalledTimes(1);
expect(s.delete).toHaveBeenCalledWith('user/f1.png');
});

Expand All @@ -201,6 +205,8 @@ describe('the reclamation gate refuses to delete bytes while a deviation stands
// reach a lifecycle that never gated on the flag would be the borrowed-
// evidence error in the other direction.
expect(confirmed).toEqual(['a1']);
// One attachment-scope tombstone ⇒ exactly one byte delete (#15607).
expect(s.delete).toHaveBeenCalledTimes(1);
expect(s.delete).toHaveBeenCalledWith('attachments/a1.bin');
});
});
Expand Down
3 changes: 3 additions & 0 deletions packages/spec/src/shared/resilient-fetch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ describe('resilientFetch', () => {
const fetchImpl = scripted([[429, { 'retry-after': '2' }], 200]);
const sleep = vi.fn(noSleep);
await resilientFetch('http://x', {}, { fetchImpl, sleep, retries: 3 });
// One 429 ⇒ exactly ONE backoff. This is a retry path, where a doubled sleep
// is a real defect and `toHaveBeenCalledWith(2000)` cannot see it (#15607).
expect(sleep).toHaveBeenCalledTimes(1);
expect(sleep).toHaveBeenCalledWith(2000);
});

Expand Down
Loading