Skip to content

Commit

Permalink
Wizard: Add unleash flag and update tests
Browse files Browse the repository at this point in the history
This gates the step behind an unleash flag and updates the existing tests so they pass with the new step added.
  • Loading branch information
regexowl authored and lucasgarfield committed Jan 14, 2025
1 parent e6bc0d4 commit 3167eff
Show file tree
Hide file tree
Showing 22 changed files with 112 additions and 5 deletions.
11 changes: 8 additions & 3 deletions src/Components/CreateImageWizard/CreateImageWizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { useNavigate, useSearchParams } from 'react-router-dom';
import DetailsStep from './steps/Details';
import FileSystemStep from './steps/FileSystem';
import { FileSystemContext } from './steps/FileSystem/FileSystemTable';
import FirewallStep from './steps/Firewall';
import FirstBootStep from './steps/FirstBoot';
import HostnameStep from './steps/Hostname';
import ImageOutputStep from './steps/ImageOutput';
Expand Down Expand Up @@ -142,6 +143,7 @@ const CreateImageWizard = ({ isEdit }: CreateImageWizardProps) => {
const isLocaleEnabled = useFlag('image-builder.locale.enabled');
const isHostnameEnabled = useFlag('image-builder.hostname.enabled');
const isKernelEnabled = useFlag('image-builder.kernel.enabled');
const isFirewallEnabled = useFlag('image-builder.firewall.enabled');

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

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

// Duplicating some of the logic from the Wizard component to allow for custom nav items status
Expand Down Expand Up @@ -518,11 +520,14 @@ const CreateImageWizard = ({ isEdit }: CreateImageWizardProps) => {
name="Firewall"
id="wizard-firewall"
key="wizard-firewall"
isHidden={true}
navItem={customStatusNavItem}
isHidden={!isFirewallEnabled}
footer={
<CustomWizardFooter disableNext={false} optional={true} />
}
></WizardStep>,
>
<FirewallStep />
</WizardStep>,
<WizardStep
name="First boot script configuration"
id="wizard-first-boot"
Expand Down
16 changes: 16 additions & 0 deletions src/Components/CreateImageWizard/steps/Firewall/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';

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

const FirewallStep = () => {
return (
<Form>
<Title headingLevel="h1" size="xl">
Firewall
</Title>
<Text>Customize firewall settings for your image.</Text>
</Form>
);
};

export default FirewallStep;
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const goToDetailsStep = async () => {
await clickNext(); // Locale
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // Firewall
await clickNext(); // First boot script
await clickNext(); // Details
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ const goToReviewStep = async () => {
await clickNext(); // Locale
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // Firewall
await clickNext(); // Details
await enterBlueprintName();
await clickNext(); // Review
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
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 goToFirewallStep = 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
await clickNext(); // Firewall
};

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

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

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

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

// TO DO Step Firewall -> revisit step button on Review works
// TO DO Firewall request generated correctly
// TO DO Firewall edit mode
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const goToFirstBootStep = async (): Promise<void> => {
await clickNext(); // Locale
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // Firewall
await clickNext(); // First Boot
};

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

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

const goToReviewStep = async () => {
await clickNext(); // Kernel
await clickNext(); // Firewall
await clickNext(); // First boot script
await clickNext(); // Details
await enterBlueprintName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ const goToReviewStep = async () => {
await clickNext(); // Locale
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // Firewall
await clickNext(); // First boot
await clickNext(); // Details
await enterBlueprintName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ describe('Step Kernel', () => {
router = undefined;
});

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const goToLocaleStep = async () => {
const goToReviewStep = async () => {
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // Firewall
await clickNext(); // First boot
await clickNext(); // Details
await enterBlueprintName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ const goToReviewStep = async () => {
await clickNext(); // Locale
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // Firewall
await clickNext(); // FirstBoot
await clickNext(); // Details
await enterBlueprintName('Oscap test');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const goToReviewStep = async () => {
await clickNext(); // Locale
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // Firewall
await clickNext(); // First Boot
await clickNext(); // Details
await enterBlueprintName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ const goToReviewStep = async () => {
await clickNext(); // Locale
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // Firewall
await clickNext(); // Details
await enterBlueprintName();
await clickNext(); // Review
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const goToReviewStep = async () => {
await clickNext(); // Locale
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // Firewall
await clickNext(); // First Boot
await clickNext(); // Details
await enterBlueprintName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const goToReviewStep = async () => {
await clickNext(); // Locale
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // Firewall
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 @@ -42,6 +42,7 @@ const goToReviewStep = async () => {
await clickNext(); // Locale
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // Firewall
await clickNext(); // First boot script
await enterBlueprintName();
await clickNext(); // Review
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const goToReview = async () => {
await clickNext(); // Locale
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // Firewall
await clickNext(); // FirstBoot
await clickNext(); // Details
await enterBlueprintName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const goToReview = async () => {
await clickNext(); // Locale
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // Firewall
await clickNext(); // FirstBoot
await clickNext(); // Details
await enterBlueprintName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const goToReview = async () => {
await clickNext(); // Locale
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // Firewall
await clickNext(); // FirstBoot
await clickNext(); // Details
await enterBlueprintName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const goToReviewStep = async () => {
await clickNext(); // Locale
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // Firewall
await clickNext(); // First boot script
await clickNext(); // Details
await enterBlueprintName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const goToReviewStep = async () => {
await clickNext(); // Locale
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // Firewall
await clickNext(); // First boot
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 @@ -73,6 +73,8 @@ vi.mock('@unleash/proxy-client-react', () => ({
return true;
case 'image-builder.kernel.enabled':
return true;
case 'image-builder.firewall.enabled':
return true;
case 'edgeParity.image-list':
return true;
case 'image-builder.edge.local-image-table':
Expand Down

0 comments on commit 3167eff

Please sign in to comment.