From 176c64dd47dddf13c9b89c30ba9478da351a947b Mon Sep 17 00:00:00 2001 From: Michal Gold Date: Tue, 29 Oct 2024 14:39:36 +0200 Subject: [PATCH] Wizard: Add `Users` step to the wizard (HMS-4902) This commit adds a new step 'Users' that is enabled only in stage-preview, and will enable it in stage-stable once IQE tests are ready. The step is not functional yet, this is just the first step. --- .../CreateImageWizard/CreateImageWizard.tsx | 16 ++++++++++- .../steps/Users/component/Empty.tsx | 28 +++++++++++++++++++ .../CreateImageWizard/steps/Users/index.tsx | 19 +++++++++++++ .../steps/Details/Details.test.tsx | 1 + .../FileSystemConfiguration.test.tsx | 1 + .../steps/FirstBoot/Firstboot.test.tsx | 2 ++ .../steps/ImageOutput/ImageOutput.test.tsx | 1 + .../steps/Oscap/Oscap.test.tsx | 1 + .../steps/Packages/Packages.test.tsx | 2 ++ .../steps/Registration/Registration.test.tsx | 1 + .../steps/Repositories/Repositories.test.tsx | 1 + .../steps/Review/Review.test.tsx | 1 + .../steps/Snapshot/Snapshot.test.tsx | 1 + .../TargetEnvironment/AwsTarget.test.tsx | 1 + .../TargetEnvironment/AzureTarget.test.tsx | 1 + .../TargetEnvironment/GCPTarget.test.tsx | 1 + src/test/setup.ts | 2 ++ 17 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 src/Components/CreateImageWizard/steps/Users/component/Empty.tsx create mode 100644 src/Components/CreateImageWizard/steps/Users/index.tsx diff --git a/src/Components/CreateImageWizard/CreateImageWizard.tsx b/src/Components/CreateImageWizard/CreateImageWizard.tsx index b367fe4bf..204133306 100644 --- a/src/Components/CreateImageWizard/CreateImageWizard.tsx +++ b/src/Components/CreateImageWizard/CreateImageWizard.tsx @@ -27,6 +27,7 @@ import SnapshotStep from './steps/Snapshot'; import Aws from './steps/TargetEnvironment/Aws'; import Azure from './steps/TargetEnvironment/Azure'; import Gcp from './steps/TargetEnvironment/Gcp'; +import UsersStep from './steps/Users'; import { useFilesystemValidation, useSnapshotValidation, @@ -132,6 +133,8 @@ const CreateImageWizard = ({ isEdit }: CreateImageWizardProps) => { const [searchParams] = useSearchParams(); const { isBeta } = useGetEnvironment(); + const isUsersEnabled = useFlag('image-builder.users.enabled'); + // Remove this and all fallthrough logic when snapshotting is enabled in Prod-stable // =========================TO REMOVE======================= const { data, isSuccess, isFetching, isError } = @@ -211,7 +214,7 @@ const CreateImageWizard = ({ isEdit }: CreateImageWizardProps) => { let startIndex = 1; // default index if (isEdit) { - startIndex = 15; + startIndex = 16; } // Duplicating some of the logic from the Wizard component to allow for custom nav items status @@ -432,6 +435,17 @@ const CreateImageWizard = ({ isEdit }: CreateImageWizardProps) => { > , + + } + > + + , { + return ( + + } + headingLevel="h4" + /> + + + + + ); +}; +export default EmptyUserState; diff --git a/src/Components/CreateImageWizard/steps/Users/index.tsx b/src/Components/CreateImageWizard/steps/Users/index.tsx new file mode 100644 index 000000000..c2a62a234 --- /dev/null +++ b/src/Components/CreateImageWizard/steps/Users/index.tsx @@ -0,0 +1,19 @@ +import React from 'react'; + +import { Form, Text, Title } from '@patternfly/react-core'; + +import EmptyUserState from './component/Empty'; + +const UsersStep = () => { + return ( +
+ + Users + + Add a user to your image. + + + ); +}; + +export default UsersStep; diff --git a/src/test/Components/CreateImageWizard/steps/Details/Details.test.tsx b/src/test/Components/CreateImageWizard/steps/Details/Details.test.tsx index 7c03f08a3..c06454bde 100644 --- a/src/test/Components/CreateImageWizard/steps/Details/Details.test.tsx +++ b/src/test/Components/CreateImageWizard/steps/Details/Details.test.tsx @@ -25,6 +25,7 @@ const goToDetailsStep = async () => { await clickNext(); await clickNext(); await clickNext(); + await clickNext(); }; const enterBlueprintDescription = async ( diff --git a/src/test/Components/CreateImageWizard/steps/FileSystemConfiguration/FileSystemConfiguration.test.tsx b/src/test/Components/CreateImageWizard/steps/FileSystemConfiguration/FileSystemConfiguration.test.tsx index eef2cdf65..c29770d74 100644 --- a/src/test/Components/CreateImageWizard/steps/FileSystemConfiguration/FileSystemConfiguration.test.tsx +++ b/src/test/Components/CreateImageWizard/steps/FileSystemConfiguration/FileSystemConfiguration.test.tsx @@ -113,6 +113,7 @@ const goToReviewStep = async () => { await clickNext(); await clickNext(); await clickNext(); + await clickNext(); await enterBlueprintName(); await clickNext(); }; diff --git a/src/test/Components/CreateImageWizard/steps/FirstBoot/Firstboot.test.tsx b/src/test/Components/CreateImageWizard/steps/FirstBoot/Firstboot.test.tsx index 2c0dcb237..a02bef952 100644 --- a/src/test/Components/CreateImageWizard/steps/FirstBoot/Firstboot.test.tsx +++ b/src/test/Components/CreateImageWizard/steps/FirstBoot/Firstboot.test.tsx @@ -43,6 +43,7 @@ const goToFirstBootStep = async (): Promise => { await clickNext(); // File System await clickNext(); // Custom repositories await clickNext(); // Additional packages + await clickNext(); // Users await clickNext(); // Snapshot await clickNext(); // First Boot }; @@ -64,6 +65,7 @@ const goFromOscapToFirstBoot = async () => { await clickNext(); await clickNext(); await clickNext(); + await clickNext(); }; const openCodeEditor = async (): Promise => { diff --git a/src/test/Components/CreateImageWizard/steps/ImageOutput/ImageOutput.test.tsx b/src/test/Components/CreateImageWizard/steps/ImageOutput/ImageOutput.test.tsx index 4948427b1..83ca9bd60 100644 --- a/src/test/Components/CreateImageWizard/steps/ImageOutput/ImageOutput.test.tsx +++ b/src/test/Components/CreateImageWizard/steps/ImageOutput/ImageOutput.test.tsx @@ -135,6 +135,7 @@ const goToReviewStep = async () => { await clickNext(); // Snapshots await clickNext(); // Custom repositories await clickNext(); // Additional packages + await clickNext(); // Users await clickNext(); // First boot await clickNext(); // Details await enterBlueprintName(); diff --git a/src/test/Components/CreateImageWizard/steps/Oscap/Oscap.test.tsx b/src/test/Components/CreateImageWizard/steps/Oscap/Oscap.test.tsx index 8928ebb09..33b491025 100644 --- a/src/test/Components/CreateImageWizard/steps/Oscap/Oscap.test.tsx +++ b/src/test/Components/CreateImageWizard/steps/Oscap/Oscap.test.tsx @@ -98,6 +98,7 @@ const goToReviewStep = async () => { await clickNext(); // Snapshot repositories await clickNext(); // Custom repositories await clickNext(); // Additional packages + await clickNext(); // Users await clickNext(); // FirstBoot await clickNext(); // Details await enterBlueprintName('Oscap test'); diff --git a/src/test/Components/CreateImageWizard/steps/Packages/Packages.test.tsx b/src/test/Components/CreateImageWizard/steps/Packages/Packages.test.tsx index 33b0d2fa4..0df0b5d05 100644 --- a/src/test/Components/CreateImageWizard/steps/Packages/Packages.test.tsx +++ b/src/test/Components/CreateImageWizard/steps/Packages/Packages.test.tsx @@ -52,6 +52,7 @@ const goToPackagesStep = async () => { }; const goToReviewStep = async () => { + await clickNext(); // Users await clickNext(); // First Boot await clickNext(); // Details await enterBlueprintName(); @@ -177,6 +178,7 @@ describe('Step Packages', () => { await renderCreateMode(); await goToPackagesStep(); await clickNext(); + await clickNext(); await screen.findByRole('heading', { name: 'First boot configuration', }); diff --git a/src/test/Components/CreateImageWizard/steps/Registration/Registration.test.tsx b/src/test/Components/CreateImageWizard/steps/Registration/Registration.test.tsx index a512763bb..483c40cf6 100644 --- a/src/test/Components/CreateImageWizard/steps/Registration/Registration.test.tsx +++ b/src/test/Components/CreateImageWizard/steps/Registration/Registration.test.tsx @@ -96,6 +96,7 @@ const goToReviewStep = async () => { await clickNext(); await clickNext(); await clickNext(); + await clickNext(); await enterBlueprintName(); await clickNext(); }; diff --git a/src/test/Components/CreateImageWizard/steps/Repositories/Repositories.test.tsx b/src/test/Components/CreateImageWizard/steps/Repositories/Repositories.test.tsx index 628f54346..da9f84831 100644 --- a/src/test/Components/CreateImageWizard/steps/Repositories/Repositories.test.tsx +++ b/src/test/Components/CreateImageWizard/steps/Repositories/Repositories.test.tsx @@ -46,6 +46,7 @@ const goToRepositoriesStep = async () => { const goToReviewStep = async () => { await clickNext(); // Additional packages await clickNext(); + await clickNext(); // Users await clickNext(); // First Boot await enterBlueprintName(); await clickNext(); // Review diff --git a/src/test/Components/CreateImageWizard/steps/Review/Review.test.tsx b/src/test/Components/CreateImageWizard/steps/Review/Review.test.tsx index 25e4b9652..2dea7bc54 100644 --- a/src/test/Components/CreateImageWizard/steps/Review/Review.test.tsx +++ b/src/test/Components/CreateImageWizard/steps/Review/Review.test.tsx @@ -56,6 +56,7 @@ const goToReviewStep = async () => { await clickNext(); await clickNext(); await clickNext(); + await clickNext(); }; describe('Step Review', () => { diff --git a/src/test/Components/CreateImageWizard/steps/Snapshot/Snapshot.test.tsx b/src/test/Components/CreateImageWizard/steps/Snapshot/Snapshot.test.tsx index 63aaa698c..a6a5c2be9 100644 --- a/src/test/Components/CreateImageWizard/steps/Snapshot/Snapshot.test.tsx +++ b/src/test/Components/CreateImageWizard/steps/Snapshot/Snapshot.test.tsx @@ -38,6 +38,7 @@ const goToReviewStep = async () => { await clickNext(); // Repositories step await clickNext(); // Additional packages await clickNext(); + await clickNext(); // Users await enterBlueprintName(); await clickNext(); }; diff --git a/src/test/Components/CreateImageWizard/steps/TargetEnvironment/AwsTarget.test.tsx b/src/test/Components/CreateImageWizard/steps/TargetEnvironment/AwsTarget.test.tsx index 852f8f468..7b3652885 100644 --- a/src/test/Components/CreateImageWizard/steps/TargetEnvironment/AwsTarget.test.tsx +++ b/src/test/Components/CreateImageWizard/steps/TargetEnvironment/AwsTarget.test.tsx @@ -44,6 +44,7 @@ const goToReview = async () => { await clickNext(); // Snapshot repositories await clickNext(); // Custom repositories await clickNext(); // Additional packages + await clickNext(); // Users await clickNext(); // Details await clickNext(); // FirstBoot await enterBlueprintName(); diff --git a/src/test/Components/CreateImageWizard/steps/TargetEnvironment/AzureTarget.test.tsx b/src/test/Components/CreateImageWizard/steps/TargetEnvironment/AzureTarget.test.tsx index c8e618613..576013137 100644 --- a/src/test/Components/CreateImageWizard/steps/TargetEnvironment/AzureTarget.test.tsx +++ b/src/test/Components/CreateImageWizard/steps/TargetEnvironment/AzureTarget.test.tsx @@ -44,6 +44,7 @@ const goToReview = async () => { await clickNext(); // Snapshot repositories await clickNext(); // Custom repositories await clickNext(); // Additional packages + await clickNext(); // Users await clickNext(); // FirstBoot await clickNext(); // Details await enterBlueprintName(); diff --git a/src/test/Components/CreateImageWizard/steps/TargetEnvironment/GCPTarget.test.tsx b/src/test/Components/CreateImageWizard/steps/TargetEnvironment/GCPTarget.test.tsx index f9de68f9a..28c274aae 100644 --- a/src/test/Components/CreateImageWizard/steps/TargetEnvironment/GCPTarget.test.tsx +++ b/src/test/Components/CreateImageWizard/steps/TargetEnvironment/GCPTarget.test.tsx @@ -39,6 +39,7 @@ const goToReview = async () => { await clickNext(); // Snapshot repositories await clickNext(); // Custom repositories await clickNext(); // Additional packages + await clickNext(); // Users await clickNext(); // Details await clickNext(); // FirstBoot await enterBlueprintName(); diff --git a/src/test/setup.ts b/src/test/setup.ts index 8442b8570..ca52b7332 100644 --- a/src/test/setup.ts +++ b/src/test/setup.ts @@ -53,6 +53,8 @@ vi.mock('@unleash/proxy-client-react', () => ({ useUnleashContext: () => vi.fn(), useFlag: vi.fn((flag) => { switch (flag) { + case 'image-builder.users.enabled': + return true; case 'image-builder.import.enabled': return true; case 'image-builder.firstboot.enabled':