From 7312132767cca14c48baec2c0016c581eede2031 Mon Sep 17 00:00:00 2001 From: findthelorax Date: Mon, 20 Apr 2026 12:18:46 -0400 Subject: [PATCH] adjusted test to be more exhaustive of all container and parent node types --- .../modals/__tests__/NodeModal.test.tsx | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/frontend/src/components/modals/__tests__/NodeModal.test.tsx b/frontend/src/components/modals/__tests__/NodeModal.test.tsx index a466733..78a7cec 100644 --- a/frontend/src/components/modals/__tests__/NodeModal.test.tsx +++ b/frontend/src/components/modals/__tests__/NodeModal.test.tsx @@ -236,18 +236,16 @@ describe('NodeModal', () => { // ── Container mode ───────────────────────────────────────────────────── - it('shows Container Mode toggle for proxmox type', () => { - renderModal({ initial: { ...BASE, type: 'proxmox' } }) + const containerModeTypes = ['proxmox', 'vm', 'lxc', 'docker_host'] as const + const nonContainerModeTypes = ['isp', 'router', 'switch', 'server', 'nas', 'ap', 'printer', 'iot', 'camera', 'cpl', 'computer', 'generic', 'groupRect', 'group'] as const + + it.each(containerModeTypes)('shows Container Mode toggle for %s type', (type) => { + renderModal({ initial: { ...BASE, type } }) expect(screen.getByText('Container Mode')).toBeDefined() }) - it('hides Container Mode for server type', () => { - renderModal({ initial: { ...BASE, type: 'server' } }) - expect(screen.queryByText('Container Mode')).toBeNull() - }) - - it('hides Container Mode for groupRect type', () => { - renderModal({ initial: { ...BASE, type: 'groupRect' } }) + it.each(nonContainerModeTypes)('hides Container Mode for %s type', (type) => { + renderModal({ initial: { ...BASE, type } }) expect(screen.queryByText('Container Mode')).toBeNull() }) @@ -260,22 +258,25 @@ describe('NodeModal', () => { // ── Parent container ────────────────────────────────────────────────── - it('shows Parent Container when options are provided', () => { + const parentContainerVisibleTypes = ['proxmox', 'vm', 'lxc', 'docker_host', 'isp', 'router', 'switch', 'server', 'nas', 'ap', 'printer', 'iot', 'camera', 'cpl', 'computer', 'generic'] as const + const parentContainerHiddenTypes = ['groupRect', 'group'] as const + + it.each(parentContainerVisibleTypes)('shows Parent Container for %s type when options are provided', (type) => { renderModal({ - initial: { ...BASE, type: 'server' }, + initial: { ...BASE, type }, parentContainerNodes: [{ id: 'c1', label: 'Container 01' }], }) expect(screen.getByText('Parent Container')).toBeDefined() expect(screen.getByText('Container 01')).toBeDefined() }) - it('hides Parent Container for groupRect type', () => { - renderModal({ initial: { ...BASE, type: 'groupRect' }, parentContainerNodes: [{ id: 'c1', label: 'Container 01' }] }) + it.each(parentContainerHiddenTypes)('hides Parent Container for %s type even when options are provided', (type) => { + renderModal({ initial: { ...BASE, type }, parentContainerNodes: [{ id: 'c1', label: 'Container 01' }] }) expect(screen.queryByText('Parent Container')).toBeNull() }) - it('hides Parent Container when no container options are available', () => { - renderModal({ initial: { ...BASE, type: 'server' } }) + it.each(parentContainerVisibleTypes)('hides Parent Container for %s type when no container options are available', (type) => { + renderModal({ initial: { ...BASE, type } }) expect(screen.queryByText('Parent Container')).toBeNull() })