summaryrefslogtreecommitdiff
path: root/packages/frontend/src/components/global/MkA.stories.impl.ts
blob: deb2b8a52b255bd5343a19d8ebc2ad0c5154482c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
 * SPDX-FileCopyrightText: syuilo and misskey-project
 * SPDX-License-Identifier: AGPL-3.0-only
 */

/* eslint-disable @typescript-eslint/explicit-function-return-type */
import { expect, userEvent, within } from '@storybook/test';
import type { StoryObj } from '@storybook/vue3';
import MkA from './MkA.vue';
import { tick } from '@/utility/test-utils.js';
export const Default = {
	render(args) {
		return {
			components: {
				MkA,
			},
			setup() {
				return {
					args,
				};
			},
			computed: {
				props() {
					return {
						...this.args,
					};
				},
			},
			template: '<MkA v-bind="props">Misskey</MkA>',
		};
	},
	async play({ canvasElement }) {
		const canvas = within(canvasElement);
		const a = canvas.getByRole<HTMLAnchorElement>('link');
		// FIXME: 通るけどその後落ちるのでコメントアウト
		// await expect(a.href).toMatch(/^https?:\/\/.*#test$/);
		await userEvent.pointer({ keys: '[MouseRight]', target: a });
		const menu = canvas.getByRole('menu');
		await expect(menu).toBeInTheDocument();
		await userEvent.click(a);
		a.blur();
		await expect(menu).not.toBeInTheDocument();
	},
	args: {
		to: '#test',
		behavior: 'browser',
	},
	parameters: {
		layout: 'centered',
	},
} satisfies StoryObj<typeof MkA>;