diff --git a/src/test/Components/CreateImageWizard/steps/Details/Details.test.tsx b/src/test/Components/CreateImageWizard/steps/Details/Details.test.tsx index 1a247e1f..b985cbbe 100644 --- a/src/test/Components/CreateImageWizard/steps/Details/Details.test.tsx +++ b/src/test/Components/CreateImageWizard/steps/Details/Details.test.tsx @@ -6,11 +6,11 @@ import { mockBlueprintIds } from '../../../../fixtures/blueprints'; import { detailsCreateBlueprintRequest } from '../../../../fixtures/editMode'; import { blueprintRequest, - clickNext, clickRegisterLater, enterBlueprintName, getNextButton, goToRegistrationStep, + goToStep, interceptBlueprintRequest, interceptEditBlueprintRequest, openAndDismissSaveAndBuildModal, @@ -18,23 +18,6 @@ import { renderEditMode, } from '../../wizardTestUtils'; -export const goToDetailsStep = async () => { - await clickNext(); // OpenSCAP - await clickNext(); // File system configuration - await clickNext(); // Repository snapshot/Repeatable builds - 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 - await clickNext(); // First boot script - await clickNext(); // Details -}; - const enterBlueprintDescription = async ( description: string = 'Now with extra carmine!', ) => { @@ -48,10 +31,6 @@ const enterBlueprintDescription = async ( await waitFor(() => user.type(blueprintDescription, description)); }; -const goToReviewStep = async () => { - await clickNext(); // Review -}; - const clickRevisitButton = async () => { const user = userEvent.setup(); const expandable = await screen.findByTestId('image-details-expandable'); @@ -69,7 +48,7 @@ describe('Step Details', () => { await renderCreateMode(); await goToRegistrationStep(); await clickRegisterLater(); - await goToDetailsStep(); + await goToStep(/Details/); const nextButton = await getNextButton(); expect(nextButton).toBeEnabled(); await enterBlueprintName(' '); @@ -80,7 +59,7 @@ describe('Step Details', () => { await renderCreateMode(); await goToRegistrationStep(); await clickRegisterLater(); - await goToDetailsStep(); + await goToStep(/Details/); await enterBlueprintName('🤣Red Velvet🤣'); const nextButton = await getNextButton(); await waitFor(() => expect(nextButton).toBeEnabled()); @@ -90,7 +69,7 @@ describe('Step Details', () => { await renderCreateMode(); await goToRegistrationStep(); await clickRegisterLater(); - await goToDetailsStep(); + await goToStep(/Details/); await enterBlueprintName('Lemon Pie'); const nextButton = await getNextButton(); await waitFor(() => expect(nextButton).toBeDisabled()); @@ -100,7 +79,7 @@ describe('Step Details', () => { await renderCreateMode(); await goToRegistrationStep(); await clickRegisterLater(); - await goToDetailsStep(); + await goToStep(/Details/); // enter invalid image name const invalidName = 'a'.repeat(101); @@ -116,7 +95,7 @@ describe('Step Details', () => { await renderCreateMode(); await goToRegistrationStep(); await clickRegisterLater(); - await goToDetailsStep(); + await goToStep(/Details/); // enter invalid image description const invalidDescription = 'a'.repeat(251); @@ -132,8 +111,8 @@ describe('Step Details', () => { await renderCreateMode(); await goToRegistrationStep(); await clickRegisterLater(); - await goToDetailsStep(); - await goToReviewStep(); + await goToStep(/Details/); + await goToStep(/Review/); await clickRevisitButton(); await screen.findByRole('heading', { name: /Details/ }); }); @@ -148,9 +127,9 @@ describe('Details request generated correctly', () => { await renderCreateMode(); await goToRegistrationStep(); await clickRegisterLater(); - await goToDetailsStep(); + await goToStep(/Details/); await enterBlueprintName(); - await goToReviewStep(); + await goToStep(/Review/); // informational modal pops up in the first test only as it's tied // to a 'imageBuilder.saveAndBuildModalSeen' variable in localStorage await openAndDismissSaveAndBuildModal(); @@ -165,10 +144,10 @@ describe('Details request generated correctly', () => { await renderCreateMode(); await goToRegistrationStep(); await clickRegisterLater(); - await goToDetailsStep(); + await goToStep(/Details/); await enterBlueprintName(); await enterBlueprintDescription(); - await goToReviewStep(); + await goToStep(/Review/); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedRequest = { diff --git a/src/test/Components/CreateImageWizard/steps/FileSystemConfiguration/FileSystemConfiguration.test.tsx b/src/test/Components/CreateImageWizard/steps/FileSystemConfiguration/FileSystemConfiguration.test.tsx index be59954a..1255133b 100644 --- a/src/test/Components/CreateImageWizard/steps/FileSystemConfiguration/FileSystemConfiguration.test.tsx +++ b/src/test/Components/CreateImageWizard/steps/FileSystemConfiguration/FileSystemConfiguration.test.tsx @@ -15,8 +15,9 @@ import { clickNext, clickRegisterLater, clickReviewAndFinish, - enterBlueprintName, getNextButton, + goToReview, + goToStep, interceptBlueprintRequest, interceptEditBlueprintRequest, openAndDismissSaveAndBuildModal, @@ -43,8 +44,7 @@ const selectImageInstaller = async () => { const goToFileSystemConfigurationStep = async () => { await clickNext(); // Registration await clickRegisterLater(); - await clickNext(); // OpenSCAP - await clickNext(); // File System + await goToStep(/File system configuration/); }; const clickManuallyConfigurePartitions = async () => { @@ -100,23 +100,6 @@ const changePartitionUnitsToMiB = async () => { await waitFor(() => user.click(mibOption)); }; -const goToReviewStep = async () => { - await clickNext(); // File system configuration - await clickNext(); // Repository snapshot/Repeatable builds - 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 - await clickNext(); // Details - await enterBlueprintName(); - await clickNext(); // Review -}; - const clickRevisitButton = async () => { const user = userEvent.setup(); const expandable = await screen.findByTestId( @@ -216,7 +199,7 @@ describe('Step File system configuration', () => { await renderCreateMode(); await selectGuestImage(); await goToFileSystemConfigurationStep(); - await goToReviewStep(); + await goToReview(); await clickRevisitButton(); await screen.findByRole('heading', { name: /File system configuration/ }); }); @@ -232,7 +215,7 @@ describe('File system configuration request generated correctly', () => { await selectGuestImage(); await goToFileSystemConfigurationStep(); await clickManuallyConfigurePartitions(); - await goToReviewStep(); + await goToReview(); // informational modal pops up in the first test only as it's tied // to a 'imageBuilder.saveAndBuildModalSeen' variable in localStorage await openAndDismissSaveAndBuildModal(); @@ -259,7 +242,7 @@ describe('File system configuration request generated correctly', () => { await goToFileSystemConfigurationStep(); await clickManuallyConfigurePartitions(); await changePartitionSize(); - await goToReviewStep(); + await goToReview(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedRequest = { @@ -283,7 +266,7 @@ describe('File system configuration request generated correctly', () => { await goToFileSystemConfigurationStep(); await clickManuallyConfigurePartitions(); await changePartitionUnitsToMiB(); - await goToReviewStep(); + await goToReview(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedRequest = { @@ -307,7 +290,7 @@ describe('File system configuration request generated correctly', () => { await goToFileSystemConfigurationStep(); await clickManuallyConfigurePartitions(); await changePartitionUnitsToKiB(); - await goToReviewStep(); + await goToReview(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedRequest = { @@ -331,7 +314,7 @@ describe('File system configuration request generated correctly', () => { await goToFileSystemConfigurationStep(); await clickManuallyConfigurePartitions(); await addPartition(); - await goToReviewStep(); + await goToReview(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedRequest = { @@ -360,7 +343,7 @@ describe('File system configuration request generated correctly', () => { await clickManuallyConfigurePartitions(); await addPartition(); await customizePartition(); - await goToReviewStep(); + await goToReview(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedRequest = { diff --git a/src/test/Components/CreateImageWizard/steps/Firewall/Firewall.test.tsx b/src/test/Components/CreateImageWizard/steps/Firewall/Firewall.test.tsx index 0b0c52f9..48e4ec50 100644 --- a/src/test/Components/CreateImageWizard/steps/Firewall/Firewall.test.tsx +++ b/src/test/Components/CreateImageWizard/steps/Firewall/Firewall.test.tsx @@ -10,7 +10,8 @@ import { clickBack, clickNext, clickRegisterLater, - enterBlueprintName, + goToReview, + goToStep, interceptBlueprintRequest, interceptEditBlueprintRequest, openAndDismissSaveAndBuildModal, @@ -29,25 +30,7 @@ const goToFirewallStep = async () => { 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 -}; - -const goToReviewStep = async () => { - await clickNext(); // Services - await clickNext(); // First boot script - await clickNext(); // Details - await enterBlueprintName(); - await clickNext(); // Review + await goToStep(/Firewall/); }; const addPort = async (port: string) => { @@ -145,7 +128,7 @@ describe('Step Firewall', () => { await renderCreateMode(); await goToFirewallStep(); await addPort('22:tcp'); - await goToReviewStep(); + await goToReview(); await clickRevisitButton(); await screen.findByRole('heading', { name: /Firewall/ }); }); @@ -157,7 +140,7 @@ describe('Firewall request generated correctly', () => { await goToFirewallStep(); await addPort('22:tcp'); await addPort('imap:tcp'); - await goToReviewStep(); + await goToReview(); // informational modal pops up in the first test only as it's tied // to a 'imageBuilder.saveAndBuildModalSeen' variable in localStorage await openAndDismissSaveAndBuildModal(); @@ -184,7 +167,7 @@ describe('Firewall request generated correctly', () => { await addEnabledFirewallService('ntp'); await addEnabledFirewallService('dhcp'); await addDisabledFirewallService('telnet'); - await goToReviewStep(); + await goToReview(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedRequest = { @@ -213,7 +196,7 @@ describe('Firewall request generated correctly', () => { await addEnabledFirewallService('ntp'); await addEnabledFirewallService('dhcp'); await addDisabledFirewallService('telnet'); - await goToReviewStep(); + await goToReview(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedRequest = { diff --git a/src/test/Components/CreateImageWizard/steps/FirstBoot/Firstboot.test.tsx b/src/test/Components/CreateImageWizard/steps/FirstBoot/Firstboot.test.tsx index c587d32d..ee691139 100644 --- a/src/test/Components/CreateImageWizard/steps/FirstBoot/Firstboot.test.tsx +++ b/src/test/Components/CreateImageWizard/steps/FirstBoot/Firstboot.test.tsx @@ -21,9 +21,10 @@ import { clickNext, clickRegisterLater, clickReviewAndFinish, - enterBlueprintName, getNextButton, goToOscapStep, + goToReview, + goToStep, interceptBlueprintRequest, interceptEditBlueprintRequest, openAndDismissSaveAndBuildModal, @@ -41,19 +42,7 @@ const goToFirstBootStep = async (): Promise => { await waitFor(() => user.click(guestImageCheckBox)); await clickNext(); // Registration await clickRegisterLater(); - await clickNext(); // OpenSCAP - await clickNext(); // File system configuration - await clickNext(); // Repository snapshot/Repeatable builds - 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 - await clickNext(); // First Boot + await goToStep(/First boot/); }; const selectSimplifiedOscapProfile = async () => { @@ -65,21 +54,6 @@ const selectSimplifiedOscapProfile = async () => { await waitFor(() => user.click(simplifiedProfile)); }; -const goFromOscapToFirstBoot = async () => { - await clickNext(); // File system configuration - await clickNext(); // Repository snapshot/Repeatable builds - 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 - await clickNext(); // First boot script -}; - const openCodeEditor = async (): Promise => { const user = userEvent.setup(); const startBtn = await screen.findByRole('button', { @@ -100,12 +74,6 @@ const uploadFile = async (scriptName: string): Promise => { } }; -const goToReviewStep = async (): Promise => { - await clickNext(); // Details - await enterBlueprintName(); - await clickNext(); // Review -}; - const clickRevisitButton = async () => { const user = userEvent.setup(); const expandable = await screen.findByTestId('firstboot-expandable'); @@ -149,7 +117,7 @@ describe('First Boot step', () => { test('revisit step button on Review works', async () => { await renderCreateMode(); await goToFirstBootStep(); - await goToReviewStep(); + await goToReview(); await clickRevisitButton(); await screen.findByRole('heading', { name: /First boot/ }); }); @@ -162,7 +130,7 @@ describe('First boot request generated correctly', () => { await goToFirstBootStep(); await openCodeEditor(); await uploadFile(SCRIPT); - await goToReviewStep(); + await goToReview(); // informational modal pops up in the first test only as it's tied // to a 'imageBuilder.saveAndBuildModalSeen' variable in localStorage await openAndDismissSaveAndBuildModal(); @@ -188,10 +156,10 @@ describe('First boot request generated correctly', () => { await selectGuestImageTarget(); await goToOscapStep(); await selectSimplifiedOscapProfile(); - await goFromOscapToFirstBoot(); + await goToStep(/First boot/); await openCodeEditor(); await uploadFile(SCRIPT); - await goToReviewStep(); + await goToReview(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); // request created with both OpenSCAP and first boot customization @@ -220,10 +188,10 @@ describe('First boot request generated correctly', () => { await selectGuestImageTarget(); await goToOscapStep(); await selectSimplifiedOscapProfile(); - await goFromOscapToFirstBoot(); + await goToStep(/First boot/); await openCodeEditor(); await uploadFile(SCRIPT_DOS); - await goToReviewStep(); + await goToReview(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); // request created with both OpenSCAP and first boot customization @@ -277,7 +245,7 @@ describe('First Boot edit mode', () => { // upload empty script file and go to Review await uploadFile(``); - await goToReviewStep(); + await goToReview(); const receivedRequest = await interceptEditBlueprintRequest( `${EDIT_BLUEPRINT}/${id}`, diff --git a/src/test/Components/CreateImageWizard/steps/Hostname/Hostname.test.tsx b/src/test/Components/CreateImageWizard/steps/Hostname/Hostname.test.tsx index 8fe42fe5..6716ff0f 100644 --- a/src/test/Components/CreateImageWizard/steps/Hostname/Hostname.test.tsx +++ b/src/test/Components/CreateImageWizard/steps/Hostname/Hostname.test.tsx @@ -10,8 +10,9 @@ import { clickBack, clickNext, clickRegisterLater, - enterBlueprintName, getNextButton, + goToReview, + goToStep, interceptBlueprintRequest, interceptEditBlueprintRequest, openAndDismissSaveAndBuildModal, @@ -33,29 +34,7 @@ const goToHostnameStep = async () => { await clickNext(); // Registration await clickRegisterLater(); } - await clickNext(); // OpenSCAP - await clickNext(); // File system configuration - if (!process.env.IS_ON_PREMISE) { - await clickNext(); // Snapshots - await clickNext(); // Custom repositories - } - await clickNext(); // Additional packages - await clickNext(); // Users - await clickNext(); // Timezone - await clickNext(); // Locale - await clickNext(); // Hostname -}; - -const goToReviewStep = async () => { - await clickNext(); // Kernel - await clickNext(); // Firewall - await clickNext(); // Services - if (!process.env.IS_ON_PREMISE) { - await clickNext(); // First boot script - } - await clickNext(); // Details - await enterBlueprintName(); - await clickNext(); // Review + await goToStep(/Hostname/); }; const enterHostname = async (hostname: string) => { @@ -146,7 +125,7 @@ describe('Step Hostname', () => { await renderCreateMode(); await goToHostnameStep(); await enterHostname('hostname'); - await goToReviewStep(); + await goToReview(); await clickRevisitButton(); await screen.findByRole('heading', { name: /Hostname/ }); }); @@ -161,7 +140,7 @@ describe('Hostname request generated correctly', () => { await renderCreateMode(); await goToHostnameStep(); await enterHostname('hostname'); - await goToReviewStep(); + await goToReview(); // informational modal pops up in the first test only as it's tied // to a 'imageBuilder.saveAndBuildModalSeen' variable in localStorage await openAndDismissSaveAndBuildModal(); diff --git a/src/test/Components/CreateImageWizard/steps/ImageOutput/ImageOutput.test.tsx b/src/test/Components/CreateImageWizard/steps/ImageOutput/ImageOutput.test.tsx index a9555aa9..1a6524da 100644 --- a/src/test/Components/CreateImageWizard/steps/ImageOutput/ImageOutput.test.tsx +++ b/src/test/Components/CreateImageWizard/steps/ImageOutput/ImageOutput.test.tsx @@ -34,6 +34,7 @@ import { clickRegisterLater, enterBlueprintName, getNextButton, + goToStep, imageRequest, interceptBlueprintRequest, interceptEditBlueprintRequest, @@ -43,7 +44,6 @@ import { selectRhel9, verifyCancelButton, } from '../../wizardTestUtils'; -import { goToDetailsStep } from '../Details/Details.test'; let router: RemixRouter | undefined = undefined; @@ -276,7 +276,7 @@ describe('Step Image output', () => { await renderCreateMode(); await selectGuestImageTarget(); await handleRegistration(); - await goToDetailsStep(); + await goToStep(/Details/); await enterNameAndGoToReviewStep(); await clickRevisitButton(); await screen.findByRole('heading', { name: /Image output/ }); @@ -286,14 +286,14 @@ describe('Step Image output', () => { await renderCreateMode(); await selectGuestImageTarget(); await handleRegistration(); - await goToDetailsStep(); + await goToStep(/Details/); await clickNext(); // Review await clickRevisitButton(); await selectRhel8(); await selectAarch64(); await selectGuestImageTarget(); await handleRegistration(); - await goToDetailsStep(); + await goToStep(/Details/); await clickNext(); // Review await verifyNameInReviewStep('rhel-8-aarch64'); }); @@ -302,14 +302,14 @@ describe('Step Image output', () => { await renderCreateMode(); await selectGuestImageTarget(); await handleRegistration(); - await goToDetailsStep(); + await goToStep(/Details/); await enterNameAndGoToReviewStep(); await clickRevisitButton(); await selectRhel8(); await selectAarch64(); await selectGuestImageTarget(); await handleRegistration(); - await goToDetailsStep(); + await goToStep(/Details/); await clickNext(); // Review await verifyNameInReviewStep('Red Velvet'); }); @@ -732,7 +732,7 @@ describe('Set target using query parameter', () => { }), ).toBeChecked(); await handleRegistration(); - await goToDetailsStep(); + await goToStep(/Details/); await enterNameAndGoToReviewStep(); const targetExpandable = await screen.findByTestId( 'target-environments-expandable', @@ -749,7 +749,7 @@ describe('Set target using query parameter', () => { }), ).toBeChecked(); await handleRegistration(); - await goToDetailsStep(); + await goToStep(/Details/); await enterNameAndGoToReviewStep(); const targetExpandable = await screen.findByTestId( 'target-environments-expandable', @@ -769,7 +769,7 @@ describe('Distribution request generated correctly', () => { await selectRhel8(); await selectGuestImageTarget(); await handleRegistration(); - await goToDetailsStep(); + await goToStep(/Details/); await enterNameAndGoToReviewStep(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); @@ -786,7 +786,7 @@ describe('Distribution request generated correctly', () => { await selectRhel9(); await selectGuestImageTarget(); await handleRegistration(); - await goToDetailsStep(); + await goToStep(/Details/); await enterNameAndGoToReviewStep(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); @@ -802,7 +802,7 @@ describe('Distribution request generated correctly', () => { await renderCreateMode(); await selectCentos9(); await selectGuestImageTarget(); - await goToDetailsStep(); + await goToStep(/Details/); await enterNameAndGoToReviewStep(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); @@ -825,7 +825,7 @@ describe('Architecture request generated correctly', () => { await selectX86_64(); await selectGuestImageTarget(); await handleRegistration(); - await goToDetailsStep(); + await goToStep(/Details/); await enterNameAndGoToReviewStep(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); @@ -846,7 +846,7 @@ describe('Architecture request generated correctly', () => { await selectAarch64(); await selectGuestImageTarget(); await handleRegistration(); - await goToDetailsStep(); + await goToStep(/Details/); await enterNameAndGoToReviewStep(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); diff --git a/src/test/Components/CreateImageWizard/steps/Kernel/Kernel.test.tsx b/src/test/Components/CreateImageWizard/steps/Kernel/Kernel.test.tsx index 9de68c60..d4c83ed4 100644 --- a/src/test/Components/CreateImageWizard/steps/Kernel/Kernel.test.tsx +++ b/src/test/Components/CreateImageWizard/steps/Kernel/Kernel.test.tsx @@ -14,7 +14,8 @@ import { clickBack, clickNext, clickRegisterLater, - enterBlueprintName, + goToReview, + goToStep, interceptBlueprintRequest, interceptEditBlueprintRequest, openAndDismissSaveAndBuildModal, @@ -56,28 +57,11 @@ const goToOpenSCAPStep = async () => { await waitFor(() => user.click(guestImageCheckBox)); await clickNext(); // Registration await clickRegisterLater(); - await clickNext(); // OpenSCAP + await goToStep(/OpenSCAP/); }; const goFromOpenSCAPToKernel = async () => { - 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 -}; - -const goToReviewStep = async () => { - await clickNext(); // Firewall - await clickNext(); // Services - await clickNext(); // First boot script - await clickNext(); // Details - await enterBlueprintName(); - await clickNext(); // Review + await goToStep(/Kernel/); }; const getKernelNameOptions = async () => { @@ -240,7 +224,7 @@ describe('Step Kernel', () => { await renderCreateMode(); await goToKernelStep(); await selectKernelName('kernel'); - await goToReviewStep(); + await goToReview(); await clickRevisitButton(); await screen.findByRole('heading', { name: /Kernel/ }); }); @@ -255,7 +239,7 @@ describe('Kernel request generated correctly', () => { await renderCreateMode(); await goToKernelStep(); await selectKernelName('kernel-debug'); - await goToReviewStep(); + await goToReview(); // informational modal pops up in the first test only as it's tied // to a 'imageBuilder.saveAndBuildModalSeen' variable in localStorage await openAndDismissSaveAndBuildModal(); @@ -280,7 +264,7 @@ describe('Kernel request generated correctly', () => { await goToKernelStep(); await selectKernelName('kernel-debug'); await clearKernelName(); - await goToReviewStep(); + await goToReview(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedRequest = { @@ -297,7 +281,7 @@ describe('Kernel request generated correctly', () => { await goToKernelStep(); await addKernelAppend('nosmt=force'); await removeKernelArg('nosmt=force'); - await goToReviewStep(); + await goToReview(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedRequest = { @@ -314,7 +298,7 @@ describe('Kernel request generated correctly', () => { await renderCreateMode(); await goToKernelStep(); await addKernelAppend('nosmt=force'); - await goToReviewStep(); + await goToReview(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedRequest = { @@ -337,7 +321,7 @@ describe('Kernel request generated correctly', () => { await goToOpenSCAPStep(); await selectProfile(); await goFromOpenSCAPToKernel(); - await goToReviewStep(); + await goToReview(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedRequest = { diff --git a/src/test/Components/CreateImageWizard/steps/Locale/Locale.test.tsx b/src/test/Components/CreateImageWizard/steps/Locale/Locale.test.tsx index f56462d8..1d54ff38 100644 --- a/src/test/Components/CreateImageWizard/steps/Locale/Locale.test.tsx +++ b/src/test/Components/CreateImageWizard/steps/Locale/Locale.test.tsx @@ -10,7 +10,8 @@ import { clickBack, clickNext, clickRegisterLater, - enterBlueprintName, + goToReview, + goToStep, interceptBlueprintRequest, interceptEditBlueprintRequest, openAndDismissSaveAndBuildModal, @@ -29,25 +30,7 @@ const goToLocaleStep = async () => { 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 -}; - -const goToReviewStep = async () => { - await clickNext(); // Hostname - await clickNext(); // Kernel - await clickNext(); // Firewall - await clickNext(); // Services - await clickNext(); // First boot - await clickNext(); // Details - await enterBlueprintName(); - await clickNext(); // Review + await goToStep(/Locale/); }; const clearLanguageSearch = async () => { @@ -181,7 +164,7 @@ describe('Step Locale', () => { await goToLocaleStep(); await searchForKeyboard('us'); await selectKeyboard(); - await goToReviewStep(); + await goToReview(); await clickRevisitButton(); await screen.findByRole('heading', { name: /Locale/ }); }); @@ -192,7 +175,7 @@ describe('Locale request generated correctly', () => { await renderCreateMode(); await goToLocaleStep(); await selectLanguages(); - await goToReviewStep(); + await goToReview(); // informational modal pops up in the first test only as it's tied // to a 'imageBuilder.saveAndBuildModalSeen' variable in localStorage await openAndDismissSaveAndBuildModal(); @@ -217,7 +200,7 @@ describe('Locale request generated correctly', () => { await goToLocaleStep(); await searchForKeyboard('us'); await selectKeyboard(); - await goToReviewStep(); + await goToReview(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedRequest = { @@ -240,7 +223,7 @@ describe('Locale request generated correctly', () => { await selectLanguages(); await searchForKeyboard('us'); await selectKeyboard(); - await goToReviewStep(); + await goToReview(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedRequest = { diff --git a/src/test/Components/CreateImageWizard/steps/Oscap/Compliance.test.tsx b/src/test/Components/CreateImageWizard/steps/Oscap/Compliance.test.tsx index 88aa1b4c..26d78723 100644 --- a/src/test/Components/CreateImageWizard/steps/Oscap/Compliance.test.tsx +++ b/src/test/Components/CreateImageWizard/steps/Oscap/Compliance.test.tsx @@ -8,7 +8,7 @@ import { complianceCreateBlueprintRequest } from '../../../../fixtures/editMode' import { clickNext, clickRegisterLater, - enterBlueprintName, + goToReview, interceptBlueprintRequest, interceptEditBlueprintRequest, openAndDismissSaveAndBuildModal, @@ -49,24 +49,6 @@ const goToComplianceStep = async () => { await screen.findByText('None'); }; -const goToReviewStep = async () => { - 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(); // Systemd services - await clickNext(); // First boot - await clickNext(); // Details - await enterBlueprintName('Compliance test'); - await clickNext(); // Review -}; - const selectPolicy = async () => { const user = userEvent.setup(); @@ -99,7 +81,7 @@ describe('Compliance', () => { await renderCreateMode(); await goToComplianceStep(); await selectPolicy(); - await goToReviewStep(); + await goToReview('Compliance test'); await openAndDismissSaveAndBuildModal(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); @@ -117,7 +99,7 @@ describe('Compliance', () => { await renderCreateMode(); await goToComplianceStep(); await selectPolicy(); - await goToReviewStep(); + await goToReview('Compliance test'); await screen.findByRole('heading', { name: /Review/ }); await clickRevisitButton(); await screen.findByRole('heading', { name: /Compliance/ }); diff --git a/src/test/Components/CreateImageWizard/steps/Oscap/FipsMode.test.tsx b/src/test/Components/CreateImageWizard/steps/Oscap/FipsMode.test.tsx index 6578a8cc..4805dcd5 100644 --- a/src/test/Components/CreateImageWizard/steps/Oscap/FipsMode.test.tsx +++ b/src/test/Components/CreateImageWizard/steps/Oscap/FipsMode.test.tsx @@ -7,7 +7,7 @@ import { baseCreateBlueprintRequest } from '../../../../fixtures/editMode'; import { clickNext, clickRegisterLater, - enterBlueprintName, + goToReview, interceptBlueprintRequest, openAndDismissSaveAndBuildModal, renderCreateMode, @@ -72,24 +72,6 @@ const toggleFipsCheckbox = async () => { return fipsCheckbox; }; -const goToReviewStep = async () => { - await clickNext(); // File system configuration - await clickNext(); // Snapshot repositories - 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 - await clickNext(); // FirstBoot - await clickNext(); // Details - await enterBlueprintName('FIPS test'); - await clickNext(); // Review -}; - describe('FIPS Mode Tests', () => { beforeEach(() => { vi.clearAllMocks(); @@ -129,7 +111,7 @@ describe('FIPS Mode Tests', () => { await goToComplianceStep(); await toggleFipsCheckbox(); - await goToReviewStep(); + await goToReview('FIPS test'); await openAndDismissSaveAndBuildModal(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); diff --git a/src/test/Components/CreateImageWizard/steps/Oscap/Oscap.test.tsx b/src/test/Components/CreateImageWizard/steps/Oscap/Oscap.test.tsx index adaa4e68..6feb8098 100644 --- a/src/test/Components/CreateImageWizard/steps/Oscap/Oscap.test.tsx +++ b/src/test/Components/CreateImageWizard/steps/Oscap/Oscap.test.tsx @@ -16,8 +16,8 @@ import { import { clickNext, clickReviewAndFinish, - enterBlueprintName, goToOscapStep, + goToReview, interceptBlueprintRequest, interceptEditBlueprintRequest, openAndDismissSaveAndBuildModal, @@ -82,24 +82,6 @@ const selectNone = async () => { await waitFor(async () => user.click(await screen.findByText(/none/i))); }; -const goToReviewStep = async () => { - await clickNext(); // File system configuration - await clickNext(); // Snapshot repositories - 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 - await clickNext(); // FirstBoot - await clickNext(); // Details - await enterBlueprintName('Oscap test'); - await clickNext(); // Review -}; - const clickRevisitButton = async () => { const user = userEvent.setup(); const expandable = await screen.findByTestId('oscap-detail-expandable'); @@ -231,7 +213,7 @@ describe('OpenSCAP request generated correctly', () => { await selectGuestImageTarget(); await goToOscapStep(); await selectProfile(); - await goToReviewStep(); + await goToReview('Oscap test'); // informational modal pops up in the first test only as it's tied // to a 'imageBuilder.saveAndBuildModalSeen' variable in localStorage await openAndDismissSaveAndBuildModal(); @@ -254,7 +236,7 @@ describe('OpenSCAP request generated correctly', () => { await goToOscapStep(); await selectProfile(); await selectNone(); - await goToReviewStep(); + await goToReview('Oscap test'); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); @@ -274,7 +256,7 @@ describe('OpenSCAP request generated correctly', () => { await goToOscapStep(); await selectProfile(); await selectDifferentProfile(); - await goToReviewStep(); + await goToReview('Oscap test'); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); @@ -301,7 +283,7 @@ describe('OpenSCAP request generated correctly', () => { await selectGuestImageTarget(); await goToOscapStep(); await selectProfile(); - await goToReviewStep(); + await goToReview('Oscap test'); await clickRevisitButton(); await screen.findByRole('heading', { name: /OpenSCAP/ }); }); diff --git a/src/test/Components/CreateImageWizard/steps/Packages/Packages.test.tsx b/src/test/Components/CreateImageWizard/steps/Packages/Packages.test.tsx index 9d4df218..85a2a12e 100644 --- a/src/test/Components/CreateImageWizard/steps/Packages/Packages.test.tsx +++ b/src/test/Components/CreateImageWizard/steps/Packages/Packages.test.tsx @@ -22,7 +22,8 @@ import { clickNext, clickRegisterLater, clickReviewAndFinish, - enterBlueprintName, + goToReview, + goToStep, interceptBlueprintRequest, interceptEditBlueprintRequest, openAndDismissSaveAndBuildModal, @@ -47,25 +48,7 @@ const goToPackagesStep = async () => { await selectGuestImageTarget(); await clickNext(); // Registration await clickRegisterLater(); - await clickNext(); // OpenSCAP - await clickNext(); // File system configuration - await clickNext(); // Repository snapshot/Repeatable builds - await clickNext(); // Custom repositories - await clickNext(); // Additional packages -}; - -const goToReviewStep = async () => { - await clickNext(); // Users - await clickNext(); // Timezone - await clickNext(); // Locale - await clickNext(); // Hostname - await clickNext(); // Kernel - await clickNext(); // Firewall - await clickNext(); // Services - await clickNext(); // First Boot - await clickNext(); // Details - await enterBlueprintName(); - await clickNext(); // Review + await goToStep(/Additional packages/); }; const typeIntoSearchBox = async (searchTerm: string) => { @@ -415,7 +398,7 @@ describe('Step Packages', () => { await goToPackagesStep(); await typeIntoSearchBox('test'); await clickFirstPackageCheckbox(); - await goToReviewStep(); + await goToReview(); await clickRevisitButton(); await screen.findByRole('heading', { name: /Custom repositories/ }); }); @@ -544,7 +527,7 @@ describe('Packages request generated correctly', () => { await goToPackagesStep(); await typeIntoSearchBox('test'); // search for 'test' package await clickFirstPackageCheckbox(); // select - await goToReviewStep(); + await goToReview(); // informational modal pops up in the first test only as it's tied // to a 'imageBuilder.saveAndBuildModalSeen' variable in localStorage await openAndDismissSaveAndBuildModal(); @@ -566,7 +549,7 @@ describe('Packages request generated correctly', () => { await typeIntoSearchBox('test'); // search for 'test' package await clickFirstPackageCheckbox(); // select await clickFirstPackageCheckbox(); // deselect - await goToReviewStep(); + await goToReview(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedRequest = blueprintRequest; @@ -582,7 +565,7 @@ describe('Packages request generated correctly', () => { name: /select row 0/i, }); await waitFor(() => user.click(moduleCheckbox)); - await goToReviewStep(); + await goToReview(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedRequest: CreateBlueprintRequest = { @@ -606,7 +589,7 @@ describe('Packages request generated correctly', () => { await waitFor(() => user.click(moduleCheckbox)); // select await toggleSelected(); await clickFirstPackageCheckbox(); // deselect - await goToReviewStep(); + await goToReview(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedRequest = blueprintRequest; @@ -619,7 +602,7 @@ describe('Packages request generated correctly', () => { await goToPackagesStep(); await typeIntoSearchBox('@grouper'); // search for '@grouper' package group await clickFirstPackageCheckbox(); // select - await goToReviewStep(); + await goToReview(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); @@ -639,7 +622,7 @@ describe('Packages request generated correctly', () => { await clickFirstPackageCheckbox(); // select await toggleSelected(); await clickFirstPackageCheckbox(); // deselect - await goToReviewStep(); + await goToReview(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedRequest = blueprintRequest; @@ -658,7 +641,7 @@ describe('Packages request generated correctly', () => { await typeIntoSearchBox('test'); // search for 'test' package await clickFirstPackageCheckbox(); // select await addSingleRecommendation(); - await goToReviewStep(); + await goToReview(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedRequest: CreateBlueprintRequest = { @@ -679,7 +662,7 @@ describe('Packages request generated correctly', () => { await typeIntoSearchBox('test'); // search for 'test' package await clickFirstPackageCheckbox(); // select await addAllRecommendations(); - await goToReviewStep(); + await goToReview(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedRequest: CreateBlueprintRequest = { @@ -702,7 +685,7 @@ describe('Packages request generated correctly', () => { await addSingleRecommendation(); await toggleSelected(); await deselectRecommendation(); - await goToReviewStep(); + await goToReview(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedRequest: CreateBlueprintRequest = { diff --git a/src/test/Components/CreateImageWizard/steps/Registration/Registration.test.tsx b/src/test/Components/CreateImageWizard/steps/Registration/Registration.test.tsx index 87dc8d25..f946099b 100644 --- a/src/test/Components/CreateImageWizard/steps/Registration/Registration.test.tsx +++ b/src/test/Components/CreateImageWizard/steps/Registration/Registration.test.tsx @@ -28,9 +28,9 @@ import { clickRegisterLater, clickRegisterSatellite, clickReviewAndFinish, - enterBlueprintName, getNextButton, goToRegistrationStep, + goToReview, interceptBlueprintRequest, interceptEditBlueprintRequest, openAndDismissSaveAndBuildModal, @@ -120,25 +120,6 @@ const uploadFile = async (scriptName: string): Promise => { } }; -const goToReviewStep = async () => { - await clickNext(); // Registration - await clickNext(); // OpenSCAP - await clickNext(); // File system configuration - await clickNext(); // Repository snapshot/Repeatable builds - 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 - await clickNext(); // Details - await enterBlueprintName(); - await clickNext(); // Review -}; - const clickRevisitButton = async () => { const user = userEvent.setup(); const expandable = await screen.findByTestId('registration-expandable'); @@ -206,7 +187,7 @@ describe('Step Registration', () => { await goToRegistrationStep(); await openActivationKeyDropdown(); await selectActivationKey('name0'); - await goToReviewStep(); + await goToReview(); const review = await screen.findByTestId('review-registration'); expect(review).toHaveTextContent( @@ -233,7 +214,7 @@ describe('Step Registration', () => { 'pf-m-disabled', ), ); - await goToReviewStep(); + await goToReview(); await screen.findByText('Register the system later'); }); @@ -242,7 +223,7 @@ describe('Step Registration', () => { await goToRegistrationStep(); await openActivationKeyDropdown(); await selectActivationKey('name0'); - await goToReviewStep(); + await goToReview(); await clickRevisitButton(); await screen.findByRole('heading', { name: /Register systems using this image/, @@ -275,7 +256,7 @@ describe('Registration request generated correctly', () => { test('register + insights + rhc', async () => { await renderCreateMode(); await goToRegistrationStep(); - await goToReviewStep(); + await goToReview(); // informational modal pops up in the first test only as it's tied // to a 'imageBuilder.saveAndBuildModalSeen' variable in localStorage await openAndDismissSaveAndBuildModal(); @@ -302,7 +283,7 @@ describe('Registration request generated correctly', () => { await goToRegistrationStep(); await clickShowAdditionalConnectionOptions(); await deselectEnableRemoteRemediations(); - await goToReviewStep(); + await goToReview(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedSubscription = { @@ -326,7 +307,7 @@ describe('Registration request generated correctly', () => { await goToRegistrationStep(); await clickShowAdditionalConnectionOptions(); await deselectPredictiveAnalytics(); - await goToReviewStep(); + await goToReview(); // informational modal pops up in the first test only as it's tied // to a 'imageBuilder.saveAndBuildModalSeen' variable in localStorage const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); @@ -353,7 +334,7 @@ describe('Registration request generated correctly', () => { await renderCreateMode(); await goToRegistrationStep(); await clickRegisterLater(); - await goToReviewStep(); + await goToReview(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedRequest = { @@ -371,7 +352,7 @@ describe('Registration request generated correctly', () => { await goToRegistrationStep(); await screen.findByDisplayValue('name0'); - await goToReviewStep(); + await goToReview(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedSubscription = { @@ -398,7 +379,7 @@ describe('Registration request generated correctly', () => { await goToRegistrationStep(); await screen.findByDisplayValue('name1'); - await goToReviewStep(); + await goToReview(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedSubscription = { diff --git a/src/test/Components/CreateImageWizard/steps/Repositories/Repositories.test.tsx b/src/test/Components/CreateImageWizard/steps/Repositories/Repositories.test.tsx index 120581dd..48f7d5e2 100644 --- a/src/test/Components/CreateImageWizard/steps/Repositories/Repositories.test.tsx +++ b/src/test/Components/CreateImageWizard/steps/Repositories/Repositories.test.tsx @@ -19,7 +19,8 @@ import { clickNext, clickRegisterLater, clickReviewAndFinish, - enterBlueprintName, + goToReview, + goToStep, interceptBlueprintRequest, interceptEditBlueprintRequest, openAndDismissSaveAndBuildModal, @@ -35,25 +36,7 @@ const goToRepositoriesStep = async () => { await waitFor(() => user.click(guestImageCheckBox)); await clickNext(); // Registration await clickRegisterLater(); - await clickNext(); // OpenSCAP - await clickNext(); // File system configuration - await clickNext(); // Repository snapshot/Repeatable builds - await clickNext(); // Custom repositories -}; - -const goToReviewStep = async () => { - 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 - await clickNext(); // First Boot - await clickNext(); // Details - await enterBlueprintName(); - await clickNext(); // Review + await goToStep(/Custom repositories/); }; const clickRevisitButton = async () => { @@ -234,7 +217,7 @@ describe('Step Custom repositories', () => { await renderCreateMode(); await goToRepositoriesStep(); await selectFirstRepository(); - await goToReviewStep(); + await goToReview(); await clickRevisitButton(); await screen.findByRole('heading', { name: /Custom repositories/ }); }); @@ -249,7 +232,7 @@ describe('Repositories request generated correctly', () => { await renderCreateMode(); await goToRepositoriesStep(); await selectFirstRepository(); - await goToReviewStep(); + await goToReview(); // informational modal pops up in the first test only as it's tied // to a 'imageBuilder.saveAndBuildModalSeen' variable in localStorage await openAndDismissSaveAndBuildModal(); @@ -303,7 +286,7 @@ describe('Repositories request generated correctly', () => { await renderCreateMode(); await goToRepositoriesStep(); await selectNginxRepository(); - await goToReviewStep(); + await goToReview(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedRequest: CreateBlueprintRequest = { @@ -322,7 +305,7 @@ describe('Repositories request generated correctly', () => { await goToRepositoriesStep(); await selectFirstRepository(); await deselectFirstRepository(); - await goToReviewStep(); + await goToReview(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedRequest = blueprintRequest; @@ -336,7 +319,7 @@ describe('Repositories request generated correctly', () => { await renderCreateMode(); await goToRepositoriesStep(); await clickBulkSelect(); - await goToReviewStep(); + await goToReview(); const receivedRequest = (await interceptBlueprintRequest( CREATE_BLUEPRINT, )) as CreateBlueprintRequest; diff --git a/src/test/Components/CreateImageWizard/steps/Review/Review.test.tsx b/src/test/Components/CreateImageWizard/steps/Review/Review.test.tsx index 08ff0583..82d9c351 100644 --- a/src/test/Components/CreateImageWizard/steps/Review/Review.test.tsx +++ b/src/test/Components/CreateImageWizard/steps/Review/Review.test.tsx @@ -6,6 +6,7 @@ import { clickBack, clickNext, clickRegisterLater, + goToReview, renderCreateMode, verifyCancelButton, } from '../../wizardTestUtils'; @@ -48,24 +49,6 @@ const handleRegistration = async () => { await clickRegisterLater(); }; -const goToReviewStep = async () => { - await clickNext(); // OpenSCAP - await clickNext(); // File system configuration - await clickNext(); // Repository snapshot/Repeatable builds - 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 - await clickNext(); // First boot script - await clickNext(); // Details - await clickNext(); // Review -}; - describe('Step Review', () => { beforeEach(() => { vi.clearAllMocks(); @@ -75,7 +58,7 @@ describe('Step Review', () => { test('has 3 buttons', async () => { await setupWithRhel(); await handleRegistration(); - await goToReviewStep(); + await goToReview(); await screen.findByRole('button', { name: /Create blueprint/ }); await screen.findByRole('button', { name: /Back/ }); await screen.findByRole('button', { name: /Cancel/ }); @@ -84,7 +67,7 @@ describe('Step Review', () => { test('clicking Back loads Image name', async () => { await setupWithRhel(); await handleRegistration(); - await goToReviewStep(); + await goToReview(); await clickBack(); await screen.findByRole('heading', { name: 'Details', @@ -94,14 +77,14 @@ describe('Step Review', () => { test('clicking Cancel loads landing page', async () => { await setupWithRhel(); await handleRegistration(); - await goToReviewStep(); + await goToReview(); await verifyCancelButton(router); }); test('has Registration expandable section for rhel', async () => { await setupWithRhel(); await handleRegistration(); - await goToReviewStep(); + await goToReview(); await screen.findByRole('heading', { name: /Review/ }); const registrationExpandable = await screen.findByTestId( @@ -115,7 +98,7 @@ describe('Step Review', () => { test('has no Registration expandable for centos', async () => { await setupWithCentos(); - await goToReviewStep(); + await goToReview(); await screen.findByRole('heading', { name: /Review/ }); expect( diff --git a/src/test/Components/CreateImageWizard/steps/Services/Services.test.tsx b/src/test/Components/CreateImageWizard/steps/Services/Services.test.tsx index 4ecbf8bd..4a97876a 100644 --- a/src/test/Components/CreateImageWizard/steps/Services/Services.test.tsx +++ b/src/test/Components/CreateImageWizard/steps/Services/Services.test.tsx @@ -14,7 +14,8 @@ import { clickBack, clickNext, clickRegisterLater, - enterBlueprintName, + goToReview, + goToStep, interceptBlueprintRequest, interceptEditBlueprintRequest, openAndDismissSaveAndBuildModal, @@ -34,18 +35,7 @@ const goToServicesStep = async () => { 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 + await goToStep(/Systemd services/i); }; const goToOpenSCAPStep = async () => { @@ -60,24 +50,7 @@ const goToOpenSCAPStep = async () => { }; const goFromOpenSCAPToServices = async () => { - 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 -}; - -const goToReviewStep = async () => { - await clickNext(); // First boot script - await clickNext(); // Details - await enterBlueprintName(); - await clickNext(); // Review + await goToStep(/Systemd services/i); }; const addDisabledService = async (service: string) => { @@ -239,7 +212,7 @@ describe('Step Services', () => { await renderCreateMode(); await goToServicesStep(); await addDisabledService('telnet'); - await goToReviewStep(); + await goToReview(); await clickRevisitButton(); await screen.findByRole('heading', { name: /Systemd services/ }); }); @@ -256,7 +229,7 @@ describe('Services request generated correctly', () => { await addDisabledService('telnet'); await addMaskedService('nfs-server'); await addEnabledService('httpd'); - await goToReviewStep(); + await goToReview(); // informational modal pops up in the first test only as it's tied // to a 'imageBuilder.saveAndBuildModalSeen' variable in localStorage await openAndDismissSaveAndBuildModal(); @@ -287,7 +260,7 @@ describe('Services request generated correctly', () => { await removeService('telnet'); await removeService('nfs-server'); await removeService('httpd'); - await goToReviewStep(); + await goToReview(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedRequest = { @@ -305,7 +278,7 @@ describe('Services request generated correctly', () => { await goToOpenSCAPStep(); await selectProfile(); await goFromOpenSCAPToServices(); - await goToReviewStep(); + await goToReview(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedRequest = { diff --git a/src/test/Components/CreateImageWizard/steps/Snapshot/Snapshot.test.tsx b/src/test/Components/CreateImageWizard/steps/Snapshot/Snapshot.test.tsx index d1f5169b..bd2ee191 100644 --- a/src/test/Components/CreateImageWizard/steps/Snapshot/Snapshot.test.tsx +++ b/src/test/Components/CreateImageWizard/steps/Snapshot/Snapshot.test.tsx @@ -15,8 +15,9 @@ import { clickNext, clickRegisterLater, clickReviewAndFinish, - enterBlueprintName, getNextButton, + goToReview, + goToStep, interceptBlueprintRequest, interceptEditBlueprintRequest, openAndDismissSaveAndBuildModal, @@ -32,24 +33,7 @@ const goToSnapshotStep = async () => { await waitFor(async () => user.click(guestImageCheckBox)); await clickNext(); // Registration await clickRegisterLater(); - await clickNext(); // OpenSCAP - await clickNext(); // File System - await clickNext(); // Repositories snapshot -}; - -const goToReviewStep = async () => { - 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 - await clickNext(); // First boot script - await enterBlueprintName(); - await clickNext(); // Review + await goToStep(/Repeatable build/); }; const clickRevisitButton = async () => { @@ -173,7 +157,7 @@ describe('repository snapshot tab - ', () => { await clickNext(); // To repositories step await selectFirstRepository(); - await goToReviewStep(); + await goToReview(); await clickContentDropdown(); const snapshotMethodElement = await getSnapshotMethodElement(); @@ -208,7 +192,7 @@ describe('repository snapshot tab - ', () => { await selectUseSnapshot(); await updateDatePickerWithValue('2024-04-22'); await clickNext(); // To repositories step - await goToReviewStep(); + await goToReview(); await clickContentDropdown(); const snapshotMethodElement = await getSnapshotMethodElement(); @@ -282,7 +266,7 @@ describe('repository snapshot tab - ', () => { }); await clickBulkSelect(); - await goToReviewStep(); + await goToReview(); // Check the date was passed correctly to the blueprint const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); @@ -306,7 +290,7 @@ describe('repository snapshot tab - ', () => { await selectUseSnapshot(); await updateDatePickerWithValue('2024-04-22'); await clickNext(); - await goToReviewStep(); + await goToReview(); await clickRevisitButton(); await screen.findByRole('heading', { name: /Custom repositories/i }); }); @@ -324,7 +308,7 @@ describe('repository snapshot tab - ', () => { expect(nextBtn).toBeEnabled(); }); await clickNext(); - await goToReviewStep(); + await goToReview(); await screen.findByText(/Use a content template/); }); }); diff --git a/src/test/Components/CreateImageWizard/steps/TargetEnvironment/AwsTarget.test.tsx b/src/test/Components/CreateImageWizard/steps/TargetEnvironment/AwsTarget.test.tsx index fddd9cbb..9cca8683 100644 --- a/src/test/Components/CreateImageWizard/steps/TargetEnvironment/AwsTarget.test.tsx +++ b/src/test/Components/CreateImageWizard/steps/TargetEnvironment/AwsTarget.test.tsx @@ -20,8 +20,8 @@ import { clickBack, clickNext, clickRegisterLater, - enterBlueprintName, getNextButton, + goToReview, interceptBlueprintRequest, interceptEditBlueprintRequest, openAndDismissSaveAndBuildModal, @@ -34,25 +34,10 @@ const goToAwsStep = async () => { await clickNext(); }; -const goToReview = async () => { +const goToReviewStep = async () => { await clickNext(); // Register await clickRegisterLater(); - await clickNext(); // OpenSCAP - await clickNext(); // File system customization - await clickNext(); // Snapshot repositories - 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 - await clickNext(); // FirstBoot - await clickNext(); // Details - await enterBlueprintName(); - await clickNext(); // Review + await goToReview(); }; const clickRevisitButton = async () => { @@ -208,7 +193,7 @@ describe('Step Upload to AWS', () => { await goToAwsStep(); await getSourceDropdown(); await selectSource(); - await goToReview(); + await goToReviewStep(); // informational modal pops up in the first test only as it's tied // to a 'imageBuilder.saveAndBuildModalSeen' variable in localStorage @@ -225,7 +210,7 @@ describe('Step Upload to AWS', () => { await goToAwsStep(); await chooseManualOption(); await enterAccountId(); - await goToReview(); + await goToReviewStep(); await clickRevisitButton(); await screen.findByRole('heading', { name: /Image output/ }); }); @@ -241,7 +226,7 @@ describe('AWS image type request generated correctly', () => { await selectAwsTarget(); await goToAwsStep(); await selectSource(); - await goToReview(); + await goToReviewStep(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedImageRequest: ImageRequest = { @@ -269,7 +254,7 @@ describe('AWS image type request generated correctly', () => { await goToAwsStep(); await chooseManualOption(); await enterAccountId(); - await goToReview(); + await goToReviewStep(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedImageRequest: ImageRequest = { @@ -298,7 +283,7 @@ describe('AWS image type request generated correctly', () => { await selectSource(); await clickBack(); await deselectAwsAndSelectGuestImage(); - await goToReview(); + await goToReviewStep(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); await waitFor(() => { diff --git a/src/test/Components/CreateImageWizard/steps/TargetEnvironment/AzureTarget.test.tsx b/src/test/Components/CreateImageWizard/steps/TargetEnvironment/AzureTarget.test.tsx index f371900d..c4faf685 100644 --- a/src/test/Components/CreateImageWizard/steps/TargetEnvironment/AzureTarget.test.tsx +++ b/src/test/Components/CreateImageWizard/steps/TargetEnvironment/AzureTarget.test.tsx @@ -20,8 +20,8 @@ import { clickBack, clickNext, clickRegisterLater, - enterBlueprintName, getNextButton, + goToReview, interceptBlueprintRequest, interceptEditBlueprintRequest, openAndDismissSaveAndBuildModal, @@ -37,25 +37,10 @@ const goToAzureStep = async () => { await clickNext(); }; -const goToReview = async () => { +const goToReviewStep = async () => { await clickNext(); // Register await clickRegisterLater(); - await clickNext(); // OpenSCAP - await clickNext(); // File system customization - await clickNext(); // Snapshot repositories - 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 - await clickNext(); // FirstBoot - await clickNext(); // Details - await enterBlueprintName(); - await clickNext(); // Review + await goToReview(); }; const clickRevisitButton = async () => { @@ -321,7 +306,7 @@ describe('Step Upload to Azure', () => { await goToAzureStep(); await selectSource('azureSource1'); await selectResourceGroup(); - await goToReview(); + await goToReviewStep(); await clickRevisitButton(); await screen.findByRole('heading', { name: /Image output/ }); }); @@ -338,7 +323,7 @@ describe('Azure image type request generated correctly', () => { await goToAzureStep(); await selectSource('azureSource1'); await selectResourceGroup(); - await goToReview(); + await goToReviewStep(); // informational modal pops up in the first test only as it's tied // to a 'imageBuilder.saveAndBuildModalSeen' variable in localStorage @@ -374,7 +359,7 @@ describe('Azure image type request generated correctly', () => { await enterTenantGuid(); await enterSubscriptionId(); await enterResourceGroup(); - await goToReview(); + await goToReviewStep(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedImageRequest: ImageRequest = { @@ -408,7 +393,7 @@ describe('Azure image type request generated correctly', () => { await enterSubscriptionId(); await enterResourceGroup(); await selectV1(); - await goToReview(); + await goToReviewStep(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedImageRequest: ImageRequest = { @@ -440,7 +425,7 @@ describe('Azure image type request generated correctly', () => { await selectSource('azureSource1'); await clickBack(); await deselectAzureAndSelectGuestImage(); - await goToReview(); + await goToReviewStep(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); await waitFor(() => { diff --git a/src/test/Components/CreateImageWizard/steps/TargetEnvironment/GCPTarget.test.tsx b/src/test/Components/CreateImageWizard/steps/TargetEnvironment/GCPTarget.test.tsx index c5175247..ad7e3825 100644 --- a/src/test/Components/CreateImageWizard/steps/TargetEnvironment/GCPTarget.test.tsx +++ b/src/test/Components/CreateImageWizard/steps/TargetEnvironment/GCPTarget.test.tsx @@ -16,8 +16,8 @@ import { clickBack, clickNext, clickRegisterLater, - enterBlueprintName, getNextButton, + goToReview, imageRequest, interceptBlueprintRequest, interceptEditBlueprintRequest, @@ -29,25 +29,10 @@ import { const GCP_ACCOUNT = 'test@gmail.com'; -const goToReview = async () => { +const goToReviewStep = async () => { await clickNext(); await clickRegisterLater(); - await clickNext(); // OpenSCAP - await clickNext(); // File system customization - await clickNext(); // Snapshot repositories - 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 - await clickNext(); // FirstBoot - await clickNext(); // Details - await enterBlueprintName(); - await clickNext(); // Review + await goToReview(); }; const clickRevisitButton = async () => { @@ -166,7 +151,7 @@ describe('Step Upload to Google', () => { await renderCreateMode(); await clickGCPTarget(); await selectGoogleAccount('Google account'); - await goToReview(); + await goToReviewStep(); await clickRevisitButton(); await screen.findByRole('heading', { name: /Image output/ }); }); @@ -181,7 +166,7 @@ describe('GCP image type request generated correctly', () => { await renderCreateMode(); await clickGCPTarget(); await selectGoogleAccount('Google account'); - await goToReview(); + await goToReviewStep(); // informational modal pops up in the first test only as it's tied // to a 'imageBuilder.saveAndBuildModalSeen' variable in localStorage await openAndDismissSaveAndBuildModal(); @@ -201,7 +186,7 @@ describe('GCP image type request generated correctly', () => { await renderCreateMode(); await clickGCPTarget(); await selectGoogleAccount('Service account'); - await goToReview(); + await goToReviewStep(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedImageRequest = createGCPCloudImage('gcp', { share_with_accounts: [`serviceAccount:${GCP_ACCOUNT}`], @@ -217,7 +202,7 @@ describe('GCP image type request generated correctly', () => { await renderCreateMode(); await clickGCPTarget(); await selectGoogleAccount('Google group'); - await goToReview(); + await goToReviewStep(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedImageRequest = createGCPCloudImage('gcp', { share_with_accounts: [`group:${GCP_ACCOUNT}`], @@ -235,7 +220,7 @@ describe('GCP image type request generated correctly', () => { await selectGoogleAccount( 'Google Workspace domain or Cloud Identity domain', ); - await goToReview(); + await goToReviewStep(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedImageRequest = createGCPCloudImage('gcp', { share_with_accounts: [`domain:${GCP_ACCOUNT}`], @@ -256,7 +241,7 @@ describe('GCP image type request generated correctly', () => { }); user.click(shareWithInsightOption); - await goToReview(); + await goToReviewStep(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedImageRequest = createGCPCloudImage('gcp', {}); const expectedRequest: CreateBlueprintRequest = { @@ -274,7 +259,7 @@ describe('GCP image type request generated correctly', () => { ); await clickBack(); await deselectGcpAndSelectGuestImage(); - await goToReview(); + await goToReviewStep(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); await waitFor(() => { diff --git a/src/test/Components/CreateImageWizard/steps/Timezone/Timezone.test.tsx b/src/test/Components/CreateImageWizard/steps/Timezone/Timezone.test.tsx index f80fd08b..11385a9a 100644 --- a/src/test/Components/CreateImageWizard/steps/Timezone/Timezone.test.tsx +++ b/src/test/Components/CreateImageWizard/steps/Timezone/Timezone.test.tsx @@ -10,7 +10,8 @@ import { clickBack, clickNext, clickRegisterLater, - enterBlueprintName, + goToReview, + goToStep, interceptBlueprintRequest, interceptEditBlueprintRequest, openAndDismissSaveAndBuildModal, @@ -29,25 +30,7 @@ const goToTimezoneStep = async () => { 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 -}; - -const goToReviewStep = async () => { - await clickNext(); // Locale - await clickNext(); // Hostname - await clickNext(); // Kernel - await clickNext(); // Firewall - await clickNext(); // Services - await clickNext(); // First boot script - await clickNext(); // Details - await enterBlueprintName(); - await clickNext(); // Review + await goToStep(/Timezone/); }; const selectTimezone = async () => { @@ -173,7 +156,7 @@ describe('Step Timezone', () => { await renderCreateMode(); await goToTimezoneStep(); await selectTimezone(); - await goToReviewStep(); + await goToReview(); await clickRevisitButton(); await screen.findByRole('heading', { name: /Timezone/ }); }); @@ -184,7 +167,7 @@ describe('Timezone request generated correctly', () => { await renderCreateMode(); await goToTimezoneStep(); await selectTimezone(); - await goToReviewStep(); + await goToReview(); // informational modal pops up in the first test only as it's tied // to a 'imageBuilder.saveAndBuildModalSeen' variable in localStorage await openAndDismissSaveAndBuildModal(); @@ -209,7 +192,7 @@ describe('Timezone request generated correctly', () => { await goToTimezoneStep(); await addNtpServerViaKeyDown('0.nl.pool.ntp.org'); await addNtpServerViaKeyDown('1.nl.pool.ntp.org'); - await goToReviewStep(); + await goToReview(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedRequest = { @@ -232,7 +215,7 @@ describe('Timezone request generated correctly', () => { await selectTimezone(); await addNtpServerViaKeyDown('0.nl.pool.ntp.org'); await addNtpServerViaKeyDown('1.nl.pool.ntp.org'); - await goToReviewStep(); + await goToReview(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedRequest = { diff --git a/src/test/Components/CreateImageWizard/steps/Users/Users.test.tsx b/src/test/Components/CreateImageWizard/steps/Users/Users.test.tsx index 95cabcb6..74018151 100644 --- a/src/test/Components/CreateImageWizard/steps/Users/Users.test.tsx +++ b/src/test/Components/CreateImageWizard/steps/Users/Users.test.tsx @@ -10,8 +10,9 @@ import { clickBack, clickNext, clickRegisterLater, - enterBlueprintName, getNextButton, + goToReview, + goToStep, interceptBlueprintRequest, interceptEditBlueprintRequest, openAndDismissSaveAndBuildModal, @@ -33,25 +34,7 @@ const chandlerPasswd = 'chandlerPass'; const goToUsersStep = async () => { 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 -}; - -const goToReviewStep = async () => { - await clickNext(); // Timezone - await clickNext(); // Locale - await clickNext(); // Hostname - await clickNext(); // Kernel - await clickNext(); // Firewall - await clickNext(); // Services - await clickNext(); // First boot - await clickNext(); // Details - await enterBlueprintName(); - await clickNext(); // Review + await goToStep(/Users/); }; const addAzureTarget = async () => { @@ -351,7 +334,7 @@ describe('Step Users', () => { await goToUsersStep(); await clickAddUser(); await addUserName(validUserName); - await goToReviewStep(); + await goToReview(); await clickRevisitButton(); await screen.findByRole('heading', { name: /Users/ }); }); @@ -373,7 +356,7 @@ describe('User request generated correctly', () => { await checkAdminCheckbox(); await addUserGroupByUserIndex('users', 0); await addUserGroupByUserIndex('widget', 0); - await goToReviewStep(); + await goToReview(); // informational modal pops up in the first test only as it's tied // to a 'imageBuilder.saveAndBuildModalSeen' variable in localStorage await openAndDismissSaveAndBuildModal(); @@ -410,7 +393,7 @@ describe('User request generated correctly', () => { await addUserGroupByUserIndex('widget', 0); await closeNthTab(0); await screen.findByText(/add a user to your image/i); - await goToReviewStep(); + await goToReview(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedRequest = { @@ -430,7 +413,7 @@ describe('User request generated correctly', () => { await addAndFillThreeUsers(); - await goToReviewStep(); + await goToReview(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedRequest = { @@ -474,7 +457,7 @@ describe('User request generated correctly', () => { await closeNthTab(1); await closeNthTab(0); - await goToReviewStep(); + await goToReview(); const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT); const expectedRequest = { diff --git a/src/test/Components/CreateImageWizard/wizardTestUtils.tsx b/src/test/Components/CreateImageWizard/wizardTestUtils.tsx index 18c9cf8b..8ef55596 100644 --- a/src/test/Components/CreateImageWizard/wizardTestUtils.tsx +++ b/src/test/Components/CreateImageWizard/wizardTestUtils.tsx @@ -255,6 +255,49 @@ export const getNextButton = async () => { return next; }; +export const goToReview = async ( + blueprintName: string = 'Red Velvet', + maxSteps: number = 25, +) => { + for (let stepIndex = 0; stepIndex < maxSteps; stepIndex++) { + const isOnReview = !!screen.queryByRole('heading', { name: /Review/ }); + if (isOnReview) { + return; + } + + const blueprintNameInput = screen.queryByRole('textbox', { + name: /blueprint name/i, + }); + if (blueprintNameInput) { + await enterBlueprintName(blueprintName); + } + + await clickNext(); + } + + throw new Error( + 'goToReview exceeded maxSteps without reaching the Review step', + ); +}; + +export const goToStep = async ( + targetHeading: string | RegExp, + maxSteps: number = 25, +) => { + for (let stepIndex = 0; stepIndex < maxSteps; stepIndex++) { + const isOnTarget = !!screen.queryByRole('heading', { name: targetHeading }); + if (isOnTarget) { + return; + } + + await clickNext(); + } + + throw new Error( + 'goToStep exceeded maxSteps without reaching the target step', + ); +}; + export const verifyCancelButton = async (router: RemixRouter | undefined) => { await clickCancel(); if (router) {