Skip to content

Commit 9ee549f

Browse files
committed
wizard: add users to review step (HMS-4906)
1 parent 8214285 commit 9ee549f

File tree

3 files changed

+76
-1
lines changed

3 files changed

+76
-1
lines changed

src/Components/CreateImageWizard/steps/Review/ReviewStep.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
TargetEnvGCPList,
2929
TargetEnvOciList,
3030
TargetEnvOtherList,
31+
UsersList,
3132
TimezoneList,
3233
LocaleList,
3334
HostnameList,
@@ -73,6 +74,7 @@ const Review = ({ snapshottingEnabled }: { snapshottingEnabled: boolean }) => {
7374
const [isExpandedLocale, setIsExpandedLocale] = useState(true);
7475
const [isExpandedHostname, setIsExpandedHostname] = useState(true);
7576
const [isExpandableFirstBoot, setIsExpandedFirstBoot] = useState(true);
77+
const [isExpandedUsers, setIsExpandedUsers] = useState(true);
7678

7779
const isTimezoneEnabled = useFlag('image-builder.timezone.enabled');
7880
const isLocaleEnabled = useFlag('image-builder.locale.enabled');
@@ -102,6 +104,8 @@ const Review = ({ snapshottingEnabled }: { snapshottingEnabled: boolean }) => {
102104
setIsExpandedHostname(isExpandedHostname);
103105
const onToggleFirstBoot = (isExpandableFirstBoot: boolean) =>
104106
setIsExpandedFirstBoot(isExpandableFirstBoot);
107+
const onToggleUsers = (isExpandedUsers: boolean) =>
108+
setIsExpandedUsers(isExpandedUsers);
105109

106110
type RevisitStepButtonProps = {
107111
ariaLabel: string;
@@ -158,6 +162,7 @@ const Review = ({ snapshottingEnabled }: { snapshottingEnabled: boolean }) => {
158162
};
159163

160164
const isFirstBootEnabled = useFlag('image-builder.firstboot.enabled');
165+
const isUsersEnabled = useFlag('image-builder.users.enabled');
161166
return (
162167
<>
163168
<ExpandableSection
@@ -314,6 +319,21 @@ const Review = ({ snapshottingEnabled }: { snapshottingEnabled: boolean }) => {
314319
{/* Intentional prop drilling for simplicity - To be removed */}
315320
<ContentList snapshottingEnabled={snapshottingEnabled} />
316321
</ExpandableSection>
322+
{isUsersEnabled && (
323+
<ExpandableSection
324+
toggleContent={composeExpandable(
325+
'Users',
326+
'revisit-users',
327+
'wizard-users'
328+
)}
329+
onToggle={(_event, isExpandedUsers) => onToggleUsers(isExpandedUsers)}
330+
isExpanded={isExpandedUsers}
331+
isIndented
332+
data-testid="users-expandable"
333+
>
334+
<UsersList />
335+
</ExpandableSection>
336+
)}
317337
{isTimezoneEnabled && (
318338
<ExpandableSection
319339
toggleContent={composeExpandable(

src/Components/CreateImageWizard/steps/Review/ReviewStepTextLists.tsx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ import {
6868
selectLanguages,
6969
selectKeyboard,
7070
selectHostname,
71+
selectUserNameByIndex,
72+
selectUserPasswordByIndex,
7173
} from '../../../../store/wizardSlice';
7274
import { toMonthAndYear, yyyyMMddFormat } from '../../../../Utilities/time';
7375
import {
@@ -774,6 +776,41 @@ export const TimezoneList = () => {
774776
);
775777
};
776778

779+
export const UsersList = () => {
780+
const index = 0;
781+
const userNameSelector = selectUserNameByIndex(index);
782+
const userName = useAppSelector(userNameSelector);
783+
const userPasswordSelector = selectUserPasswordByIndex(index);
784+
const userPassword = useAppSelector(userPasswordSelector);
785+
786+
return (
787+
<TextContent>
788+
<TextList component={TextListVariants.dl}>
789+
<>
790+
<TextListItem
791+
component={TextListItemVariants.dt}
792+
className="pf-v5-u-min-width"
793+
>
794+
Username
795+
</TextListItem>
796+
<TextListItem component={TextListItemVariants.dd}>
797+
{userName ? userName : 'None'}
798+
</TextListItem>
799+
<TextListItem
800+
component={TextListItemVariants.dt}
801+
className="pf-v5-u-min-width"
802+
>
803+
Password
804+
</TextListItem>
805+
<TextListItem component={TextListItemVariants.dd}>
806+
{userPassword ? userPassword : 'None'}
807+
</TextListItem>
808+
</>
809+
</TextList>
810+
</TextContent>
811+
);
812+
};
813+
777814
export const LocaleList = () => {
778815
const languages = useAppSelector(selectLanguages);
779816
const keyboard = useAppSelector(selectKeyboard);

src/test/Components/CreateImageWizard/steps/Users/Users.test.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Router as RemixRouter } from '@remix-run/router';
2-
import { screen, waitFor } from '@testing-library/react';
2+
import { screen, waitFor, within } from '@testing-library/react';
33
import { userEvent } from '@testing-library/user-event';
44

55
import { CREATE_BLUEPRINT, EDIT_BLUEPRINT } from '../../../../../constants';
@@ -45,6 +45,13 @@ const goToReviewStep = async () => {
4545
await clickNext(); // Review
4646
};
4747

48+
const clickRevisitButton = async () => {
49+
const user = userEvent.setup();
50+
const expandable = await screen.findByTestId('users-expandable');
51+
const revisitButton = await within(expandable).findByTestId('revisit-users');
52+
await waitFor(() => user.click(revisitButton));
53+
};
54+
4855
const addValidUser = async () => {
4956
const user = userEvent.setup();
5057
const addUser = await screen.findByRole('button', { name: /add a user/i });
@@ -92,6 +99,17 @@ describe('Step Users', () => {
9299
await verifyCancelButton(router);
93100
});
94101

102+
test('revisit step button on Review works', async () => {
103+
await renderCreateMode();
104+
await goToRegistrationStep();
105+
await clickRegisterLater();
106+
await goToUsersStep();
107+
await addValidUser();
108+
await goToReviewStep();
109+
await clickRevisitButton();
110+
await screen.findByRole('heading', { name: /Users/ });
111+
});
112+
95113
describe('User request generated correctly', () => {
96114
test('with valid name and password', async () => {
97115
await renderCreateMode();

0 commit comments

Comments
 (0)