From 28468c7af6838ee6ddce1e763592bb033cbe4469 Mon Sep 17 00:00:00 2001 From: regexowl Date: Thu, 25 Jan 2024 10:35:54 +0100 Subject: [PATCH] test: Disable repositories tests This disables all tests testing behaviour of the Repositories step. All instances were marked with the "Temporarily disable" comment to make the complete revert easier in the future. --- .../CreateImageWizard.content.test.js | 526 +++++++++--------- .../CreateImageWizard.test.js | 16 +- 2 files changed, 274 insertions(+), 268 deletions(-) diff --git a/src/test/Components/CreateImageWizard/CreateImageWizard.content.test.js b/src/test/Components/CreateImageWizard/CreateImageWizard.content.test.js index 3039e2e9..08e48e01 100644 --- a/src/test/Components/CreateImageWizard/CreateImageWizard.content.test.js +++ b/src/test/Components/CreateImageWizard/CreateImageWizard.content.test.js @@ -18,7 +18,8 @@ import { clickBack, clickNext, renderCustomRoutesWithReduxRouter, - renderWithReduxRouter, + // Temporarily disable + // renderWithReduxRouter, verifyCancelButton, } from '../../testUtils'; @@ -823,6 +824,8 @@ describe('Step Packages', () => { describe('Step Custom repositories', () => { const user = userEvent.setup(); + // Temporarily disable + // eslint-disable-next-line no-unused-vars const setUp = async () => { ({ router } = renderCustomRoutesWithReduxRouter('imagewizard', {}, routes)); @@ -854,265 +857,266 @@ describe('Step Custom repositories', () => { // skip packages await clickNext(); }; - - test('selected repositories stored in and retrieved from form state', async () => { - await setUp(); - - const getFirstRepoCheckbox = async () => - await screen.findByRole('checkbox', { - name: /select row 0/i, - }); - let firstRepoCheckbox = await getFirstRepoCheckbox(); - - expect(firstRepoCheckbox.checked).toEqual(false); - await user.click(firstRepoCheckbox); - await waitFor(() => expect(firstRepoCheckbox.checked).toEqual(true)); - - await clickNext(); - await clickBack(); - - firstRepoCheckbox = await getFirstRepoCheckbox(); - await waitFor(() => expect(firstRepoCheckbox.checked).toEqual(true)); - }); - - test('correct number of repositories is fetched', async () => { - await setUp(); - - await user.click( - await screen.findByRole('button', { - name: /^select$/i, - }) - ); - - await screen.findByText(/select all \(1015 items\)/i); - }); - - test('filter works', async () => { - await setUp(); - - await user.type( - await screen.findByRole('textbox', { name: /search repositories/i }), - '2zmya' - ); - - const table = await screen.findByTestId('repositories-table'); - const { getAllByRole } = within(table); - const getRows = () => getAllByRole('row'); - - let rows = getRows(); - // remove first row from list since it is just header labels - rows.shift(); - - expect(rows).toHaveLength(1); - - // clear filter - await user.click(await screen.findByRole('button', { name: /reset/i })); - - rows = getRows(); - // remove first row from list since it is just header labels - rows.shift(); - - await waitFor(() => expect(rows).toHaveLength(10)); - }); - - test('press on Selected button to see selected repositories list', async () => { - await setUp(); - - const getFirstRepoCheckbox = async () => - await screen.findByRole('checkbox', { - name: /select row 0/i, - }); - const firstRepoCheckbox = await getFirstRepoCheckbox(); - - expect(firstRepoCheckbox.checked).toEqual(false); - await user.click(firstRepoCheckbox); - expect(firstRepoCheckbox.checked).toEqual(true); - - const getSelectedButton = async () => - await screen.findByRole('button', { - name: /selected repositories/i, - }); - - const selectedButton = await getSelectedButton(); - await user.click(selectedButton); - - expect(firstRepoCheckbox.checked).toEqual(true); - - await clickNext(); - clickBack(); - expect(firstRepoCheckbox.checked).toEqual(true); - }); - - test('press on All button to see all repositories list', async () => { - await setUp(); - - const getFirstRepoCheckbox = async () => - await screen.findByRole('checkbox', { - name: /select row 0/i, - }); - const firstRepoCheckbox = await getFirstRepoCheckbox(); - - const getSecondRepoCheckbox = async () => - await screen.findByRole('checkbox', { - name: /select row 1/i, - }); - const secondRepoCheckbox = await getSecondRepoCheckbox(); - - expect(firstRepoCheckbox.checked).toEqual(false); - expect(secondRepoCheckbox.checked).toEqual(false); - await user.click(firstRepoCheckbox); - expect(firstRepoCheckbox.checked).toEqual(true); - expect(secondRepoCheckbox.checked).toEqual(false); - - const getAllButton = async () => - await screen.findByRole('button', { - name: /all repositories/i, - }); - - const allButton = await getAllButton(); - await user.click(allButton); - - expect(firstRepoCheckbox.checked).toEqual(true); - expect(secondRepoCheckbox.checked).toEqual(false); - - await clickNext(); - clickBack(); - - expect(firstRepoCheckbox.checked).toEqual(true); - expect(secondRepoCheckbox.checked).toEqual(false); - }); - - test('press on Selected button to see selected repositories list at the second page and filter checked repo', async () => { - await setUp(); - - const getFirstRepoCheckbox = async () => - await screen.findByRole('checkbox', { - name: /select row 0/i, - }); - - const firstRepoCheckbox = await getFirstRepoCheckbox(); - - const getNextPageButton = async () => - await screen.findByRole('button', { - name: /go to next page/i, - }); - - const nextPageButton = await getNextPageButton(); - - expect(firstRepoCheckbox.checked).toEqual(false); - await user.click(firstRepoCheckbox); - expect(firstRepoCheckbox.checked).toEqual(true); - - await user.click(nextPageButton); - - const getSelectedButton = async () => - await screen.findByRole('button', { - name: /selected repositories/i, - }); - - const selectedButton = await getSelectedButton(); - await user.click(selectedButton); - - expect(firstRepoCheckbox.checked).toEqual(true); - - await user.type( - await screen.findByRole('textbox', { name: /search repositories/i }), - '13lk3' - ); - - expect(firstRepoCheckbox.checked).toEqual(true); - - await clickNext(); - clickBack(); - expect(firstRepoCheckbox.checked).toEqual(true); - await user.click(firstRepoCheckbox); - expect(firstRepoCheckbox.checked).toEqual(false); - }); + // Temporarily disable + // test('selected repositories stored in and retrieved from form state', async () => { + // await setUp(); + // + // const getFirstRepoCheckbox = async () => + // await screen.findByRole('checkbox', { + // name: /select row 0/i, + // }); + // let firstRepoCheckbox = await getFirstRepoCheckbox(); + // + // expect(firstRepoCheckbox.checked).toEqual(false); + // await user.click(firstRepoCheckbox); + // await waitFor(() => expect(firstRepoCheckbox.checked).toEqual(true)); + // + // await clickNext(); + // await clickBack(); + // + // firstRepoCheckbox = await getFirstRepoCheckbox(); + // await waitFor(() => expect(firstRepoCheckbox.checked).toEqual(true)); + // }); + // + // test('correct number of repositories is fetched', async () => { + // await setUp(); + // + // await user.click( + // await screen.findByRole('button', { + // name: /^select$/i, + // }) + // ); + // + // await screen.findByText(/select all \(1015 items\)/i); + // }); + // + // test('filter works', async () => { + // await setUp(); + // + // await user.type( + // await screen.findByRole('textbox', { name: /search repositories/i }), + // '2zmya' + // ); + // + // const table = await screen.findByTestId('repositories-table'); + // const { getAllByRole } = within(table); + // const getRows = () => getAllByRole('row'); + // + // let rows = getRows(); + // // remove first row from list since it is just header labels + // rows.shift(); + // + // expect(rows).toHaveLength(1); + // + // // clear filter + // await user.click(await screen.findByRole('button', { name: /reset/i })); + // + // rows = getRows(); + // // remove first row from list since it is just header labels + // rows.shift(); + // + // await waitFor(() => expect(rows).toHaveLength(10)); + // }); + // + // test('press on Selected button to see selected repositories list', async () => { + // await setUp(); + // + // const getFirstRepoCheckbox = async () => + // await screen.findByRole('checkbox', { + // name: /select row 0/i, + // }); + // const firstRepoCheckbox = await getFirstRepoCheckbox(); + // + // expect(firstRepoCheckbox.checked).toEqual(false); + // await user.click(firstRepoCheckbox); + // expect(firstRepoCheckbox.checked).toEqual(true); + // + // const getSelectedButton = async () => + // await screen.findByRole('button', { + // name: /selected repositories/i, + // }); + // + // const selectedButton = await getSelectedButton(); + // await user.click(selectedButton); + // + // expect(firstRepoCheckbox.checked).toEqual(true); + // + // await clickNext(); + // clickBack(); + // expect(firstRepoCheckbox.checked).toEqual(true); + // }); + // + // test('press on All button to see all repositories list', async () => { + // await setUp(); + // + // const getFirstRepoCheckbox = async () => + // await screen.findByRole('checkbox', { + // name: /select row 0/i, + // }); + // const firstRepoCheckbox = await getFirstRepoCheckbox(); + // + // const getSecondRepoCheckbox = async () => + // await screen.findByRole('checkbox', { + // name: /select row 1/i, + // }); + // const secondRepoCheckbox = await getSecondRepoCheckbox(); + // + // expect(firstRepoCheckbox.checked).toEqual(false); + // expect(secondRepoCheckbox.checked).toEqual(false); + // await user.click(firstRepoCheckbox); + // expect(firstRepoCheckbox.checked).toEqual(true); + // expect(secondRepoCheckbox.checked).toEqual(false); + // + // const getAllButton = async () => + // await screen.findByRole('button', { + // name: /all repositories/i, + // }); + // + // const allButton = await getAllButton(); + // await user.click(allButton); + // + // expect(firstRepoCheckbox.checked).toEqual(true); + // expect(secondRepoCheckbox.checked).toEqual(false); + // + // await clickNext(); + // clickBack(); + // + // expect(firstRepoCheckbox.checked).toEqual(true); + // expect(secondRepoCheckbox.checked).toEqual(false); + // }); + // + // test('press on Selected button to see selected repositories list at the second page and filter checked repo', async () => { + // await setUp(); + // + // const getFirstRepoCheckbox = async () => + // await screen.findByRole('checkbox', { + // name: /select row 0/i, + // }); + // + // const firstRepoCheckbox = await getFirstRepoCheckbox(); + // + // const getNextPageButton = async () => + // await screen.findByRole('button', { + // name: /go to next page/i, + // }); + // + // const nextPageButton = await getNextPageButton(); + // + // expect(firstRepoCheckbox.checked).toEqual(false); + // await user.click(firstRepoCheckbox); + // expect(firstRepoCheckbox.checked).toEqual(true); + // + // await user.click(nextPageButton); + // + // const getSelectedButton = async () => + // await screen.findByRole('button', { + // name: /selected repositories/i, + // }); + // + // const selectedButton = await getSelectedButton(); + // await user.click(selectedButton); + // + // expect(firstRepoCheckbox.checked).toEqual(true); + // + // await user.type( + // await screen.findByRole('textbox', { name: /search repositories/i }), + // '13lk3' + // ); + // + // expect(firstRepoCheckbox.checked).toEqual(true); + // + // await clickNext(); + // clickBack(); + // expect(firstRepoCheckbox.checked).toEqual(true); + // await user.click(firstRepoCheckbox); + // expect(firstRepoCheckbox.checked).toEqual(false); + // }); }); -describe('On Recreate', () => { - const user = userEvent.setup(); - const setUp = async () => { - ({ router } = renderWithReduxRouter( - 'imagewizard/hyk93673-8dcc-4a61-ac30-e9f4940d8346' - )); - }; - - const setUpUnavailableRepo = async () => { - ({ router } = renderWithReduxRouter( - 'imagewizard/b7193673-8dcc-4a5f-ac30-e9f4940d8346' - )); - }; - - test('with valid repositories', async () => { - await setUp(); - - await screen.findByRole('heading', { name: /review/i }); - expect( - screen.queryByText('Previously added custom repository unavailable') - ).not.toBeInTheDocument(); - - const createImageButton = await screen.findByRole('button', { - name: /create image/i, - }); - await waitFor(() => expect(createImageButton).toBeEnabled()); - - await user.click( - await screen.findByRole('button', { name: /custom repositories/i }) - ); - - await screen.findByRole('heading', { name: /custom repositories/i }); - expect( - screen.queryByText('Previously added custom repository unavailable') - ).not.toBeInTheDocument(); - - const table = await screen.findByTestId('repositories-table'); - - const { getAllByRole } = within(table); - const rows = getAllByRole('row'); - - const availableRepo = rows[1].cells[1]; - expect(availableRepo).toHaveTextContent( - '13lk3http://yum.theforeman.org/releases/3.4/el8/x86_64/' - ); - - const availableRepoCheckbox = await screen.findByRole('checkbox', { - name: /select row 0/i, - }); - await waitFor(() => expect(availableRepoCheckbox).toBeEnabled()); - }); - - test('with repositories that are no longer available', async () => { - await setUpUnavailableRepo(); - - await screen.findByRole('heading', { name: /review/i }); - await screen.findByText('Previously added custom repository unavailable'); - - const createImageButton = await screen.findByRole('button', { - name: /create image/i, - }); - expect(createImageButton).toBeDisabled(); - - await user.click( - await screen.findByRole('button', { name: /custom repositories/i }) - ); - - await screen.findByRole('heading', { name: /custom repositories/i }); - await screen.findByText('Previously added custom repository unavailable'); - - const table = await screen.findByTestId('repositories-table'); - - const { getAllByRole } = within(table); - const rows = getAllByRole('row'); - - const unavailableRepo = rows[1].cells[1]; - expect(unavailableRepo).toHaveTextContent( - 'Repository with the following url is no longer available:http://unreachable.link.to.repo.org/x86_64/' - ); - - const unavailableRepoCheckbox = await screen.findByRole('checkbox', { - name: /select row 0/i, - }); - expect(unavailableRepoCheckbox).toBeDisabled(); - }); -}); +// Temporarily disable +// describe('On Recreate', () => { +// const user = userEvent.setup(); +// const setUp = async () => { +// ({ router } = renderWithReduxRouter( +// 'imagewizard/hyk93673-8dcc-4a61-ac30-e9f4940d8346' +// )); +// }; +// +// const setUpUnavailableRepo = async () => { +// ({ router } = renderWithReduxRouter( +// 'imagewizard/b7193673-8dcc-4a5f-ac30-e9f4940d8346' +// )); +// }; +// +// test('with valid repositories', async () => { +// await setUp(); +// +// await screen.findByRole('heading', { name: /review/i }); +// expect( +// screen.queryByText('Previously added custom repository unavailable') +// ).not.toBeInTheDocument(); +// +// const createImageButton = await screen.findByRole('button', { +// name: /create image/i, +// }); +// await waitFor(() => expect(createImageButton).toBeEnabled()); +// +// await user.click( +// await screen.findByRole('button', { name: /custom repositories/i }) +// ); +// +// await screen.findByRole('heading', { name: /custom repositories/i }); +// expect( +// screen.queryByText('Previously added custom repository unavailable') +// ).not.toBeInTheDocument(); +// +// const table = await screen.findByTestId('repositories-table'); +// +// const { getAllByRole } = within(table); +// const rows = getAllByRole('row'); +// +// const availableRepo = rows[1].cells[1]; +// expect(availableRepo).toHaveTextContent( +// '13lk3http://yum.theforeman.org/releases/3.4/el8/x86_64/' +// ); +// +// const availableRepoCheckbox = await screen.findByRole('checkbox', { +// name: /select row 0/i, +// }); +// await waitFor(() => expect(availableRepoCheckbox).toBeEnabled()); +// }); +// +// test('with repositories that are no longer available', async () => { +// await setUpUnavailableRepo(); +// +// await screen.findByRole('heading', { name: /review/i }); +// await screen.findByText('Previously added custom repository unavailable'); +// +// const createImageButton = await screen.findByRole('button', { +// name: /create image/i, +// }); +// expect(createImageButton).toBeDisabled(); +// +// await user.click( +// await screen.findByRole('button', { name: /custom repositories/i }) +// ); +// +// await screen.findByRole('heading', { name: /custom repositories/i }); +// await screen.findByText('Previously added custom repository unavailable'); +// +// const table = await screen.findByTestId('repositories-table'); +// +// const { getAllByRole } = within(table); +// const rows = getAllByRole('row'); +// +// const unavailableRepo = rows[1].cells[1]; +// expect(unavailableRepo).toHaveTextContent( +// 'Repository with the following url is no longer available:http://unreachable.link.to.repo.org/x86_64/' +// ); +// +// const unavailableRepoCheckbox = await screen.findByRole('checkbox', { +// name: /select row 0/i, +// }); +// expect(unavailableRepoCheckbox).toBeDisabled(); +// }); +// }); diff --git a/src/test/Components/CreateImageWizard/CreateImageWizard.test.js b/src/test/Components/CreateImageWizard/CreateImageWizard.test.js index 82711249..f02c731c 100644 --- a/src/test/Components/CreateImageWizard/CreateImageWizard.test.js +++ b/src/test/Components/CreateImageWizard/CreateImageWizard.test.js @@ -1221,6 +1221,7 @@ describe('Click through all steps', () => { ); await clickNext(); + // Temporarily disable // Custom repositories // await user.click( // await screen.findByRole('checkbox', { name: /select row 0/i }) @@ -1231,6 +1232,7 @@ describe('Click through all steps', () => { await clickNext(); + // Temporarily disable // Custom packages // await clickNext(); @@ -1297,6 +1299,8 @@ describe('Click through all steps', () => { expect(within(revtbody).getAllByRole('row')).toHaveLength(3); // mock the backend API + // Temporarily disable + // eslint-disable-next-line no-unused-vars const payload_repos = [ { baseurl: 'http://yum.theforeman.org/releases/3.4/el8/x86_64/', @@ -1314,6 +1318,7 @@ describe('Click through all steps', () => { }, ]; + // Temporarily disable // eslint-disable-next-line no-unused-vars const custom_repos = [ { @@ -1351,9 +1356,9 @@ describe('Click through all steps', () => { min_size: 104857600, }, ], + // Temporarily disable // custom_repositories: custom_repos, - custom_repositories: [], - payload_repositories: payload_repos, + // payload_repositories: payload_repos, packages: ['test'], subscription: { 'activation-key': 'name0', @@ -1365,7 +1370,6 @@ describe('Click through all steps', () => { }, }; - // eslint-disable-next-line const expectedComposeReqs = { aws: { distribution: RHEL_8, @@ -1479,7 +1483,6 @@ describe('Click through all steps', () => { }, }; - // eslint-disable-next-line let timesCalled = 0; const receivedComposeReqs = {}; @@ -1497,9 +1500,8 @@ describe('Click through all steps', () => { ); await user.click(await screen.findByRole('button', { name: /Create/ })); - // TODO re-enable asap - // expect(receivedComposeReqs).toEqual(expectedComposeReqs); - // expect(timesCalled).toEqual(6); + expect(receivedComposeReqs).toEqual(expectedComposeReqs); + expect(timesCalled).toEqual(6); // returns back to the landing page await waitFor(() =>