diff --git a/frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/__tests__/NodeCredentialSlot.test.tsx b/frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/__tests__/NodeCredentialSlot.test.tsx index b74f43f50..8f857dd47 100644 --- a/frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/__tests__/NodeCredentialSlot.test.tsx +++ b/frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/__tests__/NodeCredentialSlot.test.tsx @@ -325,7 +325,7 @@ describe('NodeCredentialSlot', () => { expect(payload).not.toHaveProperty('clusterEndpointOverrides'); }); - it('passes the edited node to saveNode so edits hit the update path', async () => { + it('saves a standalone PVE rename to the original connection after a poll', async () => { const settings = createSettings(); const onSaved = vi.fn(); const editingNode = { @@ -340,22 +340,37 @@ describe('NodeCredentialSlot', () => { status: 'connected', } as unknown as NodeConfigWithStatus; + const [node, setNode] = createSignal(editingNode); + render(() => ( )); + const name = screen.getByLabelText(/^Node Name/); + fireEvent.input(name, { target: { value: 'renamed-connection' } }); + setNode({ ...editingNode, name: 'server-refresh' }); + await waitFor(() => { + expect(screen.getByLabelText(/^Node Name/)).toBe(name); + expect(name).toHaveValue('renamed-connection'); + }); + expect(settings.saveNode).not.toHaveBeenCalled(); + fireEvent.submit(screen.getByRole('button', { name: 'Save changes' }).closest('form')!); await vi.waitFor(() => { expect(settings.saveNode).toHaveBeenCalledTimes(1); }); - expect(vi.mocked(settings.saveNode).mock.calls[0][1]).toBe(editingNode); + expect(settings.saveNode).toHaveBeenCalledExactlyOnceWith( + expect.objectContaining({ name: 'renamed-connection', host: editingNode.host }), + node(), + ); + expect(node().id).toBe('pve-0'); await vi.waitFor(() => { expect(onSaved).toHaveBeenCalledTimes(1); });