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: Services step basics (HMS-5372) #2785

Merged
merged 1 commit into from
Jan 23, 2025
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 @@ -27,6 +27,7 @@ import RegistrationStep from './steps/Registration';
import RepositoriesStep from './steps/Repositories';
import ReviewStep from './steps/Review';
import ReviewWizardFooter from './steps/Review/Footer/Footer';
import ServicesStep from './steps/Services';
import SnapshotStep from './steps/Snapshot';
import Aws from './steps/TargetEnvironment/Aws';
import Azure from './steps/TargetEnvironment/Azure';
Expand Down Expand Up @@ -146,6 +147,7 @@ const CreateImageWizard = ({ isEdit }: CreateImageWizardProps) => {
const isHostnameEnabled = useFlag('image-builder.hostname.enabled');
const isKernelEnabled = useFlag('image-builder.kernel.enabled');
const isFirewallEnabled = useFlag('image-builder.firewall.enabled');
const isServicesStepEnabled = useFlag('image-builder.services.enabled');

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

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

// Duplicating some of the logic from the Wizard component to allow for custom nav items status
Expand Down Expand Up @@ -541,6 +543,18 @@ const CreateImageWizard = ({ isEdit }: CreateImageWizardProps) => {
>
<FirewallStep />
</WizardStep>,
<WizardStep
name="Systemd services"
id="wizard-services"
key="wizard-services"
navItem={customStatusNavItem}
isHidden={!isServicesStepEnabled}
footer={
<CustomWizardFooter disableNext={false} optional={true} />
}
>
<ServicesStep />
</WizardStep>,
<WizardStep
name="First boot script configuration"
id="wizard-first-boot"
Expand Down
16 changes: 16 additions & 0 deletions src/Components/CreateImageWizard/steps/Services/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 ServicesStep = () => {
return (
<Form>
<Title headingLevel="h1" size="xl">
Systemd services
</Title>
<Text>Enable and disable systemd services.</Text>
</Form>
);
};

export default ServicesStep;
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const goToDetailsStep = async () => {
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // Firewall
await clickNext(); // Services
await clickNext(); // First boot script
await clickNext(); // Details
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ const goToReviewStep = async () => {
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // Firewall
await clickNext(); // Services
await clickNext(); // Details
await enterBlueprintName();
await clickNext(); // Review
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const goToFirewallStep = async () => {
};

const goToReviewStep = async () => {
await clickNext(); // Services
await clickNext(); // First boot script
await clickNext(); // Details
await enterBlueprintName();
Expand All @@ -56,12 +57,12 @@ describe('Step Firewall', () => {
router = undefined;
});

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const goToFirstBootStep = async (): Promise<void> => {
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // Firewall
await clickNext(); // Services
await clickNext(); // First Boot
};

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const goToHostnameStep = async () => {
const goToReviewStep = async () => {
await clickNext(); // Kernel
await clickNext(); // Firewall
await clickNext(); // Services
await clickNext(); // First boot script
await clickNext(); // Details
await enterBlueprintName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ const goToReviewStep = async () => {
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // Firewall
await clickNext(); // Services
await clickNext(); // First boot
await clickNext(); // Details
await enterBlueprintName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const goToKernelStep = async () => {

const goToReviewStep = async () => {
await clickNext(); // Firewall
await clickNext(); // Services
await clickNext(); // First boot script
await clickNext(); // Details
await enterBlueprintName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const goToReviewStep = async () => {
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // Firewall
await clickNext(); // Services
await clickNext(); // First boot
await clickNext(); // Details
await enterBlueprintName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ const goToReviewStep = async () => {
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // Firewall
await clickNext(); // Services
await clickNext(); // FirstBoot
await clickNext(); // Details
await enterBlueprintName('Oscap test');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const goToReviewStep = async () => {
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // Firewall
await clickNext(); // Services
await clickNext(); // First Boot
await clickNext(); // Details
await enterBlueprintName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ const goToReviewStep = async () => {
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // Firewall
await clickNext(); // Services
await clickNext(); // Details
await enterBlueprintName();
await clickNext(); // Review
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const goToReviewStep = async () => {
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // Firewall
await clickNext(); // Services
await clickNext(); // First Boot
await clickNext(); // Details
await enterBlueprintName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const goToReviewStep = async () => {
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // Firewall
await clickNext(); // Services
await clickNext(); // First boot script
await clickNext(); // Details
await clickNext(); // Review
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
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 goToServicesStep = 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
await clickNext(); // Services
};

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

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

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

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

// TO DO 'Services step' -> 'revisit step button on Review works'
// TO DO 'Services request generated correctly'
// TO DO 'Services edit mode'
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const goToReviewStep = async () => {
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // Firewall
await clickNext(); // Services
await clickNext(); // First boot script
await enterBlueprintName();
await clickNext(); // Review
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const goToReview = async () => {
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // Firewall
await clickNext(); // Services
await clickNext(); // FirstBoot
await clickNext(); // Details
await enterBlueprintName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const goToReview = async () => {
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // Firewall
await clickNext(); // Services
await clickNext(); // FirstBoot
await clickNext(); // Details
await enterBlueprintName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const goToReview = async () => {
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // Firewall
await clickNext(); // Services
await clickNext(); // FirstBoot
await clickNext(); // Details
await enterBlueprintName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const goToReviewStep = async () => {
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // Firewall
await clickNext(); // Services
await clickNext(); // First boot script
await clickNext(); // Details
await enterBlueprintName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const goToReviewStep = async () => {
await clickNext(); // Hostname
await clickNext(); // Kernel
await clickNext(); // Firewall
await clickNext(); // Services
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 @@ -75,6 +75,8 @@ vi.mock('@unleash/proxy-client-react', () => ({
return true;
case 'image-builder.firewall.enabled':
return true;
case 'image-builder.services.enabled':
return true;
case 'edgeParity.image-list':
return true;
case 'image-builder.edge.local-image-table':
Expand Down
Loading