fix(storage): a phone migration that fails to start drops the rest of the queue and says so

On the phone storage panel, when the operator accepted several category
moves and the first migration failed to start (for example the server
was busy), only that error was toasted. The other accepted moves stayed
in a hidden queue with no hint, and started on their own later whenever
the panel state happened to refresh. The desktop drops the rest of the
queue, names it in a storage.migrate.queueDropped toast and refreshes
the state, so the operator sees what did not move and saves again.

Cause: useStoragePanel only dropped the queue when the
dropQueueOnFailure option was set, and only the desktop set it.

Fix: the option is gone and useStoragePanel always drops the rest of
the queue on a failed start, toasts it and refreshes, for both shells.

Red test: FE-ADMIN-STOR-PANEL-011 (useStoragePanel.test.ts) failed with
"AssertionError: expected "vi.fn()" to be called 2 times, but got 1
times".

Changed assertions in src/components/Admin/storage/useStoragePanel.test.ts:
- FE-ADMIN-STOR-PANEL-011 (renamed from "by default a failed migration
  start only toasts and keeps the rest queued"): toast.error was called
  once, now twice; migrationQueue had length 1, now 0; refreshState was
  not called, now it is.
- FE-ADMIN-STOR-PANEL-012: no assertion changed; it no longer passes the
  removed dropQueueOnFailure option.
This commit is contained in:
Maurice
2026-10-09 17:34:56 +02:00
parent abbd2a94ce
commit a09d71ed12
3 changed files with 9 additions and 19 deletions
@@ -188,7 +188,7 @@ describe('useStoragePanel', () => {
expect(result.current.migratePrompt).toBeNull();
});
it('FE-ADMIN-STOR-PANEL-011: by default a failed migration start only toasts and keeps the rest queued', async () => {
it('FE-ADMIN-STOR-PANEL-011: a failed migration start toasts, drops the rest of the queue, and refreshes', async () => {
fake.admin = makeAdmin(baseState(), movingDraft('files', 'covers'));
vi.mocked(fake.admin.startMigration).mockResolvedValueOnce('busy');
const { result } = renderHook(() => useStoragePanel());
@@ -196,15 +196,15 @@ describe('useStoragePanel', () => {
await result.current.loaded!.moveAndSave();
});
await waitFor(() => expect(toast.error).toHaveBeenCalledWith('busy'));
expect(toast.error).toHaveBeenCalledTimes(1);
expect(result.current.migrationQueue).toHaveLength(1);
expect(fake.admin.refreshState).not.toHaveBeenCalled();
await waitFor(() => expect(toast.error).toHaveBeenCalledTimes(2));
expect(result.current.migrationQueue).toHaveLength(0);
expect(fake.admin.refreshState).toHaveBeenCalled();
});
it('FE-ADMIN-STOR-PANEL-012: with dropQueueOnFailure a failed start drops the rest, names it, and refreshes', async () => {
it('FE-ADMIN-STOR-PANEL-012: a failed start drops the rest, names it, and refreshes', async () => {
fake.admin = makeAdmin(baseState(), movingDraft('files', 'covers'));
vi.mocked(fake.admin.startMigration).mockResolvedValueOnce('busy');
const { result } = renderHook(() => useStoragePanel({ dropQueueOnFailure: true }));
const { result } = renderHook(() => useStoragePanel());
await act(async () => {
await result.current.loaded!.moveAndSave();
});