From 780b0cf0988a78494e7e5b8a8af3ee14e7c1079b Mon Sep 17 00:00:00 2001 From: "pulse-triage[bot]" <249995291+pulse-triage[bot]@users.noreply.github.com> Date: Wed, 9 Sep 2026 18:16:42 +0100 Subject: [PATCH] test(web): cover standalone connection rename across polling The existing update-path test submitted unchanged values, leaving standalone PVE rename behaviour unproved. Type a new name, refresh the same connection and assert the edited payload reaches saveNode with the existing target rather than the add path. Change-source: pulse-maintainer --- .../__tests__/NodeCredentialSlot.test.tsx | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) 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); });