test: Add revisit step button checks

This adds tests to check that the revisit buttons on the Review step are working correctly.

Also some minor cleanup, namely making case used in the names of describe and test more consistent and moving render functions outside of functions selecting targets to make the structure easier to go through.
This commit is contained in:
regexowl 2024-08-28 09:55:40 +02:00 committed by Lucas Garfield
parent 4a15b25ceb
commit 558bb50c34
14 changed files with 324 additions and 36 deletions

View file

@ -151,6 +151,20 @@ const deselectRecommendation = async () => {
await waitFor(async () => user.click(row1Checkbox));
};
const clickRevisitButton = async () => {
const user = userEvent.setup();
const expandable = await screen.findByTestId('content-expandable');
const revisitButton = await within(expandable).findByTestId(
'revisit-custom-repositories'
);
await waitFor(() => user.click(revisitButton));
await waitFor(() =>
expect(
screen.queryByRole('button', { name: /Create blueprint/ })
).not.toBeInTheDocument()
);
};
describe('Step Packages', () => {
beforeEach(() => {
vi.clearAllMocks();
@ -326,6 +340,16 @@ describe('Step Packages', () => {
await within(pkgTable).findByText('recommendedPackage1');
});
test('revisit step button on Review works', async () => {
await renderCreateMode();
await goToPackagesStep();
await typeIntoSearchBox('test');
await clickFirstPackageCheckbox();
await goToReviewStep();
await clickRevisitButton();
await screen.findByRole('heading', { name: /Custom repositories/ });
});
describe('Pagination', () => {
beforeEach(() => {
vi.clearAllMocks();