test: Add test fixtures and update tests where needed

Mock fixtures for RHEL 10 were missing, meaning the tests were unable to fetch mocked data and failed.
This commit is contained in:
regexowl 2025-06-19 13:55:13 +02:00 committed by Klara Simickova
parent cdd10a01ff
commit 1d3967a585
12 changed files with 204 additions and 35 deletions

View file

@ -5,6 +5,7 @@ import {
CREATE_BLUEPRINT,
EDIT_BLUEPRINT,
FIRST_BOOT_SERVICE,
RHEL_9,
} from '../../../../../constants';
import { mockBlueprintIds } from '../../../../fixtures/blueprints';
import {
@ -21,6 +22,7 @@ import {
goToOscapStep,
selectGuestImageTarget,
getNextButton,
selectRhel9,
} from '../../wizardTestUtils';
import {
blueprintRequest,
@ -159,6 +161,7 @@ describe('First Boot step', () => {
describe('First boot request generated correctly', () => {
test('with no OpenSCAP profile selected', async () => {
await renderCreateMode();
await selectRhel9();
await goToFirstBootStep();
await openCodeEditor();
await uploadFile(SCRIPT);
@ -170,6 +173,7 @@ describe('First boot request generated correctly', () => {
const expectedRequest = {
...blueprintRequest,
distribution: RHEL_9, // overrides default RHEL 10 to make OpenSCAP available
customizations: {
files: firstBootData,
services: { enabled: [FIRST_BOOT_SERVICE] },
@ -183,6 +187,7 @@ describe('First boot request generated correctly', () => {
test('with an OpenSCAP profile', async () => {
await renderCreateMode();
await selectRhel9();
await selectGuestImageTarget();
await goToOscapStep();
await selectSimplifiedOscapProfile();
@ -195,6 +200,7 @@ describe('First boot request generated correctly', () => {
// request created with both OpenSCAP and first boot customization
const expectedRequest = {
...blueprintRequest,
distribution: RHEL_9, // overrides default RHEL 10 to make OpenSCAP available
customizations: {
openscap: {
profile_id: 'xccdf_org.ssgproject.content_profile_standard',
@ -213,6 +219,7 @@ describe('First boot request generated correctly', () => {
test('dos2unix', async () => {
await renderCreateMode();
await selectRhel9();
await selectGuestImageTarget();
await goToOscapStep();
await selectSimplifiedOscapProfile();
@ -225,6 +232,7 @@ describe('First boot request generated correctly', () => {
// request created with both OpenSCAP and first boot customization
const expectedRequest = {
...blueprintRequest,
distribution: RHEL_9, // overrides default RHEL 10 to make OpenSCAP available
customizations: {
openscap: {
profile_id: 'xccdf_org.ssgproject.content_profile_standard',

View file

@ -7,6 +7,7 @@ import {
CENTOS_9,
CREATE_BLUEPRINT,
EDIT_BLUEPRINT,
RHEL_10,
RHEL_8,
RHEL_9,
X86_64,
@ -27,6 +28,8 @@ import {
import {
clickNext,
getNextButton,
openReleaseMenu,
selectRhel9,
verifyCancelButton,
} from '../../wizardTestUtils';
import {
@ -43,12 +46,6 @@ import { goToDetailsStep } from '../Details/Details.test';
let router: RemixRouter | undefined = undefined;
const openReleaseMenu = async () => {
const user = userEvent.setup();
const releaseMenu = screen.getByTestId('release_select');
await waitFor(() => user.click(releaseMenu));
};
const clickShowOptions = async () => {
const user = userEvent.setup();
const showOptions = await screen.findByRole('option', {
@ -66,15 +63,6 @@ const selectRhel8 = async () => {
await waitFor(() => user.click(rhel8));
};
const selectRhel9 = async () => {
const user = userEvent.setup();
await openReleaseMenu();
const rhel9 = await screen.findByRole('option', {
name: /red hat enterprise linux \(rhel\) 9 full support ends: may 2027 \| maintenance support ends: may 2032/i,
});
await waitFor(() => user.click(rhel9));
};
const selectCentos9 = async () => {
const user = userEvent.setup();
await openReleaseMenu();
@ -263,6 +251,7 @@ describe('Step Image output', () => {
test('VMware checkbox select and unselect works', async () => {
await renderCreateMode();
await selectRhel9();
await selectVMwareTarget();
let vmwareCheckbox = await screen.findByTestId('checkbox-vmware');
@ -346,8 +335,39 @@ describe('Check that the target filtering is in accordance to mock content', ()
vi.clearAllMocks();
});
test('rhel10 x86_64', async () => {
await renderCreateMode();
await selectX86_64();
// make sure this test is in SYNC with the mocks
let images_types: string[] = []; // type is `string[]` and not `ImageType[]` because in imageBuilderAPI ArchitectureItem['image_types'] is type string
mockArchitecturesByDistro(RHEL_10).forEach((elem) => {
if (elem.arch === X86_64) {
images_types = elem.image_types;
}
});
expect(images_types).toContain('aws');
expect(images_types).toContain('gcp');
expect(images_types).toContain('azure');
expect(images_types).toContain('oci');
expect(images_types).toContain('guest-image');
expect(images_types).toContain('image-installer');
expect(images_types).toContain('wsl');
// make sure the UX conforms to the mocks
await screen.findByTestId('upload-aws');
await screen.findByTestId('upload-google');
await screen.findByTestId('upload-azure');
await screen.findByTestId('upload-oci');
await screen.findByTestId('checkbox-guest-image');
await screen.findByTestId('checkbox-image-installer');
await screen.findByText(/wsl - windows subsystem for linux \(\.tar\.gz\)/i);
});
test('rhel9 x86_64', async () => {
await renderCreateMode();
await selectRhel9();
await selectX86_64();
// make sure this test is in SYNC with the mocks
@ -361,6 +381,7 @@ describe('Check that the target filtering is in accordance to mock content', ()
expect(images_types).toContain('aws');
expect(images_types).toContain('gcp');
expect(images_types).toContain('azure');
expect(images_types).toContain('oci');
expect(images_types).toContain('guest-image');
expect(images_types).toContain('image-installer');
expect(images_types).toContain('vsphere');
@ -371,6 +392,7 @@ describe('Check that the target filtering is in accordance to mock content', ()
await screen.findByTestId('upload-aws');
await screen.findByTestId('upload-google');
await screen.findByTestId('upload-azure');
await screen.findByTestId('upload-oci');
await screen.findByTestId('checkbox-guest-image');
await screen.findByTestId('checkbox-image-installer');
await screen.findByText(/vmware vsphere/i);
@ -396,6 +418,7 @@ describe('Check that the target filtering is in accordance to mock content', ()
expect(images_types).toContain('aws');
expect(images_types).toContain('gcp');
expect(images_types).toContain('azure');
expect(images_types).toContain('oci');
expect(images_types).toContain('guest-image');
expect(images_types).toContain('image-installer');
expect(images_types).toContain('vsphere');
@ -406,6 +429,7 @@ describe('Check that the target filtering is in accordance to mock content', ()
await screen.findByTestId('upload-aws');
await screen.findByTestId('upload-google');
await screen.findByTestId('upload-azure');
await screen.findByTestId('upload-oci');
await screen.findByTestId('checkbox-guest-image');
await screen.findByTestId('checkbox-image-installer');
await screen.findByText(/vmware vsphere/i);
@ -413,8 +437,49 @@ describe('Check that the target filtering is in accordance to mock content', ()
await screen.findByText(/wsl - windows subsystem for linux \(\.tar\.gz\)/i);
});
test('rhel10 aarch64', async () => {
await renderCreateMode();
await selectAarch64();
// make sure this test is in SYNC with the mocks
let images_types: string[] = [];
mockArchitecturesByDistro(RHEL_10).forEach((elem) => {
if (elem.arch === AARCH64) {
images_types = elem.image_types;
}
});
expect(images_types).toContain('aws');
expect(images_types).not.toContain('gcp');
expect(images_types).not.toContain('azure');
expect(images_types).not.toContain('oci');
expect(images_types).toContain('guest-image');
expect(images_types).toContain('image-installer');
expect(images_types).not.toContain('vsphere');
expect(images_types).not.toContain('vsphere-ova');
expect(images_types).not.toContain('wsl');
// make sure the UX conforms to the mocks
await screen.findByTestId('upload-aws');
await waitFor(() =>
expect(screen.queryByTestId('upload-google')).not.toBeInTheDocument()
);
expect(screen.queryByTestId('upload-azure')).not.toBeInTheDocument();
expect(screen.queryByTestId('upload-oci')).not.toBeInTheDocument();
await screen.findByTestId('checkbox-guest-image');
await screen.findByTestId('checkbox-image-installer');
expect(screen.queryByText(/vmware vsphere/i)).not.toBeInTheDocument();
expect(
screen.queryByText(/open virtualization format \(\.ova\)/i)
).not.toBeInTheDocument();
expect(
screen.queryByText(/wsl - windows subsystem for linux \(\.tar\.gz\)/i)
).not.toBeInTheDocument();
});
test('rhel9 aarch64', async () => {
await renderCreateMode();
await selectRhel9();
await selectAarch64();
// make sure this test is in SYNC with the mocks
@ -428,6 +493,7 @@ describe('Check that the target filtering is in accordance to mock content', ()
expect(images_types).toContain('aws');
expect(images_types).not.toContain('gcp');
expect(images_types).not.toContain('azure');
expect(images_types).not.toContain('oci');
expect(images_types).toContain('guest-image');
expect(images_types).toContain('image-installer');
expect(images_types).not.toContain('vsphere');
@ -440,6 +506,7 @@ describe('Check that the target filtering is in accordance to mock content', ()
expect(screen.queryByTestId('upload-google')).not.toBeInTheDocument()
);
expect(screen.queryByTestId('upload-azure')).not.toBeInTheDocument();
expect(screen.queryByTestId('upload-oci')).not.toBeInTheDocument();
await screen.findByTestId('checkbox-guest-image');
await screen.findByTestId('checkbox-image-installer');
expect(screen.queryByText(/vmware vsphere/i)).not.toBeInTheDocument();
@ -467,6 +534,7 @@ describe('Check that the target filtering is in accordance to mock content', ()
expect(images_types).toContain('aws');
expect(images_types).not.toContain('gcp');
expect(images_types).not.toContain('azure');
expect(images_types).not.toContain('oci');
expect(images_types).toContain('guest-image');
expect(images_types).toContain('image-installer');
expect(images_types).not.toContain('vsphere');
@ -477,6 +545,7 @@ describe('Check that the target filtering is in accordance to mock content', ()
await screen.findByTestId('upload-aws');
expect(screen.queryByTestId('upload-google')).not.toBeInTheDocument();
expect(screen.queryByTestId('upload-azure')).not.toBeInTheDocument();
expect(screen.queryByTestId('upload-oci')).not.toBeInTheDocument();
await screen.findByTestId('checkbox-guest-image');
await screen.findByTestId('checkbox-image-installer');
expect(screen.queryByText(/vmware vsphere/i)).not.toBeInTheDocument();
@ -526,16 +595,16 @@ describe('Set release using query parameter', () => {
vi.clearAllMocks();
});
test('rhel 9 by default (no query parameter)', async () => {
test('rhel 10 by default (no query parameter)', async () => {
await renderCreateMode();
await screen.findByText('Red Hat Enterprise Linux (RHEL) 9', {
await screen.findByText('Red Hat Enterprise Linux (RHEL) 10', {
exact: true,
});
});
test('rhel 9 by default (invalid query parameter)', async () => {
test('rhel 10 by default (invalid query parameter)', async () => {
await renderCreateMode({ release: 'rhel9001' });
await screen.findByText('Red Hat Enterprise Linux (RHEL) 9', {
await screen.findByText('Red Hat Enterprise Linux (RHEL) 10', {
exact: true,
});
});
@ -545,6 +614,11 @@ describe('Set release using query parameter', () => {
await screen.findByText('Red Hat Enterprise Linux (RHEL) 8');
});
test('rhel 9 (query parameter provided)', async () => {
await renderCreateMode({ release: 'rhel9' });
await screen.findByText('Red Hat Enterprise Linux (RHEL) 9');
});
test('rhel 10 beta (query parameter provided)', async () => {
await renderCreateMode({ release: 'rhel10beta' });
await screen.findByText('Red Hat Enterprise Linux (RHEL) 10 Beta');

View file

@ -2,7 +2,11 @@ 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, EDIT_BLUEPRINT } from '../../../../../constants';
import {
CREATE_BLUEPRINT,
EDIT_BLUEPRINT,
RHEL_9,
} from '../../../../../constants';
import { mockBlueprintIds } from '../../../../fixtures/blueprints';
import { kernelCreateBlueprintRequest } from '../../../../fixtures/editMode';
import {
@ -14,6 +18,7 @@ import {
interceptEditBlueprintRequest,
openAndDismissSaveAndBuildModal,
renderEditMode,
selectRhel9,
verifyCancelButton,
} from '../../wizardTestUtils';
import { clickRegisterLater, renderCreateMode } from '../../wizardTestUtils';
@ -215,6 +220,7 @@ describe('Step Kernel', () => {
test('kernel append from OpenSCAP gets added correctly and cannot be removed', async () => {
await renderCreateMode();
await selectRhel9();
await goToOpenSCAPStep();
await selectProfile();
await goFromOpenSCAPToKernel();
@ -326,6 +332,7 @@ describe('Kernel request generated correctly', () => {
test('with OpenSCAP profile that includes kernel append', async () => {
await renderCreateMode();
await selectRhel9();
await goToOpenSCAPStep();
await selectProfile();
await goFromOpenSCAPToKernel();
@ -334,6 +341,7 @@ describe('Kernel request generated correctly', () => {
const expectedRequest = {
...blueprintRequest,
distribution: RHEL_9, // overrides default RHEL 10 to make OpenSCAP available
customizations: {
openscap: {
profile_id: 'xccdf_org.ssgproject.content_profile_ccn_basic',

View file

@ -5,7 +5,7 @@ import { CREATE_BLUEPRINT, EDIT_BLUEPRINT } from '../../../../../constants';
import { CreateBlueprintRequest } from '../../../../../store/imageBuilderApi';
import { mockBlueprintIds } from '../../../../fixtures/blueprints';
import { complianceCreateBlueprintRequest } from '../../../../fixtures/editMode';
import { clickNext } from '../../wizardTestUtils';
import { clickNext, selectRhel9 } from '../../wizardTestUtils';
import {
clickRegisterLater,
enterBlueprintName,
@ -31,6 +31,7 @@ vi.mock('@unleash/proxy-client-react', () => ({
const goToComplianceStep = async () => {
const user = userEvent.setup();
await selectRhel9(); // Compliance is not available for RHEL 10 yet
const guestImageCheckBox = await screen.findByRole('checkbox', {
name: /virtualization guest image checkbox/i,
});

View file

@ -21,6 +21,7 @@ import {
renderCreateMode,
renderEditMode,
selectGuestImageTarget,
selectRhel9,
} from '../../wizardTestUtils';
import {
clickNext,
@ -117,6 +118,7 @@ describe('Step OpenSCAP', () => {
test('create an image with None OpenSCAP profile', async () => {
await renderCreateMode();
await selectRhel9(); // OpenSCAP is not available for RHEL 10 yet
await selectGuestImageTarget();
await goToOscapStep();
await selectNone();
@ -145,6 +147,7 @@ describe('Step OpenSCAP', () => {
test('create an image with an OpenSCAP profile', async () => {
await renderCreateMode();
await selectRhel9(); // OpenSCAP is not available for RHEL 10 yet
await selectGuestImageTarget();
await goToOscapStep();
await selectProfile();
@ -197,6 +200,7 @@ describe('Step OpenSCAP', () => {
test('clicking Review and finish leads to Review', async () => {
await renderCreateMode();
await selectRhel9(); // OpenSCAP is not available for RHEL 10 yet
await selectGuestImageTarget();
await goToOscapStep();
await clickReviewAndFinish();
@ -213,6 +217,7 @@ describe('OpenSCAP request generated correctly', () => {
test('add a profile', async () => {
await renderCreateMode();
await selectRhel9(); // OpenSCAP is not available for RHEL 10 yet
await selectGuestImageTarget();
await goToOscapStep();
await selectProfile();
@ -234,6 +239,7 @@ describe('OpenSCAP request generated correctly', () => {
test('remove a profile', { timeout: 20000 }, async () => {
await renderCreateMode();
await selectRhel9(); // OpenSCAP is not available for RHEL 10 yet
await selectGuestImageTarget();
await goToOscapStep();
await selectProfile();
@ -253,6 +259,7 @@ describe('OpenSCAP request generated correctly', () => {
test('change profile', { timeout: 20000 }, async () => {
await renderCreateMode();
await selectRhel9(); // OpenSCAP is not available for RHEL 10 yet
await selectGuestImageTarget();
await goToOscapStep();
await selectProfile();
@ -280,6 +287,7 @@ describe('OpenSCAP request generated correctly', () => {
test('revisit step button on Review works', async () => {
await renderCreateMode();
await selectRhel9(); // OpenSCAP is not available for RHEL 10 yet
await selectGuestImageTarget();
await goToOscapStep();
await selectProfile();

View file

@ -2,7 +2,11 @@ import { Router as RemixRouter } from '@remix-run/router/dist/router';
import { screen, waitFor, within } from '@testing-library/react';
import { userEvent } from '@testing-library/user-event';
import { CREATE_BLUEPRINT, EDIT_BLUEPRINT } from '../../../../../constants';
import {
CREATE_BLUEPRINT,
EDIT_BLUEPRINT,
RHEL_9,
} from '../../../../../constants';
import { CreateBlueprintRequest } from '../../../../../store/imageBuilderApi';
import { mockBlueprintIds } from '../../../../fixtures/blueprints';
import {
@ -16,6 +20,7 @@ import {
clickBack,
clickNext,
clickReviewAndFinish,
selectRhel9,
verifyCancelButton,
} from '../../wizardTestUtils';
import { selectCustomRepo } from '../../wizardTestUtils';
@ -382,6 +387,7 @@ describe('Step Packages', () => {
test('should display recommendations', async () => {
await renderCreateMode();
await selectRhel9(); // recommendations are not available for RHEL 10 yet
await goToPackagesStep();
await checkRecommendationsEmptyState();
await typeIntoSearchBox('test');
@ -394,6 +400,7 @@ describe('Step Packages', () => {
test('allow to add recommendations to selected', async () => {
await renderCreateMode();
await selectRhel9(); // recommendations are not available for RHEL 10 yet
await goToPackagesStep();
await checkRecommendationsEmptyState();
await typeIntoSearchBox('test');
@ -648,6 +655,7 @@ describe('Packages request generated correctly', () => {
test('selecting single recommendation adds it to the request', async () => {
await renderCreateMode();
await selectRhel9(); // recommendations are not available for RHEL 10 yet
await goToPackagesStep();
await typeIntoSearchBox('test'); // search for 'test' package
await clickFirstPackageCheckbox(); // select
@ -657,6 +665,7 @@ describe('Packages request generated correctly', () => {
const expectedRequest: CreateBlueprintRequest = {
...blueprintRequest,
distribution: RHEL_9,
customizations: {
packages: expectedSinglePackageRecommendation,
},
@ -667,6 +676,7 @@ describe('Packages request generated correctly', () => {
test('clicking "Add all packages" adds all recommendations to the request', async () => {
await renderCreateMode();
await selectRhel9(); // recommendations are not available for RHEL 10 yet
await goToPackagesStep();
await typeIntoSearchBox('test'); // search for 'test' package
await clickFirstPackageCheckbox(); // select
@ -676,6 +686,7 @@ describe('Packages request generated correctly', () => {
const expectedRequest: CreateBlueprintRequest = {
...blueprintRequest,
distribution: RHEL_9,
customizations: {
packages: expectedAllPackageRecommendations,
},
@ -686,6 +697,7 @@ describe('Packages request generated correctly', () => {
test('deselecting a package recommendation removes it from the request', async () => {
await renderCreateMode();
await selectRhel9(); // recommendations are not available for RHEL 10 yet
await goToPackagesStep();
await typeIntoSearchBox('test'); // search for 'test' package
await clickFirstPackageCheckbox(); // select
@ -697,6 +709,7 @@ describe('Packages request generated correctly', () => {
const expectedRequest: CreateBlueprintRequest = {
...blueprintRequest,
distribution: RHEL_9,
customizations: {
packages: expectedPackagesWithoutRecommendations,
},

View file

@ -6,7 +6,7 @@ import { http, HttpResponse } from 'msw';
import {
CREATE_BLUEPRINT,
EDIT_BLUEPRINT,
RHEL_9,
RHEL_10,
RHSM_API,
} from '../../../../../constants';
import {
@ -268,7 +268,7 @@ describe('Registration request generated correctly', () => {
const blueprintRequest: CreateBlueprintRequest = {
name: 'Red Velvet',
description: '',
distribution: RHEL_9,
distribution: RHEL_10,
image_requests: [imageRequest],
customizations: {},
};

View file

@ -2,7 +2,11 @@ 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, EDIT_BLUEPRINT } from '../../../../../constants';
import {
CREATE_BLUEPRINT,
EDIT_BLUEPRINT,
RHEL_9,
} from '../../../../../constants';
import { mockBlueprintIds } from '../../../../fixtures/blueprints';
import { servicesCreateBlueprintRequest } from '../../../../fixtures/editMode';
import {
@ -15,6 +19,7 @@ import {
interceptEditBlueprintRequest,
renderEditMode,
verifyCancelButton,
selectRhel9,
} from '../../wizardTestUtils';
import { clickRegisterLater, renderCreateMode } from '../../wizardTestUtils';
@ -192,6 +197,7 @@ describe('Step Services', () => {
test('services from OpenSCAP get added correctly and cannot be removed', async () => {
await renderCreateMode();
await selectRhel9();
await goToOpenSCAPStep();
await selectProfile();
await goFromOpenSCAPToServices();
@ -282,6 +288,7 @@ describe('Services request generated correctly', () => {
test('with OpenSCAP profile that includes services', async () => {
await renderCreateMode();
await selectRhel9();
await goToOpenSCAPStep();
await selectProfile();
await goFromOpenSCAPToServices();
@ -290,6 +297,7 @@ describe('Services request generated correctly', () => {
const expectedRequest = {
...blueprintRequest,
distribution: RHEL_9, // overrides default RHEL 10 to make OpenSCAP available
customizations: {
filesystem: [
{