test: Move util function to wizardTestUtils

This moves `selectCustomRepo` to `wizardTestUtils.tsx`

Since the function was originally imported into `Packages.test.tsx` from `CreateImageWizard.content.test.tsx` the entire content suite was re-run under Packages suite each time. This solves the issue.
This commit is contained in:
regexowl 2024-08-06 13:48:53 +02:00 committed by Michal Gold
parent e0b33fd6f5
commit 912b56f735
3 changed files with 19 additions and 13 deletions

View file

@ -4,6 +4,8 @@ import type { Router as RemixRouter } from '@remix-run/router';
import { screen, waitFor, within } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { selectCustomRepo } from './wizardTestUtils';
import CreateImageWizard from '../../../Components/CreateImageWizard/CreateImageWizard';
import {
clickBack,
@ -104,17 +106,6 @@ const checkRecommendationsEmptyState = async () => {
await screen.findByText('Select packages to generate recommendations.');
};
export const selectCustomRepo = async () => {
const user = userEvent.setup();
await clickBack();
const customRepoCheckbox = await screen.findByRole('checkbox', {
name: /select row 0/i,
});
user.click(customRepoCheckbox);
await clickNext();
};
describe('Step Packages', () => {
beforeEach(() => {
vi.clearAllMocks();

View file

@ -12,7 +12,7 @@ import {
packagesCreateBlueprintRequest,
} from '../../../../fixtures/editMode';
import { clickNext } from '../../../../testUtils';
import { selectCustomRepo } from '../../CreateImageWizard.content.test';
import { selectCustomRepo } from '../../wizardTestUtils';
import {
blueprintRequest,
clickRegisterLater,

View file

@ -10,7 +10,11 @@ import {
ImageRequest,
} from '../../../store/imageBuilderApi';
import { server } from '../../mocks/server';
import { clickNext, renderCustomRoutesWithReduxRouter } from '../../testUtils';
import {
clickBack,
clickNext,
renderCustomRoutesWithReduxRouter,
} from '../../testUtils';
type RequestTypes = 'GET' | 'PUT' | 'POST' | 'DELETE';
@ -106,6 +110,17 @@ export const clickRegisterLater = async () => {
await waitFor(() => user.click(radioButton));
};
export const selectCustomRepo = async () => {
const user = userEvent.setup();
await clickBack();
const customRepoCheckbox = await screen.findByRole('checkbox', {
name: /select row 0/i,
});
user.click(customRepoCheckbox);
await clickNext();
};
export const enterBlueprintName = async (name: string = 'Red Velvet') => {
const user = userEvent.setup();
const blueprintName = await screen.findByRole('textbox', {