Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wizard: Kernel step basics (HMS-5198) #2685

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/Components/CreateImageWizard/CreateImageWizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { FileSystemContext } from './steps/FileSystem/FileSystemTable';
import FirstBootStep from './steps/FirstBoot';
import HostnameStep from './steps/Hostname';
import ImageOutputStep from './steps/ImageOutput';
import KernelStep from './steps/Kernel';
import LocaleStep from './steps/Locale';
import OscapStep from './steps/Oscap';
import PackagesStep from './steps/Packages';
Expand Down Expand Up @@ -140,6 +141,7 @@ const CreateImageWizard = ({ isEdit }: CreateImageWizardProps) => {
const isTimezoneEnabled = useFlag('image-builder.timezone.enabled');
const isLocaleEnabled = useFlag('image-builder.locale.enabled');
const isHostnameEnabled = useFlag('image-builder.hostname.enabled');
const isKernelEnabled = useFlag('image-builder.kernel.enabled');

// Remove this and all fallthrough logic when snapshotting is enabled in Prod-stable
// =========================TO REMOVE=======================
Expand Down Expand Up @@ -226,7 +228,7 @@ const CreateImageWizard = ({ isEdit }: CreateImageWizardProps) => {

let startIndex = 1; // default index
if (isEdit) {
startIndex = 19;
startIndex = 20;
}

// Duplicating some of the logic from the Wizard component to allow for custom nav items status
Expand Down Expand Up @@ -500,6 +502,18 @@ const CreateImageWizard = ({ isEdit }: CreateImageWizardProps) => {
>
<HostnameStep />
</WizardStep>,
<WizardStep
name="Kernel"
id="wizard-kernel"
key="wizard-kernel"
navItem={customStatusNavItem}
isHidden={!isKernelEnabled}
footer={
<CustomWizardFooter disableNext={false} optional={true} />
}
>
<KernelStep />
</WizardStep>,
<WizardStep
name="First boot script configuration"
id="wizard-first-boot"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';

import { FormGroup } from '@patternfly/react-core';

const KernelArguments = () => {
return <FormGroup isRequired={false} label="Append"></FormGroup>;
};

export default KernelArguments;
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';

import { FormGroup } from '@patternfly/react-core';

const KernelName = () => {
return <FormGroup isRequired={false} label="Name"></FormGroup>;
};

export default KernelName;
21 changes: 21 additions & 0 deletions src/Components/CreateImageWizard/steps/Kernel/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react';

import { Text, Form, Title } from '@patternfly/react-core';

import KernelArguments from './components/KernelArguments';
import KernelName from './components/KernelName';

const KernelStep = () => {
return (
<Form>
<Title headingLevel="h1" size="xl">
Kernel
</Title>
<Text>Customize kernel name and kernel arguments.</Text>
<KernelName />
<KernelArguments />
</Form>
);
};

export default KernelStep;
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const goToDetailsStep = async () => {
await clickNext(); // Timezone
await clickNext(); // Locale
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // First boot script
await clickNext(); // Details
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ const goToReviewStep = async () => {
await clickNext(); // Timezone
await clickNext(); // Locale
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // Details
await enterBlueprintName();
await clickNext(); // Review
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const goToFirstBootStep = async (): Promise<void> => {
await clickNext(); // Timezone
await clickNext(); // Locale
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // First Boot
};

Expand All @@ -72,6 +73,7 @@ const goFromOscapToFirstBoot = async () => {
await clickNext(); // Timezone
await clickNext(); // Locale
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // First boot script
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const goToHostnameStep = async () => {
};

const goToReviewStep = async () => {
await clickNext(); // Kernel
await clickNext(); // First boot script
await clickNext(); // Details
await enterBlueprintName();
Expand Down Expand Up @@ -74,12 +75,12 @@ describe('Step Hostname', () => {
router = undefined;
});

test('clicking Next loads First boot script', async () => {
test('clicking Next loads Kernel', async () => {
await renderCreateMode();
await goToHostnameStep();
await clickNext();
await screen.findByRole('heading', {
name: 'First boot configuration',
name: 'Kernel',
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ const goToReviewStep = async () => {
await clickNext(); // Timezone
await clickNext(); // Locale
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // First boot
await clickNext(); // Details
await enterBlueprintName();
Expand Down
65 changes: 65 additions & 0 deletions src/test/Components/CreateImageWizard/steps/Kernel/Kernel.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import type { Router as RemixRouter } from '@remix-run/router';
import { screen, waitFor } from '@testing-library/react';
import { userEvent } from '@testing-library/user-event';

import {
clickBack,
clickNext,
verifyCancelButton,
} from '../../wizardTestUtils';
import { clickRegisterLater, renderCreateMode } from '../../wizardTestUtils';

let router: RemixRouter | undefined = undefined;

const goToKernelStep = async () => {
const user = userEvent.setup();
const guestImageCheckBox = await screen.findByRole('checkbox', {
name: /virtualization guest image checkbox/i,
});
await waitFor(() => user.click(guestImageCheckBox));
await clickNext(); // Registration
await clickRegisterLater();
await clickNext(); // OpenSCAP
await clickNext(); // File system configuration
await clickNext(); // Snapshots
await clickNext(); // Custom repositories
await clickNext(); // Additional packages
await clickNext(); // Users
await clickNext(); // Timezone
await clickNext(); // Locale
await clickNext(); // Hostname
await clickNext(); // Kernel
};

describe('Step Kernel', () => {
beforeEach(() => {
vi.clearAllMocks();
router = undefined;
});

test('clicking Next loads First boot script', async () => {
await renderCreateMode();
await goToKernelStep();
await clickNext();
await screen.findByRole('heading', {
name: 'First boot configuration',
});
});

test('clicking Back loads Hostname', async () => {
await renderCreateMode();
await goToKernelStep();
await clickBack();
await screen.findByRole('heading', { name: 'Hostname' });
});

test('clicking Cancel loads landing page', async () => {
await renderCreateMode();
await goToKernelStep();
await verifyCancelButton(router);
});
});

// TO DO 'Kernel step' -> 'revisit step button on Review works'
// TO DO 'Kernel request generated correctly'
// TO DO 'Kernel edit mode'
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const goToLocaleStep = async () => {

const goToReviewStep = async () => {
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // First boot
await clickNext(); // Details
await enterBlueprintName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ const goToReviewStep = async () => {
await clickNext(); // Timezone
await clickNext(); // Locale
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // FirstBoot
await clickNext(); // Details
await enterBlueprintName('Oscap test');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const goToReviewStep = async () => {
await clickNext(); // Timezone
await clickNext(); // Locale
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // First Boot
await clickNext(); // Details
await enterBlueprintName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ const goToReviewStep = async () => {
await clickNext(); // Timezone
await clickNext(); // Locale
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // Details
await enterBlueprintName();
await clickNext(); // Review
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const goToReviewStep = async () => {
await clickNext(); // Timezone
await clickNext(); // Locale
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // First Boot
await clickNext(); // Details
await enterBlueprintName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const goToReviewStep = async () => {
await clickNext(); // Timezone
await clickNext(); // Locale
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // First boot script
await clickNext(); // Details
await clickNext(); // Review
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const goToReviewStep = async () => {
await clickNext(); // Timezone
await clickNext(); // Locale
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // First boot script
await enterBlueprintName();
await clickNext(); // Review
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const goToReview = async () => {
await clickNext(); // Timezone
await clickNext(); // Locale
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // FirstBoot
await clickNext(); // Details
await enterBlueprintName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const goToReview = async () => {
await clickNext(); // Timezone
await clickNext(); // Locale
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // FirstBoot
await clickNext(); // Details
await enterBlueprintName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ const goToReview = async () => {
await clickNext(); // Users
await clickNext(); // Timezone
await clickNext(); // Locale
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // FirstBoot
await clickNext(); // Details
await clickNext(); // Hostname
await enterBlueprintName();
await clickNext(); // Review
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const goToTimezoneStep = async () => {
const goToReviewStep = async () => {
await clickNext(); // Locale
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // First boot script
await clickNext(); // Details
await enterBlueprintName();
Expand Down
2 changes: 2 additions & 0 deletions src/test/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ vi.mock('@unleash/proxy-client-react', () => ({
return true;
case 'image-builder.hostname.enabled':
return true;
case 'image-builder.kernel.enabled':
return true;
case 'edgeParity.image-list':
return true;
case 'image-builder.edge.local-image-table':
Expand Down
Loading