test: Clean up GCP tests
This cleans up GCP test file after relevant tests were moved there from `CreateImageWizard.test.tsx`.
This commit is contained in:
parent
2168bc31d8
commit
57e4ed1f4b
1 changed files with 17 additions and 61 deletions
|
|
@ -1,10 +1,7 @@
|
||||||
import React from 'react';
|
|
||||||
|
|
||||||
import type { Router as RemixRouter } from '@remix-run/router';
|
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';
|
||||||
|
|
||||||
import CreateImageWizard from '../../../../../Components/CreateImageWizard/CreateImageWizard';
|
|
||||||
import { CREATE_BLUEPRINT, EDIT_BLUEPRINT } from '../../../../../constants';
|
import { CREATE_BLUEPRINT, EDIT_BLUEPRINT } from '../../../../../constants';
|
||||||
import {
|
import {
|
||||||
CreateBlueprintRequest,
|
CreateBlueprintRequest,
|
||||||
|
|
@ -14,7 +11,6 @@ import {
|
||||||
} from '../../../../../store/imageBuilderApi';
|
} from '../../../../../store/imageBuilderApi';
|
||||||
import { mockBlueprintIds } from '../../../../fixtures/blueprints';
|
import { mockBlueprintIds } from '../../../../fixtures/blueprints';
|
||||||
import { gcpCreateBlueprintRequest } from '../../../../fixtures/editMode';
|
import { gcpCreateBlueprintRequest } from '../../../../fixtures/editMode';
|
||||||
import { renderCustomRoutesWithReduxRouter } from '../../../../testUtils';
|
|
||||||
import {
|
import {
|
||||||
clickBack,
|
clickBack,
|
||||||
clickNext,
|
clickNext,
|
||||||
|
|
@ -90,16 +86,6 @@ const selectGoogleAccount = async (optionId: string) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
let router: RemixRouter | undefined = undefined;
|
let router: RemixRouter | undefined = undefined;
|
||||||
const routes = [
|
|
||||||
{
|
|
||||||
path: 'insights/image-builder/*',
|
|
||||||
element: <div />,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'insights/image-builder/imagewizard/:composeId?',
|
|
||||||
element: <CreateImageWizard />,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
describe('Step Upload to Google', () => {
|
describe('Step Upload to Google', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
@ -108,77 +94,43 @@ describe('Step Upload to Google', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const user = userEvent.setup();
|
const user = userEvent.setup();
|
||||||
const setUp = async () => {
|
|
||||||
({ router } = await renderCustomRoutesWithReduxRouter(
|
|
||||||
'imagewizard',
|
|
||||||
{},
|
|
||||||
routes
|
|
||||||
));
|
|
||||||
|
|
||||||
// select gcp as upload destination
|
|
||||||
const uploadGcp = await screen.findByTestId('upload-google');
|
|
||||||
|
|
||||||
user.click(uploadGcp);
|
|
||||||
|
|
||||||
await clickNext();
|
|
||||||
|
|
||||||
await screen.findByRole('heading', {
|
|
||||||
name: 'Target environment - Google Cloud Platform',
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
test('clicking Next loads Registration', async () => {
|
test('clicking Next loads Registration', async () => {
|
||||||
await setUp();
|
await clickGCPTarget();
|
||||||
|
await selectGoogleAccount('google-account');
|
||||||
const shareRadioButton = await screen.findByText(
|
|
||||||
/share image with a google account/i
|
|
||||||
);
|
|
||||||
user.click(shareRadioButton);
|
|
||||||
|
|
||||||
const googleEmailInput = await screen.findByTestId('principal');
|
|
||||||
|
|
||||||
await waitFor(() => user.type(googleEmailInput, 'test@test.com'));
|
|
||||||
await clickNext();
|
await clickNext();
|
||||||
|
await screen.findByRole('heading', {
|
||||||
await screen.findByRole('textbox', {
|
name: 'Register systems using this image',
|
||||||
name: 'Select activation key',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
await screen.findByText(
|
|
||||||
'Automatically register and enable advanced capabilities'
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('clicking Back loads Release', async () => {
|
test('clicking Back loads Image output', async () => {
|
||||||
await setUp();
|
await clickGCPTarget();
|
||||||
|
|
||||||
await clickBack();
|
await clickBack();
|
||||||
|
await screen.findByRole('heading', { name: 'Image output' });
|
||||||
await screen.findByTestId('upload-google');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('clicking Cancel loads landing page', async () => {
|
test('clicking Cancel loads landing page', async () => {
|
||||||
await setUp();
|
await clickGCPTarget();
|
||||||
|
|
||||||
await verifyCancelButton(router);
|
await verifyCancelButton(router);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('the google account id field is shown and required', async () => {
|
test('the google account id field is shown and required', async () => {
|
||||||
await setUp();
|
await clickGCPTarget();
|
||||||
|
|
||||||
const principalInput = await screen.findByTestId('principal');
|
const principalInput = await screen.findByTestId('principal');
|
||||||
expect(principalInput).toHaveValue('');
|
expect(principalInput).toHaveValue('');
|
||||||
expect(principalInput).toBeEnabled();
|
expect(await getNextButton()).toBeDisabled();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('the google email field must be a valid email', async () => {
|
test('the google email field must be a valid email', async () => {
|
||||||
await setUp();
|
await clickGCPTarget();
|
||||||
|
|
||||||
await waitFor(async () =>
|
await waitFor(async () =>
|
||||||
user.type(await screen.findByTestId('principal'), 'a')
|
user.type(await screen.findByTestId('principal'), 'a')
|
||||||
);
|
);
|
||||||
expect(await getNextButton()).toHaveClass('pf-m-disabled');
|
expect(await getNextButton()).toHaveClass('pf-m-disabled');
|
||||||
expect(await getNextButton()).toBeDisabled();
|
expect(await getNextButton()).toBeDisabled();
|
||||||
|
|
||||||
await waitFor(async () =>
|
await waitFor(async () =>
|
||||||
user.type(await screen.findByTestId('principal'), 'test@test.com')
|
user.type(await screen.findByTestId('principal'), 'test@test.com')
|
||||||
);
|
);
|
||||||
|
|
@ -187,7 +139,7 @@ describe('Step Upload to Google', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('gcp image type request generated correctly', () => {
|
describe('GCP image type request generated correctly', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
vi.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
});
|
});
|
||||||
|
|
@ -210,6 +162,7 @@ describe('gcp image type request generated correctly', () => {
|
||||||
};
|
};
|
||||||
expect(receivedRequest).toEqual(expectedRequest);
|
expect(receivedRequest).toEqual(expectedRequest);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('share image with service account', async () => {
|
test('share image with service account', async () => {
|
||||||
await clickGCPTarget();
|
await clickGCPTarget();
|
||||||
await selectGoogleAccount('service-account');
|
await selectGoogleAccount('service-account');
|
||||||
|
|
@ -224,6 +177,7 @@ describe('gcp image type request generated correctly', () => {
|
||||||
};
|
};
|
||||||
expect(receivedRequest).toEqual(expectedRequest);
|
expect(receivedRequest).toEqual(expectedRequest);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('share image with google group', async () => {
|
test('share image with google group', async () => {
|
||||||
await clickGCPTarget();
|
await clickGCPTarget();
|
||||||
await selectGoogleAccount('google-group');
|
await selectGoogleAccount('google-group');
|
||||||
|
|
@ -238,6 +192,7 @@ describe('gcp image type request generated correctly', () => {
|
||||||
};
|
};
|
||||||
expect(receivedRequest).toEqual(expectedRequest);
|
expect(receivedRequest).toEqual(expectedRequest);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('share image with domain', async () => {
|
test('share image with domain', async () => {
|
||||||
await clickGCPTarget();
|
await clickGCPTarget();
|
||||||
await selectGoogleAccount('google-domain');
|
await selectGoogleAccount('google-domain');
|
||||||
|
|
@ -252,6 +207,7 @@ describe('gcp image type request generated correctly', () => {
|
||||||
};
|
};
|
||||||
expect(receivedRequest).toEqual(expectedRequest);
|
expect(receivedRequest).toEqual(expectedRequest);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('share image with red hat insight only', async () => {
|
test('share image with red hat insight only', async () => {
|
||||||
const user = userEvent.setup();
|
const user = userEvent.setup();
|
||||||
await clickGCPTarget();
|
await clickGCPTarget();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue