fix(storybook): implement missing stories (#15862)
This commit is contained in:
parent
74d9cc4e38
commit
978ab2f848
|
@ -43,6 +43,41 @@ export function channel(id = 'somechannelid', name = 'Some Channel', bannerUrl:
|
|||
};
|
||||
}
|
||||
|
||||
export function chatMessage(room = false, id = 'somechatmessageid', text = 'Hello!'): entities.ChatMessage {
|
||||
const fromUser = userLite();
|
||||
const toRoom = chatRoom();
|
||||
const toUser = userLite('touserid');
|
||||
return {
|
||||
id,
|
||||
createdAt: '2016-12-28T22:49:51.000Z',
|
||||
fromUserId: fromUser.id,
|
||||
fromUser,
|
||||
text,
|
||||
isRead: false,
|
||||
reactions: [],
|
||||
...room ? {
|
||||
toRoomId: toRoom.id,
|
||||
toRoom,
|
||||
} : {
|
||||
toUserId: toUser.id,
|
||||
toUser,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function chatRoom(id = 'somechatroomid', name = 'Some Chat Room'): entities.ChatRoom {
|
||||
const owner = userLite('someownerid');
|
||||
return {
|
||||
id,
|
||||
createdAt: '2016-12-28T22:49:51.000Z',
|
||||
ownerId: owner.id,
|
||||
owner,
|
||||
name,
|
||||
description: 'A chat room for testing',
|
||||
isMuted: false,
|
||||
};
|
||||
}
|
||||
|
||||
export function clip(id = 'someclipid', name = 'Some Clip'): entities.Clip {
|
||||
return {
|
||||
id,
|
||||
|
|
|
@ -0,0 +1,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>;
|
|
@ -0,0 +1,7 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import MkDisableSection from './MkDisableSection.vue';
|
||||
void MkDisableSection;
|
Loading…
Reference in New Issue