diff --git a/src/test/Components/CreateImageWizard/steps/Services/Services.test.tsx b/src/test/Components/CreateImageWizard/steps/Services/Services.test.tsx index fd6a9099..5b170c80 100644 --- a/src/test/Components/CreateImageWizard/steps/Services/Services.test.tsx +++ b/src/test/Components/CreateImageWizard/steps/Services/Services.test.tsx @@ -2,7 +2,9 @@ import type { Router as RemixRouter } from '@remix-run/router'; import { screen, waitFor, within } 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 { servicesCreateBlueprintRequest } from '../../../../fixtures/editMode'; import { blueprintRequest, clickBack, @@ -10,6 +12,8 @@ import { enterBlueprintName, interceptBlueprintRequest, openAndDismissSaveAndBuildModal, + interceptEditBlueprintRequest, + renderEditMode, verifyCancelButton, } from '../../wizardTestUtils'; import { clickRegisterLater, renderCreateMode } from '../../wizardTestUtils'; @@ -279,5 +283,22 @@ describe('Services request generated correctly', () => { }); }); +describe('Services edit mode', () => { + beforeEach(() => { + vi.clearAllMocks(); + }); + + test('edit mode works', async () => { + const id = mockBlueprintIds['services']; + await renderEditMode(id); + + // starts on review step + const receivedRequest = await interceptEditBlueprintRequest( + `${EDIT_BLUEPRINT}/${id}` + ); + const expectedRequest = servicesCreateBlueprintRequest; + expect(receivedRequest).toEqual(expectedRequest); + }); +}); + // TO DO 'Services step' -> 'revisit step button on Review works' -// TO DO 'Services edit mode' diff --git a/src/test/fixtures/blueprints.ts b/src/test/fixtures/blueprints.ts index 492318b7..44773af6 100644 --- a/src/test/fixtures/blueprints.ts +++ b/src/test/fixtures/blueprints.ts @@ -39,6 +39,7 @@ export const mockBlueprintIds = { hostname: '05677f58-56c5-4c1e-953b-c8a93da70cc5', kernel: '8d6d35c7-a098-4bf5-a67f-5c59628210dc', firewall: '26f14b17-bdee-4c06-a12b-b6ee384350de', + services: '718dfa72-c919-4ad8-a02f-a8cd5bbd6edc', firstBoot: 'd0a8376e-e44e-47b3-845d-30f5199a35b6', details: '58991b91-4b98-47e0-b26d-8d908678ddb3', compliance: '21571945-fe23-45e9-8afb-4aa073b8d735', @@ -71,6 +72,7 @@ export const mockBlueprintNames = { hostname: 'hostname', kernel: 'kernel', firewall: 'firewall', + services: 'services', firstBoot: 'firstBoot', details: 'details', compliance: 'compliance', @@ -99,6 +101,7 @@ export const mockBlueprintDescriptions = { hostname: '', kernel: '', firewall: '', + services: '', firstBoot: '', details: 'This is a test description for the Details step.', compliance: '', @@ -333,6 +336,13 @@ export const mockGetBlueprints: GetBlueprintsApiResponse = { version: 1, last_modified_at: '2021-09-08T21:00:00.000Z', }, + { + id: mockBlueprintIds['services'], + name: mockBlueprintNames['services'], + description: mockBlueprintDescriptions['services'], + 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 df1269a5..9128ee03 100644 --- a/src/test/fixtures/editMode.ts +++ b/src/test/fixtures/editMode.ts @@ -540,6 +540,21 @@ export const firewallBlueprintResponse: BlueprintResponse = { description: mockBlueprintDescriptions['firewall'], }; +export const servicesCreateBlueprintRequest: CreateBlueprintRequest = { + ...baseCreateBlueprintRequest, + name: mockBlueprintNames['services'], + description: mockBlueprintDescriptions['services'], + customizations: { + services: expectedServicesCisL1, + }, +}; + +export const servicesBlueprintResponse: BlueprintResponse = { + ...servicesCreateBlueprintRequest, + id: mockBlueprintIds['services'], + description: mockBlueprintDescriptions['services'], +}; + export const firstBootCreateBlueprintRequest: CreateBlueprintRequest = { ...baseCreateBlueprintRequest, name: mockBlueprintNames['firstBoot'], @@ -636,6 +651,8 @@ export const getMockBlueprintResponse = (id: string) => { return kernelBlueprintResponse; case mockBlueprintIds['firewall']: return firewallBlueprintResponse; + case mockBlueprintIds['services']: + return servicesBlueprintResponse; case mockBlueprintIds['firstBoot']: return firstBootBlueprintResponse; case mockBlueprintIds['details']: