diff options
| author | Acid Chicken (硫酸鶏) <root@acid-chicken.com> | 2023-03-25 23:32:47 +0900 |
|---|---|---|
| committer | Acid Chicken (硫酸鶏) <root@acid-chicken.com> | 2023-03-25 23:32:47 +0900 |
| commit | 356fd72603ad09737d82c65aea90baef70bcda7c (patch) | |
| tree | 75cf5aa9f50297fa61a6742b99b0ada2b506ce5a /packages/frontend/src/components/global | |
| parent | docs: fix (diff) | |
| download | misskey-356fd72603ad09737d82c65aea90baef70bcda7c.tar.gz misskey-356fd72603ad09737d82c65aea90baef70bcda7c.tar.bz2 misskey-356fd72603ad09737d82c65aea90baef70bcda7c.zip | |
build(#10336): interactions
Diffstat (limited to 'packages/frontend/src/components/global')
| -rw-r--r-- | packages/frontend/src/components/global/MkA.stories.impl.ts | 46 | ||||
| -rw-r--r-- | packages/frontend/src/components/global/MkA.stories.ts | 25 |
2 files changed, 67 insertions, 4 deletions
diff --git a/packages/frontend/src/components/global/MkA.stories.impl.ts b/packages/frontend/src/components/global/MkA.stories.impl.ts new file mode 100644 index 0000000000..b1a88be5a3 --- /dev/null +++ b/packages/frontend/src/components/global/MkA.stories.impl.ts @@ -0,0 +1,46 @@ +/* eslint-disable @typescript-eslint/explicit-function-return-type */ +import { expect } from '@storybook/jest'; +import { userEvent, within } from '@storybook/testing-library'; +import { StoryObj } from '@storybook/vue3'; +import MkA from './MkA.vue'; +import { tick } from '@/scripts/test-utils'; +export const Default = { + render(args) { + return { + components: { + MkA, + }, + setup() { + return { + args, + }; + }, + computed: { + props() { + return { + ...args, + }; + }, + }, + template: '<MkA v-bind="props">Text</MkA>', + }; + }, + args: { + to: '#test', + }, + parameters: { + layout: 'centered', + }, +} satisfies StoryObj<typeof MkA>; +export const ContextMenu = { + ...Default, + async play({ canvasElement }) { + const canvas = within(canvasElement); + const a = canvas.getByRole<HTMLAnchorElement>('link'); + await expect(a.href).toMatch(/^https?:\/\/.*#test$/); + await userEvent.click(a, { button: 2 }); + await tick(); + const menu = canvas.getByRole('menu'); + await expect(menu).toBeInTheDocument(); + }, +} satisfies StoryObj<typeof MkA>; diff --git a/packages/frontend/src/components/global/MkA.stories.ts b/packages/frontend/src/components/global/MkA.stories.ts index 91ea368263..ce648f2d57 100644 --- a/packages/frontend/src/components/global/MkA.stories.ts +++ b/packages/frontend/src/components/global/MkA.stories.ts @@ -1,11 +1,17 @@ /* eslint-disable @typescript-eslint/explicit-function-return-type */ /* eslint-disable import/no-default-export */ -import { Meta, StoryObj } from '@storybook/vue3'; -import MkA from './MkA.vue'; +import { Meta } from '@storybook/vue3'; const meta = { title: 'components/global/MkA', component: MkA, } satisfies Meta<typeof MkA>; +export default meta; +/* eslint-disable @typescript-eslint/explicit-function-return-type */ +import { expect } from '@storybook/jest'; +import { userEvent, within } from '@storybook/testing-library'; +import { StoryObj } from '@storybook/vue3'; +import MkA from './MkA.vue'; +import { tick } from '@/scripts/test-utils'; export const Default = { render(args) { return { @@ -24,11 +30,22 @@ export const Default = { }; }, }, - template: '<MkA v-bind="props" />', + template: '<MkA v-bind="props">Text</MkA>', }; }, + async play({ canvasElement }) { + const canvas = within(canvasElement); + const a = canvas.getByRole<HTMLAnchorElement>('link'); + await expect(a.href).toMatch(/^https?:\/\/.*#test$/); + await userEvent.click(a, { button: 2 }); + await tick(); + const menu = canvas.getByRole('menu'); + await expect(menu).toBeInTheDocument(); + }, + args: { + to: '#test', + }, parameters: { layout: 'centered', }, } satisfies StoryObj<typeof MkA>; -export default meta; |