Skip to content

Commit

Permalink
Wizard: Add kernel to Review step
Browse files Browse the repository at this point in the history
This adds a kernel expandable to the Review step.
  • Loading branch information
regexowl committed Jan 21, 2025
1 parent 25f1240 commit d788baa
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 2 deletions.
22 changes: 22 additions & 0 deletions src/Components/CreateImageWizard/steps/Review/ReviewStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
TimezoneList,
LocaleList,
HostnameList,
KernelList,
} from './ReviewStepTextLists';

import isRhel from '../../../../../src/Utilities/isRhel';
Expand Down Expand Up @@ -83,12 +84,14 @@ const Review = ({ snapshottingEnabled }: { snapshottingEnabled: boolean }) => {
const [isExpandedTimezone, setIsExpandedTimezone] = useState(true);
const [isExpandedLocale, setIsExpandedLocale] = useState(true);
const [isExpandedHostname, setIsExpandedHostname] = useState(true);
const [isExpandedKernel, setIsExpandedKernel] = useState(true);
const [isExpandableFirstBoot, setIsExpandedFirstBoot] = useState(true);
const [isExpandedUsers, setIsExpandedUsers] = useState(true);

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');

const onToggleImageOutput = (isExpandedImageOutput: boolean) =>
setIsExpandedImageOutput(isExpandedImageOutput);
Expand All @@ -112,6 +115,8 @@ const Review = ({ snapshottingEnabled }: { snapshottingEnabled: boolean }) => {
setIsExpandedLocale(isExpandedLocale);
const onToggleHostname = (isExpandedHostname: boolean) =>
setIsExpandedHostname(isExpandedHostname);
const onToggleKernel = (isExpandedKernel: boolean) =>
setIsExpandedKernel(isExpandedKernel);
const onToggleFirstBoot = (isExpandableFirstBoot: boolean) =>
setIsExpandedFirstBoot(isExpandableFirstBoot);
const onToggleUsers = (isExpandedUsers: boolean) =>
Expand Down Expand Up @@ -398,6 +403,23 @@ const Review = ({ snapshottingEnabled }: { snapshottingEnabled: boolean }) => {
<HostnameList />
</ExpandableSection>
)}
{isKernelEnabled && (
<ExpandableSection
toggleContent={composeExpandable(
'Kernel',
'revisit-kernel',
'wizard-kernel'
)}
onToggle={(_event, isExpandedKernel) =>
onToggleKernel(isExpandedKernel)
}
isExpanded={isExpandedKernel}
isIndented
data-testid="kernel-expandable"
>
<KernelList />
</ExpandableSection>
)}
{isFirstBootEnabled && (
<ExpandableSection
toggleContent={composeExpandable(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ import {
selectUserNameByIndex,
selectUserPasswordByIndex,
selectUserSshKeyByIndex,
selectKernel,
} from '../../../../store/wizardSlice';
import { toMonthAndYear, yyyyMMddFormat } from '../../../../Utilities/time';
import {
Expand Down Expand Up @@ -875,6 +876,35 @@ export const HostnameList = () => {
);
};

export const KernelList = () => {
const kernel = useAppSelector(selectKernel);

return (
<TextContent>
<TextList component={TextListVariants.dl}>
<TextListItem
component={TextListItemVariants.dt}
className="pf-v5-u-min-width"
>
Name
</TextListItem>
<TextListItem component={TextListItemVariants.dd}>
{kernel.name ? kernel.name : 'None'}
</TextListItem>
<TextListItem
component={TextListItemVariants.dt}
className="pf-v5-u-min-width"
>
Append
</TextListItem>
<TextListItem component={TextListItemVariants.dd}>
{kernel.append ? kernel.append : 'None'}
</TextListItem>
</TextList>
</TextContent>
);
};

export const FirstBootList = () => {
const isFirstbootEnabled = !!useAppSelector(selectFirstBootScript);

Expand Down
19 changes: 17 additions & 2 deletions src/test/Components/CreateImageWizard/steps/Kernel/Kernel.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Router as RemixRouter } from '@remix-run/router';
import { screen, waitFor } from '@testing-library/react';
import { screen, waitFor, within } from '@testing-library/react';
import { userEvent } from '@testing-library/user-event';

import { CREATE_BLUEPRINT } from '../../../../../constants';
Expand Down Expand Up @@ -82,6 +82,13 @@ const clearKernelName = async () => {
await waitFor(() => user.click(kernelNameClearBtn));
};

const clickRevisitButton = async () => {
const user = userEvent.setup();
const expandable = await screen.findByTestId('kernel-expandable');
const revisitButton = await within(expandable).findByTestId('revisit-kernel');
await waitFor(() => user.click(revisitButton));
};

describe('Step Kernel', () => {
beforeEach(() => {
vi.clearAllMocks();
Expand Down Expand Up @@ -136,6 +143,15 @@ describe('Step Kernel', () => {
expect(screen.queryByText(/Invalid format/)).not.toBeInTheDocument();
expect(nextButton).toBeEnabled();
});

test('revisit step button on Review works', async () => {
await renderCreateMode();
await goToKernelStep();
await selectKernelName('kernel');
await goToReviewStep();
await clickRevisitButton();
await screen.findByRole('heading', { name: /Kernel/ });
});
});

describe('Kernel request generated correctly', () => {
Expand Down Expand Up @@ -185,7 +201,6 @@ describe('Kernel request generated correctly', () => {
});
});

// TO DO 'Kernel step' -> 'revisit step button on Review works'
// TO DO 'Kernel request generated correctly' -> 'with valid kernel append'
// TO DO 'Kernel request generated correctly' -> 'with valid kernel name and kernel append'
// TO DO 'Kernel edit mode'

0 comments on commit d788baa

Please sign in to comment.