Wizard: add tests for satellite registration
This commit is contained in:
parent
75792bcc0a
commit
d2c9b77957
6 changed files with 111 additions and 13 deletions
|
|
@ -14,6 +14,11 @@ import {
|
|||
ImageRequest,
|
||||
} from '../../../../../store/imageBuilderApi';
|
||||
import { mockBlueprintIds } from '../../../../fixtures/blueprints';
|
||||
import {
|
||||
CERTIFICATE,
|
||||
SATELLITE_COMMAND,
|
||||
SATELLITE_COMMAND_EXPIRED_TOKEN,
|
||||
} from '../../../../fixtures/customizations';
|
||||
import { registrationCreateBlueprintRequest } from '../../../../fixtures/editMode';
|
||||
import { server } from '../../../../mocks/server';
|
||||
import {
|
||||
|
|
@ -29,6 +34,8 @@ import {
|
|||
clickBack,
|
||||
verifyCancelButton,
|
||||
clickReviewAndFinish,
|
||||
getNextButton,
|
||||
clickRegisterSatellite,
|
||||
} from '../../wizardTestUtils';
|
||||
|
||||
const localStorageMock = (() => {
|
||||
|
|
@ -88,6 +95,29 @@ const selectActivationKey = async (key: string) => {
|
|||
await screen.findByDisplayValue(key);
|
||||
};
|
||||
|
||||
const addSatelliteRegistrationCommandViaKeyDown = async (command: string) => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const satelliteRegistrationCommand = await screen.findByPlaceholderText(
|
||||
/registration command/i
|
||||
);
|
||||
|
||||
await waitFor(() => user.type(satelliteRegistrationCommand, command));
|
||||
};
|
||||
|
||||
const uploadFile = async (scriptName: string): Promise<void> => {
|
||||
const user = userEvent.setup();
|
||||
const fileInput: HTMLElement | null =
|
||||
// eslint-disable-next-line testing-library/no-node-access
|
||||
document.querySelector('input[type="file"]');
|
||||
|
||||
if (fileInput) {
|
||||
const file = new File([scriptName], 'certificate.pem', {
|
||||
type: 'application/x-pem-file',
|
||||
});
|
||||
await waitFor(() => user.upload(fileInput, file));
|
||||
}
|
||||
};
|
||||
|
||||
const goToReviewStep = async () => {
|
||||
await clickNext(); // Registration
|
||||
await clickNext(); // OpenSCAP
|
||||
|
|
@ -389,6 +419,29 @@ describe('Registration request generated correctly', () => {
|
|||
// clear mocked values in localStorage so they don't affect following tests
|
||||
localStorage.clear();
|
||||
});
|
||||
|
||||
test('register with satellite', async () => {
|
||||
await renderCreateMode();
|
||||
await goToRegistrationStep();
|
||||
await clickRegisterSatellite();
|
||||
|
||||
const nextButton = await getNextButton();
|
||||
expect(nextButton).toBeDisabled();
|
||||
|
||||
await uploadFile(CERTIFICATE);
|
||||
expect(nextButton).toBeDisabled();
|
||||
await addSatelliteRegistrationCommandViaKeyDown(
|
||||
SATELLITE_COMMAND_EXPIRED_TOKEN
|
||||
);
|
||||
|
||||
const expiredTokenHelper = await screen.findByText(
|
||||
/The token is already expired or will expire by next day. Expiration date/i
|
||||
);
|
||||
await waitFor(() => expect(expiredTokenHelper).toBeInTheDocument());
|
||||
|
||||
await addSatelliteRegistrationCommandViaKeyDown(SATELLITE_COMMAND);
|
||||
expect(nextButton).toBeEnabled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Registration edit mode', () => {
|
||||
|
|
|
|||
|
|
@ -122,6 +122,17 @@ export const clickRegisterLater = async () => {
|
|||
await waitFor(() => user.click(registerLaterRadio));
|
||||
};
|
||||
|
||||
export const clickRegisterSatellite = async () => {
|
||||
const user = userEvent.setup();
|
||||
await screen.findByRole('heading', {
|
||||
name: /Register systems using this image/,
|
||||
});
|
||||
const registerLaterRadio = await screen.findByRole('radio', {
|
||||
name: /register with satellite/i,
|
||||
});
|
||||
await waitFor(() => user.click(registerLaterRadio));
|
||||
};
|
||||
|
||||
export const goToOscapStep = async () => {
|
||||
await clickNext(); // Registration
|
||||
await clickRegisterLater();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue