summaryrefslogtreecommitdiff
path: root/packages/frontend/src/pages/user/home.stories.impl.ts
blob: c623ef9ee48f5e39e40f9e6ba7c6d88e0b94f58f (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
 * SPDX-FileCopyrightText: syuilo and misskey-project
 * SPDX-License-Identifier: AGPL-3.0-only
 */

/* eslint-disable @typescript-eslint/explicit-function-return-type */
import { StoryObj } from '@storybook/vue3';
import { HttpResponse, http } from 'msw';
import { userDetailed } from '../../../.storybook/fakes.js';
import { commonHandlers } from '../../../.storybook/mocks.js';
import home_ from './home.vue';
export const Default = {
	render(args) {
		return {
			components: {
				home_,
			},
			setup() {
				return {
					args,
				};
			},
			computed: {
				props() {
					return {
						...this.args,
					};
				},
			},
			template: '<home_ v-bind="props" />',
		};
	},
	args: {
		user: userDetailed(),
		disableNotes: false,
	},
	parameters: {
		layout: 'fullscreen',
		msw: {
			handlers: [
				...commonHandlers,
				http.post('/api/users/notes', () => {
					return HttpResponse.json([]);
				}),
				http.get('/api/charts/user/notes', ({ request }) => {
					const url = new URL(request.url);
					const length = Math.max(Math.min(parseInt(url.searchParams.get('limit') ?? '30', 10), 1), 300);
					return HttpResponse.json({
						total: Array.from({ length }, () => 0),
						inc: Array.from({ length }, () => 0),
						dec: Array.from({ length }, () => 0),
						diffs: {
							normal: Array.from({ length }, () => 0),
							reply: Array.from({ length }, () => 0),
							renote: Array.from({ length }, () => 0),
							withFile: Array.from({ length }, () => 0),
						},
					});
				}),
				http.get('/api/charts/user/pv', ({ request }) => {
					const url = new URL(request.url);
					const length = Math.max(Math.min(parseInt(url.searchParams.get('limit') ?? '30', 10), 1), 300);
					return HttpResponse.json({
						upv: {
							user: Array.from({ length }, () => 0),
							visitor: Array.from({ length }, () => 0),
						},
						pv: {
							user: Array.from({ length }, () => 0),
							visitor: Array.from({ length }, () => 0),
						},
					});
				}),
			],
		},
		chromatic: {
			// `XActivity` is not compatible with Chromatic for now
			disableSnapshot: true,
		},
	},
} satisfies StoryObj<typeof home_>;