From 2184323ae782108180cf165d6bc31d8d98a0cd3b Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Wed, 12 Jul 2023 23:57:26 +0200 Subject: [PATCH] use waitFor --- .../frontend/src/components/global/MkAd.stories.impl.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/frontend/src/components/global/MkAd.stories.impl.ts b/packages/frontend/src/components/global/MkAd.stories.impl.ts index 3a88051374..3e4420fad8 100644 --- a/packages/frontend/src/components/global/MkAd.stories.impl.ts +++ b/packages/frontend/src/components/global/MkAd.stories.impl.ts @@ -1,10 +1,9 @@ /* eslint-disable @typescript-eslint/explicit-function-return-type */ import { expect } from '@storybook/jest'; -import { userEvent, within } from '@storybook/testing-library'; +import { userEvent, waitFor, within } from '@storybook/testing-library'; import { StoryObj } from '@storybook/vue3'; import MkAd from './MkAd.vue'; import { i18n } from '@/i18n'; -import { tick } from '@/scripts/test-utils.js'; const common = { render(args) { return { @@ -37,8 +36,7 @@ const common = { const i = buttons[0]; await expect(i).toBeInTheDocument(); await userEvent.click(i); - await tick(); - await expect(a).not.toBeInTheDocument(); + await waitFor(() => expect(a).not.toBeInTheDocument()); await expect(i).not.toBeInTheDocument(); buttons = canvas.getAllByRole('button'); await expect(buttons).toHaveLength(args.__hasReduce ? 2 : 1); @@ -51,11 +49,10 @@ const common = { await expect(back).toBeInTheDocument(); await expect(back).toHaveTextContent(i18n.ts._ad.back); await userEvent.click(back); - await tick(); + await waitFor(() => expect(back).not.toBeInTheDocument()); if (reduce) { await expect(reduce).not.toBeInTheDocument(); } - await expect(back).not.toBeInTheDocument(); const aAgain = canvas.getByRole('link'); await expect(aAgain).toBeInTheDocument(); const imgAgain = within(aAgain).getByRole('img');