V1Wizard: Add search parameter for target selection (HMS-3684)
Add an optional search parameter to the V1Wizard like so: `/insights/image-builder/imagewizard?target=iso` or `/insights/image-builder/imagewizard?target=qcow` This results in wizard being opened and iso or qcow target being pre-selected. The Insights assistant chat bot will make use of this feature.
This commit is contained in:
parent
2d8b2b2796
commit
76fba98773
2 changed files with 129 additions and 57 deletions
|
|
@ -18,6 +18,7 @@ import {
|
|||
import { HelpIcon } from '@patternfly/react-icons';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useField } from 'react-final-form';
|
||||
import { useSearchParams } from 'react-router-dom';
|
||||
|
||||
import { useGetArchitecturesQuery } from '../../../store/imageBuilderApi';
|
||||
import { provisioningApi } from '../../../store/provisioningApi';
|
||||
|
|
@ -63,6 +64,16 @@ const TargetEnvironment = ({ label, isRequired, ...props }) => {
|
|||
const { isBeta } = useGetEnvironment();
|
||||
const release = getState()?.values?.release;
|
||||
|
||||
const [searchParams] = useSearchParams();
|
||||
|
||||
// Set the target via search parameter
|
||||
// Used by Insights assistant or external hyperlinks (access.redhat.com, developers.redhat.com)
|
||||
const preloadTarget = searchParams.get('target');
|
||||
useEffect(() => {
|
||||
preloadTarget === 'iso' && handleSetEnvironment('image-installer', true);
|
||||
preloadTarget === 'qcow' && handleSetEnvironment('guest-image', true);
|
||||
}, [preloadTarget]);
|
||||
|
||||
useEffect(() => {
|
||||
if (getState()?.values?.[input.name]) {
|
||||
setEnvironment(getState().values[input.name]);
|
||||
|
|
|
|||
|
|
@ -99,6 +99,18 @@ const getSourceDropdown = async () => {
|
|||
return sourceDropdown;
|
||||
};
|
||||
|
||||
const clickToReview = async () => {
|
||||
await clickNext();
|
||||
await userEvent.click(
|
||||
await screen.findByRole('radio', { name: /Register later/ })
|
||||
);
|
||||
await clickNext(); // skip Registration
|
||||
await clickNext(); // skip FSC
|
||||
await clickNext(); // skip Repositories
|
||||
await clickNext(); // skip Packages
|
||||
await clickNext(); // skip Details
|
||||
};
|
||||
|
||||
beforeAll(() => {
|
||||
// scrollTo is not defined in jsdom
|
||||
window.HTMLElement.prototype.scrollTo = function () {};
|
||||
|
|
@ -1507,6 +1519,112 @@ describe('Click through all steps', () => {
|
|||
}, 20000);
|
||||
});
|
||||
|
||||
describe('set release using query parameter', () => {
|
||||
test('rhel 9 by default (no query parameter)', async () => {
|
||||
({ router } = await renderCustomRoutesWithReduxRouter(
|
||||
'imagewizard',
|
||||
{},
|
||||
routes
|
||||
));
|
||||
await screen.findByText('Red Hat Enterprise Linux (RHEL) 9');
|
||||
});
|
||||
|
||||
test('rhel 9 by default (invalid query parameter)', async () => {
|
||||
({ router } = await renderCustomRoutesWithReduxRouter(
|
||||
'imagewizard?release=rhel9000',
|
||||
{},
|
||||
routes
|
||||
));
|
||||
await screen.findByText('Red Hat Enterprise Linux (RHEL) 9');
|
||||
});
|
||||
|
||||
test('rhel 8 (query parameter provided)', async () => {
|
||||
({ router } = await renderCustomRoutesWithReduxRouter(
|
||||
'imagewizard?release=rhel8',
|
||||
{},
|
||||
routes
|
||||
));
|
||||
await screen.findByText('Red Hat Enterprise Linux (RHEL) 8');
|
||||
});
|
||||
});
|
||||
describe('set architecture using query parameter', () => {
|
||||
test('x86_64 by default (no query parameter)', async () => {
|
||||
({ router } = await renderCustomRoutesWithReduxRouter(
|
||||
'imagewizard',
|
||||
{},
|
||||
routes
|
||||
));
|
||||
await screen.findByText('x86_64');
|
||||
});
|
||||
|
||||
test('x86_64 by default (invalid query parameter)', async () => {
|
||||
({ router } = await renderCustomRoutesWithReduxRouter(
|
||||
'imagewizard?arch=arm',
|
||||
{},
|
||||
routes
|
||||
));
|
||||
await screen.findByText('x86_64');
|
||||
});
|
||||
|
||||
test('aarch64 (query parameter provided)', async () => {
|
||||
({ router } = await renderCustomRoutesWithReduxRouter(
|
||||
'imagewizard?arch=aarch64',
|
||||
{},
|
||||
routes
|
||||
));
|
||||
await screen.findByText('aarch64');
|
||||
});
|
||||
});
|
||||
describe('set target using query parameter', () => {
|
||||
test('no target by default (no query parameter)', async () => {
|
||||
({ router } = await renderCustomRoutesWithReduxRouter(
|
||||
'imagewizard',
|
||||
{},
|
||||
routes
|
||||
));
|
||||
const nextButton = await screen.findByRole('button', { name: /Next/ });
|
||||
expect(nextButton).toBeDisabled();
|
||||
});
|
||||
|
||||
test('no target by default (invalid query parameter)', async () => {
|
||||
({ router } = await renderCustomRoutesWithReduxRouter(
|
||||
'imagewizard?target=azure',
|
||||
{},
|
||||
routes
|
||||
));
|
||||
const nextButton = await screen.findByRole('button', { name: /Next/ });
|
||||
expect(nextButton).toBeDisabled();
|
||||
});
|
||||
|
||||
test('image-installer (query parameter provided)', async () => {
|
||||
({ router } = await renderCustomRoutesWithReduxRouter(
|
||||
'imagewizard?target=iso',
|
||||
{},
|
||||
routes
|
||||
));
|
||||
await clickToReview();
|
||||
const targetExpandable = await screen.findByRole('button', {
|
||||
name: /Target environments/,
|
||||
});
|
||||
await userEvent.click(targetExpandable);
|
||||
await screen.findByText('Bare metal - Installer (.iso)');
|
||||
});
|
||||
|
||||
test('guest-installer (query parameter provided)', async () => {
|
||||
({ router } = await renderCustomRoutesWithReduxRouter(
|
||||
'imagewizard?target=qcow',
|
||||
{},
|
||||
routes
|
||||
));
|
||||
await clickToReview();
|
||||
const targetExpandable = await screen.findByRole('button', {
|
||||
name: /Target environments/,
|
||||
});
|
||||
await userEvent.click(targetExpandable);
|
||||
await screen.findByText('Virtualization - Guest image (.qcow2)');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Keyboard accessibility', () => {
|
||||
const user = userEvent.setup();
|
||||
const setUp = async () => {
|
||||
|
|
@ -1656,60 +1774,3 @@ describe('Keyboard accessibility', () => {
|
|||
testTile(await screen.findByTestId('upload-azure'));
|
||||
});
|
||||
});
|
||||
|
||||
describe('set release using query parameter', () => {
|
||||
test('rhel 9 by default (no query parameter)', async () => {
|
||||
({ router } = await renderCustomRoutesWithReduxRouter(
|
||||
'imagewizard',
|
||||
{},
|
||||
routes
|
||||
));
|
||||
await screen.findByText('Red Hat Enterprise Linux (RHEL) 9');
|
||||
});
|
||||
|
||||
test('rhel 9 by default (invalid query parameter)', async () => {
|
||||
({ router } = await renderCustomRoutesWithReduxRouter(
|
||||
'imagewizard?release=rhel9000',
|
||||
{},
|
||||
routes
|
||||
));
|
||||
await screen.findByText('Red Hat Enterprise Linux (RHEL) 9');
|
||||
});
|
||||
|
||||
test('rhel 8 (query parameter provided)', async () => {
|
||||
({ router } = await renderCustomRoutesWithReduxRouter(
|
||||
'imagewizard?release=rhel8',
|
||||
{},
|
||||
routes
|
||||
));
|
||||
await screen.findByText('Red Hat Enterprise Linux (RHEL) 8');
|
||||
});
|
||||
});
|
||||
describe('set architecture using query parameter', () => {
|
||||
test('x86_64 by default (no query parameter)', async () => {
|
||||
({ router } = await renderCustomRoutesWithReduxRouter(
|
||||
'imagewizard',
|
||||
{},
|
||||
routes
|
||||
));
|
||||
await screen.findByText('x86_64');
|
||||
});
|
||||
|
||||
test('x86_64 by default (invalid query parameter)', async () => {
|
||||
({ router } = await renderCustomRoutesWithReduxRouter(
|
||||
'imagewizard?arch=arm',
|
||||
{},
|
||||
routes
|
||||
));
|
||||
await screen.findByText('x86_64');
|
||||
});
|
||||
|
||||
test('aarch64 (query parameter provided)', async () => {
|
||||
({ router } = await renderCustomRoutesWithReduxRouter(
|
||||
'imagewizard?arch=aarch64',
|
||||
{},
|
||||
routes
|
||||
));
|
||||
await screen.findByText('aarch64');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue