test: Clean up Registration tests and enable a test
This cleans up Registration tests and re-enables "clicking Cancel loads landing page" test.
This commit is contained in:
parent
be95cd9dc0
commit
4fa0ad863b
1 changed files with 32 additions and 37 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
import type { Router as RemixRouter } from '@remix-run/router';
|
||||||
import { screen, waitFor } from '@testing-library/react';
|
import { screen, waitFor } from '@testing-library/react';
|
||||||
import { userEvent } from '@testing-library/user-event';
|
import { userEvent } from '@testing-library/user-event';
|
||||||
|
|
||||||
|
|
@ -23,6 +24,7 @@ import {
|
||||||
openAndDismissSaveAndBuildModal,
|
openAndDismissSaveAndBuildModal,
|
||||||
clickNext,
|
clickNext,
|
||||||
clickBack,
|
clickBack,
|
||||||
|
verifyCancelButton,
|
||||||
} from '../../wizardTestUtils';
|
} from '../../wizardTestUtils';
|
||||||
|
|
||||||
const localStorageMock = (() => {
|
const localStorageMock = (() => {
|
||||||
|
|
@ -40,6 +42,9 @@ Object.defineProperty(window, 'localStorage', {
|
||||||
value: localStorageMock,
|
value: localStorageMock,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Initiliaze the router
|
||||||
|
const router: RemixRouter | undefined = undefined;
|
||||||
|
|
||||||
const clickShowAdditionalConnectionOptions = async () => {
|
const clickShowAdditionalConnectionOptions = async () => {
|
||||||
const user = userEvent.setup();
|
const user = userEvent.setup();
|
||||||
const link = await screen.findByText('Show additional connection options');
|
const link = await screen.findByText('Show additional connection options');
|
||||||
|
|
@ -62,6 +67,23 @@ const deselectPredictiveAnalytics = async () => {
|
||||||
await waitFor(() => user.click(checkBox));
|
await waitFor(() => user.click(checkBox));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const openActivationKeyDropdown = async () => {
|
||||||
|
const user = userEvent.setup();
|
||||||
|
const activationKeyDropdown = await screen.findByRole('textbox', {
|
||||||
|
name: 'Select activation key',
|
||||||
|
});
|
||||||
|
user.click(activationKeyDropdown);
|
||||||
|
};
|
||||||
|
|
||||||
|
const selectActivationKey = async (key: string) => {
|
||||||
|
const user = userEvent.setup();
|
||||||
|
const activationKey = await screen.findByRole('option', {
|
||||||
|
name: key,
|
||||||
|
});
|
||||||
|
user.click(activationKey);
|
||||||
|
await screen.findByDisplayValue(key);
|
||||||
|
};
|
||||||
|
|
||||||
const goToReviewStep = async () => {
|
const goToReviewStep = async () => {
|
||||||
await clickNext();
|
await clickNext();
|
||||||
await clickNext();
|
await clickNext();
|
||||||
|
|
@ -79,19 +101,11 @@ describe('Step Registration', () => {
|
||||||
vi.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
});
|
});
|
||||||
|
|
||||||
const user = userEvent.setup();
|
|
||||||
|
|
||||||
test('clicking Next leads to OpenSCAP step', async () => {
|
test('clicking Next leads to OpenSCAP step', async () => {
|
||||||
await renderCreateMode();
|
await renderCreateMode();
|
||||||
await goToRegistrationStep();
|
await goToRegistrationStep();
|
||||||
|
await clickRegisterLater();
|
||||||
const registrationCheckbox = await screen.findByTestId(
|
|
||||||
'automatically-register-checkbox'
|
|
||||||
);
|
|
||||||
user.click(registrationCheckbox);
|
|
||||||
|
|
||||||
await clickNext();
|
await clickNext();
|
||||||
|
|
||||||
await screen.findByRole('heading', {
|
await screen.findByRole('heading', {
|
||||||
name: 'OpenSCAP profile',
|
name: 'OpenSCAP profile',
|
||||||
});
|
});
|
||||||
|
|
@ -100,36 +114,25 @@ describe('Step Registration', () => {
|
||||||
test('clicking Back leads to Image output step', async () => {
|
test('clicking Back leads to Image output step', async () => {
|
||||||
await renderCreateMode();
|
await renderCreateMode();
|
||||||
await goToRegistrationStep();
|
await goToRegistrationStep();
|
||||||
|
|
||||||
await clickBack();
|
await clickBack();
|
||||||
|
|
||||||
await screen.findByRole('heading', {
|
await screen.findByRole('heading', {
|
||||||
name: 'Image output',
|
name: 'Image output',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// test('clicking Cancel loads landing page', async () => {
|
test('clicking Cancel loads landing page', async () => {
|
||||||
// await renderCreateMode();
|
await renderCreateMode();
|
||||||
// await goToRegistrationStep();
|
await goToRegistrationStep();
|
||||||
//
|
await verifyCancelButton(router);
|
||||||
// await verifyCancelButton(router);
|
});
|
||||||
// });
|
|
||||||
|
|
||||||
test('default registration includes rhsm, rhc and insights', async () => {
|
test('default registration includes rhsm, rhc and insights', async () => {
|
||||||
await renderCreateMode();
|
await renderCreateMode();
|
||||||
await goToRegistrationStep();
|
await goToRegistrationStep();
|
||||||
|
await openActivationKeyDropdown();
|
||||||
const activationKeyDropdown = await screen.findByRole('textbox', {
|
await selectActivationKey('name0');
|
||||||
name: 'Select activation key',
|
|
||||||
});
|
|
||||||
user.click(activationKeyDropdown);
|
|
||||||
const activationKey = await screen.findByRole('option', {
|
|
||||||
name: 'name0',
|
|
||||||
});
|
|
||||||
user.click(activationKey);
|
|
||||||
await screen.findByDisplayValue('name0');
|
|
||||||
|
|
||||||
await goToReviewStep();
|
await goToReviewStep();
|
||||||
|
|
||||||
const review = await screen.findByTestId('review-registration');
|
const review = await screen.findByTestId('review-registration');
|
||||||
expect(review).toHaveTextContent(
|
expect(review).toHaveTextContent(
|
||||||
'Register with Red Hat Subscription Manager (RHSM)'
|
'Register with Red Hat Subscription Manager (RHSM)'
|
||||||
|
|
@ -143,26 +146,18 @@ describe('Step Registration', () => {
|
||||||
test('should disable dropdown when clicking Register the system later', async () => {
|
test('should disable dropdown when clicking Register the system later', async () => {
|
||||||
await renderCreateMode();
|
await renderCreateMode();
|
||||||
await goToRegistrationStep();
|
await goToRegistrationStep();
|
||||||
await screen.findByTestId('selected-activation-key');
|
await clickRegisterLater();
|
||||||
|
|
||||||
// click the later radio button which should remove any input fields
|
|
||||||
const registrationCheckbox = await screen.findByTestId(
|
|
||||||
'automatically-register-checkbox'
|
|
||||||
);
|
|
||||||
await waitFor(async () => user.click(registrationCheckbox));
|
|
||||||
|
|
||||||
await waitFor(() =>
|
await waitFor(() =>
|
||||||
expect(
|
expect(
|
||||||
screen.queryByTestId('selected-activation-key')
|
screen.queryByTestId('selected-activation-key')
|
||||||
).not.toBeInTheDocument()
|
).not.toBeInTheDocument()
|
||||||
);
|
);
|
||||||
|
|
||||||
await waitFor(async () =>
|
await waitFor(async () =>
|
||||||
expect(
|
expect(
|
||||||
await screen.findByRole('button', { name: /options menu/i })
|
await screen.findByRole('button', { name: /options menu/i })
|
||||||
).toBeDisabled()
|
).toBeDisabled()
|
||||||
);
|
);
|
||||||
|
|
||||||
await goToReviewStep();
|
await goToReviewStep();
|
||||||
await screen.findByText('Register the system later');
|
await screen.findByText('Register the system later');
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue