V2 Wizard: Add search parameter for release selection (HMS-3684)

Adding an optional search parameter to the V2 wizard like so:

/insights/image-builder/imagewizard?release=rhel8

results in the wizard being opened and RHEL 8 being pre-selected as the release.

The Insights assistant chat bot will make use of this feature.

The render() test utility function had to be updated to accept an
optional searchParams argument.
This commit is contained in:
lucasgarfield 2024-03-01 18:09:57 +01:00 committed by Lucas Garfield
parent f9350956f7
commit ad5d2007bb
3 changed files with 38 additions and 3 deletions

View file

@ -9,6 +9,7 @@ import { AARCH64, RHEL_8, RHEL_9, X86_64 } from '../../../../../constants';
import { mockArchitecturesByDistro } from '../../../../fixtures/architectures';
import { server } from '../../../../mocks/server';
import { renderCustomRoutesWithReduxRouter } from '../../../../testUtils';
import { render } from '../../wizardTestUtils';
const routes = [
{
@ -258,3 +259,20 @@ describe('Check step consistency', () => {
await waitFor(() => expect(next).toBeEnabled());
});
});
describe('set release using query parameter', () => {
test('rhel 9 by default (no query parameter)', async () => {
await render();
await screen.findByText('Red Hat Enterprise Linux (RHEL) 9');
});
test('rhel 9 by default (invalid query parameter)', async () => {
await render({ release: 'rhel9001' });
await screen.findByText('Red Hat Enterprise Linux (RHEL) 9');
});
test('rhel 8 (query parameter provided)', async () => {
await render({ release: 'rhel8' });
await screen.findByText('Red Hat Enterprise Linux (RHEL) 8');
});
});