From 3b3f683f8cdff33c8c745e1da99596e7499ca2d6 Mon Sep 17 00:00:00 2001 From: "Acid Chicken (硫酸鶏)" Date: Thu, 6 Apr 2023 08:19:49 +0900 Subject: feat(#8149): respect nsfw settings on gallery list (#10481) * feat(#8149): respect nsfw settings on gallery list * ci(#10336): use pull_request * test(#8149): add interaction tests * test(#10336): use `waitFor` * chore: transition --- .../MkGalleryPostPreview.stories.impl.ts | 85 ++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 packages/frontend/src/components/MkGalleryPostPreview.stories.impl.ts (limited to 'packages/frontend/src/components/MkGalleryPostPreview.stories.impl.ts') diff --git a/packages/frontend/src/components/MkGalleryPostPreview.stories.impl.ts b/packages/frontend/src/components/MkGalleryPostPreview.stories.impl.ts new file mode 100644 index 0000000000..e46a708192 --- /dev/null +++ b/packages/frontend/src/components/MkGalleryPostPreview.stories.impl.ts @@ -0,0 +1,85 @@ +/* eslint-disable @typescript-eslint/explicit-function-return-type */ +import { expect } from '@storybook/jest'; +import { userEvent, waitFor, within } from '@storybook/testing-library'; +import { StoryObj } from '@storybook/vue3'; +import { galleryPost } from '../../.storybook/fakes'; +import MkGalleryPostPreview from './MkGalleryPostPreview.vue'; +export const Default = { + render(args) { + return { + components: { + MkGalleryPostPreview, + }, + setup() { + return { + args, + }; + }, + computed: { + props() { + return { + ...this.args, + }; + }, + }, + template: '', + }; + }, + async play({ canvasElement }) { + const canvas = within(canvasElement); + const links = canvas.getAllByRole('link'); + await expect(links).toHaveLength(2); + await expect(links[0]).toHaveAttribute('href', `/gallery/${galleryPost().id}`); + await expect(links[1]).toHaveAttribute('href', `/@${galleryPost().user.username}@${galleryPost().user.host}`); + }, + args: { + post: galleryPost(), + }, + decorators: [ + () => ({ + template: '
', + }), + ], + parameters: { + layout: 'centered', + }, +} satisfies StoryObj; +export const Hover = { + ...Default, + async play(context) { + await Default.play(context); + const canvas = within(context.canvasElement); + const links = canvas.getAllByRole('link'); + await waitFor(() => userEvent.hover(links[0])); + }, +} satisfies StoryObj; +export const HoverThenUnhover = { + ...Default, + async play(context) { + await Hover.play(context); + const canvas = within(context.canvasElement); + const links = canvas.getAllByRole('link'); + await waitFor(() => userEvent.unhover(links[0])); + }, +} satisfies StoryObj; +export const Sensitive = { + ...Default, + args: { + ...Default.args, + post: galleryPost(true), + }, +} satisfies StoryObj; +export const SensitiveHover = { + ...Hover, + args: { + ...Hover.args, + post: galleryPost(true), + }, +} satisfies StoryObj; +export const SensitiveHoverThenUnhover = { + ...HoverThenUnhover, + args: { + ...HoverThenUnhover.args, + post: galleryPost(true), + }, +} satisfies StoryObj; -- cgit v1.2.3-freya