summaryrefslogtreecommitdiff
path: root/packages/frontend/src/components/MkChatHistories.stories.impl.ts
blob: 8268adc36f26cef958b0b85c710d618ec0178050 (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
/*
 * SPDX-FileCopyrightText: syuilo and misskey-project
 * SPDX-License-Identifier: AGPL-3.0-only
 */

import { http, HttpResponse } from 'msw';
import { action } from '@storybook/addon-actions';
import { chatMessage } from '../../.storybook/fakes';
import MkChatHistories from './MkChatHistories.vue';
import type { StoryObj } from '@storybook/vue3';
import type * as Misskey from 'misskey-js';
export const Default = {
	render(args) {
		return {
			components: {
				MkChatHistories,
			},
			setup() {
				return {
					args,
				};
			},
			computed: {
				props() {
					return {
						...this.args,
					};
				},
			},
			template: '<MkChatHistories v-bind="props" />',
		};
	},
	parameters: {
		layout: 'centered',
		msw: {
			handlers: [
				http.post('/api/chat/history', async ({ request }) => {
					const body = await request.json() as Misskey.entities.ChatHistoryRequest;
					action('POST /api/chat/history')(body);
					return HttpResponse.json([chatMessage(body.room)]);
				}),
			],
		},
	},
} satisfies StoryObj<typeof MkChatHistories>;