Skip to content

Commit

Permalink
test: flaky snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
acid-chicken committed Apr 10, 2023
1 parent 47f9219 commit a6bdb24
Showing 1 changed file with 53 additions and 3 deletions.
56 changes: 53 additions & 3 deletions packages/frontend/src/components/MkAutocomplete.stories.impl.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
/* eslint-disable @typescript-eslint/explicit-function-return-type */
import { action } from '@storybook/addon-actions';
import { expect } from '@storybook/jest';
import { userEvent, waitFor, within } from '@storybook/testing-library';
import { StoryObj } from '@storybook/vue3';
import { rest } from 'msw';
import { tick } from '@/scripts/test-utils';
import { userDetailed } from '../../.storybook/fakes';
import { commonHandlers } from '../../.storybook/mocks';
import MkAutocomplete from './MkAutocomplete.vue';
Expand Down Expand Up @@ -62,14 +65,29 @@ const common = {
exclude: ['textarea'],
},
layout: 'centered',
chromatic: {
// FIXME: flaky
disableSnapshot: true,
},
},
} satisfies StoryObj<typeof MkAutocomplete>;
export const User = {
...common,
args: {
...common.args,
type: 'user',
q: 'm',
},
async play({ canvasElement }) {
const canvas = within(canvasElement);
const input = canvas.getByRole('combobox');
await waitFor(() => userEvent.hover(input));
await waitFor(() => userEvent.click(input));
await waitFor(() => userEvent.type(input, 'm'));
await waitFor(async () => {
await userEvent.type(input, ' ', { delay: 256 });
await tick();
return await expect(canvas.getByRole('list')).toBeInTheDocument();
}, { timeout: 16384 });
},
parameters: {
...common.parameters,
Expand All @@ -91,7 +109,18 @@ export const Hashtag = {
args: {
...common.args,
type: 'hashtag',
q: '気象',
},
async play({ canvasElement }) {
const canvas = within(canvasElement);
const input = canvas.getByRole('combobox');
await waitFor(() => userEvent.hover(input));
await waitFor(() => userEvent.click(input));
await waitFor(() => userEvent.type(input, '気象'));
await waitFor(async () => {
await userEvent.type(input, ' ', { delay: 256 });
await tick();
return await expect(canvas.getByRole('list')).toBeInTheDocument();
}, { interval: 256, timeout: 16384 });
},
parameters: {
...common.parameters,
Expand All @@ -114,7 +143,18 @@ export const Emoji = {
args: {
...common.args,
type: 'emoji',
q: 'smile',
},
async play({ canvasElement }) {
const canvas = within(canvasElement);
const input = canvas.getByRole('combobox');
await waitFor(() => userEvent.hover(input));
await waitFor(() => userEvent.click(input));
await waitFor(() => userEvent.type(input, 'smile'));
await waitFor(async () => {
await userEvent.type(input, ' ', { delay: 256 });
await tick();
return await expect(canvas.getByRole('list')).toBeInTheDocument();
}, { interval: 256, timeout: 16384 });
},
} satisfies StoryObj<typeof MkAutocomplete>;
export const MfmTag = {
Expand All @@ -123,4 +163,14 @@ export const MfmTag = {
...common.args,
type: 'mfmTag',
},
async play({ canvasElement }) {
const canvas = within(canvasElement);
const input = canvas.getByRole('combobox');
await waitFor(() => userEvent.hover(input));
await waitFor(() => userEvent.click(input));
await waitFor(async () => {
await tick();
return await expect(canvas.getByRole('list')).toBeInTheDocument();
}, { interval: 256, timeout: 16384 });
},
} satisfies StoryObj<typeof MkAutocomplete>;

1 comment on commit a6bdb24

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chromatic will skip testing but you may still have to review the changes on Chromatic.

Please sign in to comment.