diff --git a/src/test/Components/CreateImageWizard/CreateImageWizard.azure.2.test.js b/src/test/Components/CreateImageWizard/CreateImageWizard.azure.2.test.js deleted file mode 100644 index cd68b21b..00000000 --- a/src/test/Components/CreateImageWizard/CreateImageWizard.azure.2.test.js +++ /dev/null @@ -1,86 +0,0 @@ -import React from 'react'; -import '@testing-library/jest-dom'; - -import { screen } from '@testing-library/react'; -import userEvent from '@testing-library/user-event'; -import { rest } from 'msw'; - -import CreateImageWizard from '../../../Components/CreateImageWizard/CreateImageWizard'; -import ShareImageModal from '../../../Components/ShareImageModal/ShareImageModal'; -import { PROVISIONING_API } from '../../../constants.js'; -import { server } from '../../mocks/server.js'; -import { clickNext, renderCustomRoutesWithReduxRouter } from '../../testUtils'; - -const routes = [ - { - path: 'insights/image-builder/*', - element:
, - }, - { - path: 'insights/image-builder/imagewizard/:composeId?', - element: , - }, - { - path: 'insights/image-builder/share/:composeId', - element: , - }, -]; - -jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({ - useChrome: () => ({ - auth: { - getUser: () => { - return { - identity: { - internal: { - org_id: 5, - }, - }, - }; - }, - }, - isBeta: () => false, - isProd: () => true, - getEnvironment: () => 'prod', - }), -})); - -describe('Step Upload to Azure', () => { - beforeAll(() => { - // scrollTo is not defined in jsdom - window.HTMLElement.prototype.scrollTo = function () {}; - }); - - afterEach(() => { - jest.clearAllMocks(); - }); - - const user = userEvent.setup(); - - const setUp = async () => { - renderCustomRoutesWithReduxRouter('imagewizard', {}, routes); - // select Azure as upload destination - await user.click(screen.getByTestId('upload-azure')); - - await clickNext(); - - expect(screen.getByRole('heading', { level: 1 })).toHaveTextContent( - 'Target environment - Microsoft Azure' - ); - }; - - test('component renders error state correctly', async () => { - setUp(); - server.use( - rest.get(`${PROVISIONING_API}/sources`, (req, res, ctx) => - res(ctx.status(500)) - ) - ); - - await screen.findByText( - /Sources cannot be reached, try again later or enter an account info for upload manually\./i - ); - // - }); - // set test timeout on 10 seconds -}, 15000); diff --git a/src/test/Components/CreateImageWizard/CreateImageWizard.azure.test.js b/src/test/Components/CreateImageWizard/CreateImageWizard.azure.test.js index cb3bcbdf..9b1a43a4 100644 --- a/src/test/Components/CreateImageWizard/CreateImageWizard.azure.test.js +++ b/src/test/Components/CreateImageWizard/CreateImageWizard.azure.test.js @@ -3,9 +3,12 @@ import '@testing-library/jest-dom'; import { screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; +import { rest } from 'msw'; import CreateImageWizard from '../../../Components/CreateImageWizard/CreateImageWizard'; import ShareImageModal from '../../../Components/ShareImageModal/ShareImageModal'; +import { PROVISIONING_API } from '../../../constants'; +import { server } from '../../mocks/server'; import { clickBack, clickNext, @@ -49,6 +52,17 @@ jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({ let router = undefined; +beforeAll(() => { + // scrollTo is not defined in jsdom + window.HTMLElement.prototype.scrollTo = function () {}; +}); + +afterEach(() => { + jest.clearAllMocks(); + router = undefined; + server.resetHandlers(); +}); + describe('Step Upload to Azure', () => { const getSourceDropdown = async () => { const sourceDropdown = await screen.findByRole('textbox', { @@ -60,16 +74,6 @@ describe('Step Upload to Azure', () => { return sourceDropdown; }; - beforeAll(() => { - // scrollTo is not defined in jsdom - window.HTMLElement.prototype.scrollTo = function () {}; - }); - - afterEach(() => { - jest.clearAllMocks(); - router = undefined; - }); - const user = userEvent.setup(); const setUp = async () => { ({ router } = renderCustomRoutesWithReduxRouter('imagewizard', {}, routes)); @@ -222,5 +226,21 @@ describe('Step Upload to Azure', () => { expect(groups).toBeInTheDocument(); expect(screen.getByLabelText('Resource group theirGroup2')).toBeVisible(); }); - // set test timeout on 10 seconds + + test('component renders error state correctly', async () => { + server.use( + rest.get(`${PROVISIONING_API}/sources`, (req, res, ctx) => + res(ctx.status(500)) + ) + ); + + setUp(); + + await screen.findByText( + /Sources cannot be reached, try again later or enter an account info for upload manually\./i + ); + // + }); + + // set test timeout to 15 seconds }, 15000); diff --git a/src/test/Components/CreateImageWizard/CreateImageWizard.test.js b/src/test/Components/CreateImageWizard/CreateImageWizard.test.js index 71cbbca9..8e09fbbf 100644 --- a/src/test/Components/CreateImageWizard/CreateImageWizard.test.js +++ b/src/test/Components/CreateImageWizard/CreateImageWizard.test.js @@ -114,6 +114,7 @@ beforeAll(() => { afterEach(() => { jest.clearAllMocks(); router = undefined; + server.resetHandlers(); }); describe('Create Image Wizard', () => { @@ -319,13 +320,12 @@ describe('Step Upload to AWS', () => { }); test('component renders error state correctly', async () => { - await setUp(); server.use( rest.get(`${PROVISIONING_API}/sources`, (req, res, ctx) => res(ctx.status(500)) ) ); - + await setUp(); await screen.findByText( /sources cannot be reached, try again later or enter an aws account id manually\./i );