Skip to content

Commit

Permalink
Trying to fix flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
pkirilin committed Jul 16, 2024
1 parent e07991f commit dcb8332
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ export const whenProductSaved = async (user: UserEvent): Promise<void> => {
export const expectCategory = (name: string): SelectOption =>
expect.objectContaining<Partial<SelectOption>>({ name });

export const thenProductFormIsVisible = async (): Promise<void> => {
expect(await screen.findByRole('dialog', { name: /product/i })).toBeVisible();
};

export const thenFormValueContains = async (
onSubmitMock: Mock,
product: productModel.FormValues,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
thenDefaultQuantityIsInvalid,
thenDialogShouldBeHidden,
thenFormValueContains,
thenProductFormIsVisible,
thenProductNameHasValue,
thenProductNameIsInvalid,
thenProductNameIsValid,
Expand Down Expand Up @@ -39,6 +40,8 @@ test('I can add new product', async () => {
);

await whenDialogOpened(user);
await thenProductFormIsVisible();

await whenProductNameChanged(user, 'Potato');
await whenCaloriesCostChanged(user, '150');
await whenDefaultQuantityChanged(user, '120');
Expand Down Expand Up @@ -71,6 +74,8 @@ test('I can edit product', async () => {
);

await whenDialogOpened(user);
await thenProductFormIsVisible();

await whenProductNameChanged(user, 'Potato edited');
await whenCaloriesCostChanged(user, '140');
await whenDefaultQuantityChanged(user, '110');
Expand Down

0 comments on commit dcb8332

Please sign in to comment.