test(storage): follow the release queue in the tests that pinned an immediate delete

Replacing a cover or an avatar and deleting a note file now hand the old
bytes to the release queue instead of deleting them in the request; the
integration tests check the queue row and that the bytes are still
there. Release mocks answer with a count, the reclaim e2e sends its
refused bodies one after another, and a stale-count reload that fails is
told to the admin instead of swallowed.
This commit is contained in:
Maurice
2026-11-01 18:46:58 +01:00
parent 0b598680ec
commit bf8e04741d
9 changed files with 56 additions and 26 deletions
@@ -453,7 +453,7 @@ describe('BackupService (wrapper)', () => {
let runningInside = false;
vi.mocked(backupSvc.createBackup).mockImplementationOnce(async () => {
runningInside = jobs.backupRunning;
return { filename: 'svc.zip', size: 5 };
return { filename: 'svc.zip', size: 5, sizeText: '5 B', created_at: '2026-11-01T00:00:00.000Z' };
});
await wrapper.createBackup();
expect(runningInside).toBe(true);
@@ -996,7 +996,7 @@ describe('hardening', () => {
collabRelease.releaseValues.mockClear();
collabRelease.releaseValues.mockImplementationOnce(async () => {
expect(await countRows(orm, TripFiles, { id: attachment.id })).toBe(0);
return [];
return 0;
});
expect(await svc.deleteNoteFile(trip.id, note.id, attachment.id)).toBe(true);
expect(collabRelease.releaseValues).toHaveBeenLastCalledWith(['stuck.pdf'], { bare: 'files', basename: true });
@@ -1004,7 +1004,7 @@ describe('hardening', () => {
await attachToNote(trip.id, note.id, 'files/legacy.pdf', 'legacy.pdf');
collabRelease.releaseValues.mockImplementationOnce(async () => {
expect(await countRows(orm, CollabNotes, { id: note.id })).toBe(0);
return [];
return 0;
});
expect(await svc.deleteNote(trip.id, note.id)).toBe(true);
expect(collabRelease.releaseValues).toHaveBeenLastCalledWith(['files/legacy.pdf'], {
+1 -1
View File
@@ -565,7 +565,7 @@ describe('permanentDeleteFile', () => {
const file = await makeFile(trip.id, user.id, { filename: 'on-disk.pdf' });
release.releaseValues.mockImplementationOnce(async () => {
expect(await svc.getFileById(file.id, trip.id)).toBeUndefined();
return [];
return 0;
});
await svc.permanentDeleteFile((await svc.getFileById(file.id, trip.id))!);
expect(release.releaseValues).toHaveBeenCalledWith(['on-disk.pdf'], FILE_KEYS);
@@ -454,7 +454,7 @@ describe('deleteUserCompletely', () => {
await updateRows(orm, Users, { id: user.id }, { avatar: 'face.png' });
cleanupRelease.releaseValues.mockImplementationOnce(async () => {
expect(await findRow(orm, Users, { id: user.id })).toBeNull();
return [];
return 0;
});
await svc.deleteUserCompletely(user.id);
expect(cleanupRelease.releaseValues).toHaveBeenCalledWith(['face.png'], { bare: 'avatars' });