test/CreateImageWizard: add basic render for cockpit tests

This commit is contained in:
Sanne Raymaekers 2025-02-06 14:03:00 +01:00 committed by Klara Simickova
parent 73afbc2b51
commit d10620cc56
4 changed files with 31 additions and 10 deletions

View file

@ -103,7 +103,7 @@
"test": "TZ=UTC vitest run",
"test:watch": "TZ=UTC vitest",
"test:coverage": "TZ=UTC vitest run --coverage",
"test:cockpit": "TZ=UTC IS_ON_PREMISE=true vitest run -t 'Images Table render ImagesTable'",
"test:cockpit": "src/test/cockpit-tests.sh",
"build": "fec build",
"build:cockpit": "webpack --config cockpit/webpack.config.ts",
"api": "npm-run-all api:pull api:generate",

View file

@ -45,17 +45,25 @@ describe('Create Image Wizard', () => {
// check navigation
await screen.findByRole('button', { name: 'Image output' });
await screen.findByRole('button', { name: 'Optional steps' });
await screen.findByRole('button', { name: 'Register' });
await screen.findByRole('button', { name: 'OpenSCAP' });
await screen.findByRole('button', { name: 'File system configuration' });
await screen.findByRole('button', { name: 'Repository snapshot' });
await screen.findByRole('button', { name: 'Custom repositories' });
await screen.findByRole('button', { name: 'Additional packages' });
await screen.findByRole('button', {
name: 'First boot script configuration',
});
await screen.findByRole('button', { name: 'Users' });
await screen.findByRole('button', { name: 'Timezone' });
await screen.findByRole('button', { name: 'Hostname' });
await screen.findByRole('button', { name: 'Kernel' });
await screen.findByRole('button', { name: 'Firewall' });
await screen.findByRole('button', { name: 'Systemd services' });
await screen.findByRole('button', { name: 'Details' });
await screen.findByRole('button', { name: 'Review' });
if (!process.env.IS_ON_PREMISE) {
await screen.findByRole('button', { name: 'Register' });
await screen.findByRole('button', { name: 'OpenSCAP' });
await screen.findByRole('button', { name: 'Repository snapshot' });
await screen.findByRole('button', { name: 'Custom repositories' });
await screen.findByRole('button', {
name: 'First boot script configuration',
});
}
});
});

View file

@ -40,6 +40,10 @@ const routes = [
path: 'insights/image-builder/imagewizard/:composeId?',
element: <ImageWizard />,
},
{
path: '/imageWizard',
element: <ImageWizard />,
},
];
export const imageRequest: ImageRequest = {
@ -64,11 +68,11 @@ export const blueprintRequest: CreateBlueprintRequest = {
* // returns 'imageWizard?release=rhel8&architecture=aarch64'
* preparePathname({ release: 'rhel8', architecture: 'aarch64' });
* @example
* // returns 'imageWizard'
* // returns '(/)imageWizard'
* preparePathname({});
*/
function preparePathname(searchParams: { [key: string]: string } = {}): string {
let pathName = 'imageWizard';
let pathName = process.env.IS_ON_PREMISE ? '/imageWizard' : 'imageWizard';
const params = Object.entries(searchParams).map(
([param, value]) => `${param}=${value}`
);

9
src/test/cockpit-tests.sh Executable file
View file

@ -0,0 +1,9 @@
#!/bin/bash
export TZ=UTC IS_ON_PREMISE=true
vitest run -t 'Images Table render ImagesTable' \
src/test/Components/ImagesTable/ImagesTable.test.tsx
vitest run -t 'Create Image Wizard renders component' \
src/test/Components/CreateImageWizard/CreateImageWizard.test.tsx