diff --git a/src/test/Components/CreateImageWizard/steps/Firewall/Firewall.test.tsx b/src/test/Components/CreateImageWizard/steps/Firewall/Firewall.test.tsx index 2b8731e70..eeb2f24c4 100644 --- a/src/test/Components/CreateImageWizard/steps/Firewall/Firewall.test.tsx +++ b/src/test/Components/CreateImageWizard/steps/Firewall/Firewall.test.tsx @@ -2,14 +2,18 @@ import type { Router as RemixRouter } from '@remix-run/router'; import { screen, waitFor } from '@testing-library/react'; import { userEvent } from '@testing-library/user-event'; -import { CREATE_BLUEPRINT } from '../../../../../constants'; +import { CREATE_BLUEPRINT, EDIT_BLUEPRINT } from '../../../../../constants'; +import { mockBlueprintIds } from '../../../../fixtures/blueprints'; +import { firewallCreateBlueprintRequest } from '../../../../fixtures/editMode'; import { blueprintRequest, clickBack, clickNext, enterBlueprintName, interceptBlueprintRequest, + interceptEditBlueprintRequest, openAndDismissSaveAndBuildModal, + renderEditMode, verifyCancelButton, } from '../../wizardTestUtils'; import { clickRegisterLater, renderCreateMode } from '../../wizardTestUtils'; @@ -205,5 +209,22 @@ describe('Firewall request generated correctly', () => { }); }); +describe('Firewall edit mode', () => { + beforeEach(() => { + vi.clearAllMocks(); + }); + + test('edit mode works', async () => { + const id = mockBlueprintIds['firewall']; + await renderEditMode(id); + + // starts on review step + const receivedRequest = await interceptEditBlueprintRequest( + `${EDIT_BLUEPRINT}/${id}` + ); + const expectedRequest = firewallCreateBlueprintRequest; + expect(receivedRequest).toEqual(expectedRequest); + }); +}); + // TO DO Step Firewall -> revisit step button on Review works -// TO DO Firewall edit mode diff --git a/src/test/fixtures/blueprints.ts b/src/test/fixtures/blueprints.ts index b1fa91454..ecbe281e3 100644 --- a/src/test/fixtures/blueprints.ts +++ b/src/test/fixtures/blueprints.ts @@ -38,6 +38,7 @@ export const mockBlueprintIds = { locale: '6e982b49-cd2e-4ad0-9962-39315a0ed9d1', hostname: '05677f58-56c5-4c1e-953b-c8a93da70cc5', kernel: '8d6d35c7-a098-4bf5-a67f-5c59628210dc', + firewall: '26f14b17-bdee-4c06-a12b-b6ee384350de', firstBoot: 'd0a8376e-e44e-47b3-845d-30f5199a35b6', details: '58991b91-4b98-47e0-b26d-8d908678ddb3', compliance: '21571945-fe23-45e9-8afb-4aa073b8d735', @@ -64,6 +65,7 @@ export const mockBlueprintNames = { locale: 'locale', hostname: 'hostname', kernel: 'kernel', + firewall: 'firewall', firstBoot: 'firstBoot', details: 'details', compliance: 'compliance', @@ -90,6 +92,7 @@ export const mockBlueprintDescriptions = { locale: '', hostname: '', kernel: '', + firewall: '', firstBoot: '', details: 'This is a test description for the Details step.', compliance: '', @@ -316,6 +319,13 @@ export const mockGetBlueprints: GetBlueprintsApiResponse = { version: 1, last_modified_at: '2021-09-08T21:00:00.000Z', }, + { + id: mockBlueprintIds['firewall'], + name: mockBlueprintNames['firewall'], + description: mockBlueprintDescriptions['firewall'], + version: 1, + last_modified_at: '2021-09-08T21:00:00.000Z', + }, { id: mockBlueprintIds['firstBoot'], name: mockBlueprintNames['firstBoot'], diff --git a/src/test/fixtures/editMode.ts b/src/test/fixtures/editMode.ts index 2e8611cd3..df1269a5b 100644 --- a/src/test/fixtures/editMode.ts +++ b/src/test/fixtures/editMode.ts @@ -511,6 +511,35 @@ export const kernelBlueprintResponse: BlueprintResponse = { description: mockBlueprintDescriptions['kernel'], }; +export const firewallCreateBlueprintRequest: CreateBlueprintRequest = { + ...baseCreateBlueprintRequest, + name: mockBlueprintNames['firewall'], + description: mockBlueprintDescriptions['firewall'], + customizations: { + firewall: { + ports: [ + '22:tcp', + '80:tcp', + 'imap:tcp', + '53:tcp', + '53:udp', + '30000-32767:tcp', + '30000-32767:udp', + ], + services: { + disabled: ['telnet'], + enabled: ['ftp', 'ntp', 'dhcp'], + }, + }, + }, +}; + +export const firewallBlueprintResponse: BlueprintResponse = { + ...firewallCreateBlueprintRequest, + id: mockBlueprintIds['firewall'], + description: mockBlueprintDescriptions['firewall'], +}; + export const firstBootCreateBlueprintRequest: CreateBlueprintRequest = { ...baseCreateBlueprintRequest, name: mockBlueprintNames['firstBoot'], @@ -605,6 +634,8 @@ export const getMockBlueprintResponse = (id: string) => { return hostnameBlueprintResponse; case mockBlueprintIds['kernel']: return kernelBlueprintResponse; + case mockBlueprintIds['firewall']: + return firewallBlueprintResponse; case mockBlueprintIds['firstBoot']: return firstBootBlueprintResponse; case mockBlueprintIds['details']: