mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-27 23:27:31 +00:00
fix(storage): Test on a mirrored phone storage row probes the backends on the form
On the phone storage panel, Test on a mirrored backend sent the mirror itself to POST /api/admin/storage/test. The server expands a mirror by looking its primary and replicas up by name in the SAVED storage config, so the phone tested the saved settings instead of what the operator had just edited, and a replica added but not saved yet made the whole test fail with "references unknown backend". The desktop probes the primary and each replica with their draft options and merges the results. Cause: the phone called admin.test with the mirror candidate, while the desktop called admin.testMirror with mirrorProbeTargets. The choice lived in each shell's markup. Fix: useStoragePanel now offers loaded.testRow(row), which tests a plain row as it is and a mirrored row through admin.testMirror with mirrorProbeTargets from the draft. Both shells call it. Red test: FE-MOB-MSTOR-018 (new, MAdminStoragePanel.test.tsx) failed with "AssertionError: expected [ 'mirror' ] to deeply equal [ 'backups-local', 'off-box' ]". FE-ADMIN-STOR-PANEL-017 (new, useStoragePanel.test.ts) covers testRow itself. No existing assertion changed.
This commit is contained in:
@@ -441,4 +441,26 @@ describe('MAdminStoragePanel', () => {
|
||||
await new Promise((r) => setTimeout(r, 100));
|
||||
expect(screen.queryByText(/Existing objects are not replicated yet/)).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-MOB-MSTOR-018: Test on a mirrored primary probes the draft primary and each replica, never the mirror stub', async () => {
|
||||
const posted: Array<{ name: string; type: string; options: Record<string, unknown> }> = [];
|
||||
await renderPanel(mirroredState());
|
||||
server.use(
|
||||
http.post('/api/admin/storage/test', async ({ request }) => {
|
||||
const body = (await request.json()) as { backend: { name: string; type: string; options: Record<string, unknown> } };
|
||||
posted.push(body.backend);
|
||||
return HttpResponse.json({ ok: true, targets: [{ name: body.backend.name, ok: true }] });
|
||||
}),
|
||||
);
|
||||
// An unsaved endpoint change on the replica must be what the probe sees.
|
||||
fireEvent.click(within(screen.getByTestId('m-storage-backend-off-box')).getByRole('button', { name: 'Edit' }));
|
||||
fireEvent.change(screen.getByDisplayValue('http://127.0.0.1:9000'), { target: { value: 'http://edited.example:9000' } });
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Apply' }));
|
||||
fireEvent.click(within(screen.getByTestId('m-storage-backend-backups-local')).getByRole('button', { name: 'Test' }));
|
||||
await waitFor(() => expect(posted.length).toBeGreaterThan(0));
|
||||
await new Promise((r) => setTimeout(r, 50));
|
||||
expect(posted.map((b) => b.name).sort()).toEqual(['backups-local', 'off-box']);
|
||||
expect(posted.every((b) => b.type !== 'mirror')).toBe(true);
|
||||
expect(posted.find((b) => b.name === 'off-box')?.options.endpoint).toBe('http://edited.example:9000');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user