diff --git a/src/test/Components/CreateImageWizard/CreateImageWizard.compliance.test.tsx b/src/test/Components/CreateImageWizard/CreateImageWizard.compliance.test.tsx index b5c05ae0..a704c882 100644 --- a/src/test/Components/CreateImageWizard/CreateImageWizard.compliance.test.tsx +++ b/src/test/Components/CreateImageWizard/CreateImageWizard.compliance.test.tsx @@ -242,40 +242,3 @@ describe('Step Compliance', () => { ).toBeEnabled(); }); }); - -// -// TO DO - check if the correct version of Wizard is tested -// -//describe('On Recreate', () => { -// const setup = async () => { -// renderWithReduxRouter('imagewizard/1679d95b-8f1d-4982-8c53-8c2afa4ab04c'); -// }; -// test('with oscap profile', async () => { -// const user = userEvent.setup(); -// await setup(); -// await screen.findByRole('button', { -// name: /review/i, -// }); -// const createImageButton = await screen.findByRole('button', { -// name: /create image/i, -// }); -// await waitFor(() => expect(createImageButton).toBeEnabled()); - -// check that the FSC contains a /tmp partition -// There are two buttons with the same name but cannot easily select the DDF rendered sidenav. -// The sidenav will be the first node found out of all buttons. -// const buttonsFSC = await screen.findAllByRole('button', { -// name: /file system configuration/i, -// }); -// await user.click(buttonsFSC[0]); -// await screen.findByRole('heading', { name: /file system configuration/i }); -// await screen.findByText('/tmp'); - -// check that the Packages contain a nftable package -// await clickNext(); -// await screen.findByRole('heading', { -// name: /Additional Red Hat packages/i, -// }); -// await screen.findByText('nftables'); -// }); -//}); diff --git a/src/test/Components/CreateImageWizard/steps/Oscap/Oscap.test.tsx b/src/test/Components/CreateImageWizard/steps/Oscap/Oscap.test.tsx index c073a148..130672bf 100644 --- a/src/test/Components/CreateImageWizard/steps/Oscap/Oscap.test.tsx +++ b/src/test/Components/CreateImageWizard/steps/Oscap/Oscap.test.tsx @@ -6,6 +6,11 @@ import { CreateBlueprintRequest } from '../../../../../store/imageBuilderApi'; import { mockBlueprintIds } from '../../../../fixtures/blueprints'; import { baseCreateBlueprintRequest, + expectedFilesystemCisL2, + expectedKernelCisL2, + expectedOpenscapCisL2, + expectedPackagesCisL2, + expectedServicesCisL2, oscapCreateBlueprintRequest, } from '../../../../fixtures/editMode'; import { clickNext } from '../../../../testUtils'; @@ -101,27 +106,6 @@ const goToReviewStep = async () => { await clickNext(); // Review }; -const expectedOpenscapCisL2 = { - profile_id: 'xccdf_org.ssgproject.content_profile_cis_workstation_l2', -}; - -const expectedPackagesCisL2 = ['aide', 'emacs']; - -const expectedServicesCisL2 = { - enabled: ['crond', 'emacs-service'], - masked: ['nfs-server', 'neovim-service'], -}; - -const expectedKernelCisL2 = { - append: 'audit_backlog_limit=8192 audit=2', -}; - -const expectedFilesystemCisL2 = [ - { min_size: 10737418240, mountpoint: '/' }, - { min_size: 1073741824, mountpoint: '/tmp' }, - { min_size: 1073741824, mountpoint: '/app' }, -]; - describe('oscap', () => { beforeEach(() => { vi.clearAllMocks(); @@ -195,6 +179,7 @@ describe('OpenSCAP edit mode', () => { vi.clearAllMocks(); }); + const user = userEvent.setup(); test('edit mode works', async () => { const id = mockBlueprintIds['oscap']; await renderEditMode(id); @@ -206,4 +191,30 @@ describe('OpenSCAP edit mode', () => { const expectedRequest = oscapCreateBlueprintRequest; expect(receivedRequest).toEqual(expectedRequest); }); + + test('fsc and packages get populated on edit', async () => { + const id = mockBlueprintIds['oscap']; + await renderEditMode(id); + + // check that the FSC contains a /tmp partition + const fscBtns = await screen.findAllByRole('button', { + name: /file system configuration/i, + }); + user.click(fscBtns[0]); + await screen.findByRole('heading', { name: /file system configuration/i }); + await screen.findByText('/tmp'); + // check that the Packages contain neovim package + const packagesNavBtn = await screen.findByRole('button', { + name: /additional packages/i, + }); + user.click(packagesNavBtn); + await screen.findByRole('heading', { + name: /Additional packages/i, + }); + const selectedBtn = await screen.findByRole('button', { + name: /Selected/i, + }); + user.click(selectedBtn); + await screen.findByText('neovim'); + }); }); diff --git a/src/test/fixtures/editMode.ts b/src/test/fixtures/editMode.ts index 87115996..909aad0b 100644 --- a/src/test/fixtures/editMode.ts +++ b/src/test/fixtures/editMode.ts @@ -60,6 +60,27 @@ export const expectedFilesystemCisL1 = [ { min_size: 1073741824, mountpoint: '/home' }, ]; +export const expectedOpenscapCisL2 = { + profile_id: 'xccdf_org.ssgproject.content_profile_cis_workstation_l2', +}; + +export const expectedPackagesCisL2 = ['aide', 'emacs']; + +export const expectedServicesCisL2 = { + enabled: ['crond', 'emacs-service'], + masked: ['nfs-server', 'neovim-service'], +}; + +export const expectedKernelCisL2 = { + append: 'audit_backlog_limit=8192 audit=2', +}; + +export const expectedFilesystemCisL2 = [ + { min_size: 10737418240, mountpoint: '/' }, + { min_size: 1073741824, mountpoint: '/tmp' }, + { min_size: 1073741824, mountpoint: '/app' }, +]; + // FSC export const expectedFsc = [ { min_size: 10 * UNIT_GIB, mountpoint: '/' },