Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Exercise VMware draft withdrawal at the organisation wire boundary

pulse-triage[bot]c786dbfbec78
diff --git a/frontend-modern/src/components/Settings/__tests__/useVMwareSettingsPanelState.transport.test.tsx b/frontend-modern/src/components/Settings/__tests__/useVMwareSettingsPanelState.transport.test.tsx
index f19a29ac7b..43b548c49c 100644
--- a/frontend-modern/src/components/Settings/__tests__/useVMwareSettingsPanelState.transport.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/useVMwareSettingsPanelState.transport.test.tsx
@@ -251,4 +251,21 @@ describe('VMware settings through the real API transport', () => {
expect(result.form().hasStoredPassword).toBe(true);
},
);
+ it('refuses a stale draft mutation if organisation storage changed without an event', async () => {
+ const { result } = renderHook(() => useVMwareSettingsPanelState());
+ await ready(result);
+ result.openEditDialog(result.connections()[0]);
+ result.updateForm({ password: 'synthetic-old-org-draft', name: 'Old org unsaved name' });
+ setOrgID('south');
+ await result.saveCurrentForm();
+ await ready(result);
+ expect(fetchMock).toHaveBeenCalledTimes(2);
+ expect(fetchMock.mock.calls.every(([, options]) => (options?.method || 'GET') === 'GET')).toBe(
+ true,
+ );
+ expect(new Headers(fetchMock.mock.calls[1][1]?.headers).get('X-Pulse-Org-ID')).toBe('south');
+ expect(result.connections()[0].name).toBe('Replacement source');
+ expect(result.dialogOpen()).toBe(false);
+ expect(result.form().password).toBe('');
+ });
});