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

@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { screen, waitFor } from '@testing-library/react';
import { screen, waitFor, within } from '@testing-library/react';
import { userEvent } from '@testing-library/user-event';
import {
@ -67,6 +67,15 @@ const goToReviewStep = async (): Promise<void> => {
await clickNext(); // Review
};
const clickRevisitButton = async () => {
const user = userEvent.setup();
const expandable = await screen.findByTestId('firstboot-expandable');
const revisitButton = await within(expandable).findByTestId(
'revisit-first-boot'
);
await waitFor(() => user.click(revisitButton));
};
describe('First Boot step', () => {
beforeEach(() => {
vi.clearAllMocks();
@ -118,6 +127,14 @@ describe('First Boot step', () => {
// });
// });
// });
test('revisit step button on Review works', async () => {
await renderCreateMode();
await goToFirstBootStep();
await goToReviewStep();
await clickRevisitButton();
await screen.findByRole('heading', { name: /First boot/ });
});
});
describe('First Boot edit mode', () => {