[wip] add custom-emojis-manager2.stories.impl.ts

This commit is contained in:
samunohito 2024-02-23 09:34:26 +09:00
parent 879596ca7d
commit c2c920c4a2
2 changed files with 51 additions and 0 deletions

View File

@ -4,6 +4,7 @@
*/
import type { entities } from 'misskey-js'
import { imageDataUrl, text } from "./fake-utils.js";
export function abuseUserReport() {
return {
@ -196,3 +197,42 @@ export function role(params: {
policies: {},
}
}
export function emoji(params?: {
id?: string,
name?: string,
host?: string,
uri?: string,
publicUrl?: string,
originalUrl?: string,
type?: string,
aliases?: string[],
category?: string,
license?: string,
isSensitive?: boolean,
localOnly?: boolean,
roleIdsThatCanBeUsedThisEmojiAsReaction?: {id:string, name:string}[],
updatedAt?: string,
}): entities.EmojiDetailedAdmin {
const id = params?.id ?? new Date().getTime().toString() + text(5);
const name = params?.name ?? text(8);
const image = imageDataUrl()
return {
id: id,
name: name,
host: params?.host ?? null,
uri: params?.uri ?? null,
publicUrl: params?.publicUrl ?? image,
originalUrl: params?.originalUrl ?? image,
type: params?.type ?? 'image/png',
aliases: params?.aliases ?? [`alias1-${name}`, `alias2-${name}`],
category: params?.category ?? null,
license: params?.license ?? null,
isSensitive: params?.isSensitive ?? false,
localOnly: params?.localOnly ?? false,
roleIdsThatCanBeUsedThisEmojiAsReaction: params?.roleIdsThatCanBeUsedThisEmojiAsReaction ?? [],
updatedAt: params?.updatedAt ?? new Date().toISOString(),
}
}

View File

@ -7,6 +7,7 @@ import { delay, http, HttpResponse } from 'msw';
import { StoryObj } from '@storybook/vue3';
import { entities } from 'misskey-js';
import { commonHandlers } from '../../../.storybook/mocks.js';
import { emoji } from '../../../.storybook/fakes.js';
import custom_emojis_manager2 from './custom-emojis-manager2.vue';
function createRender(params: {
@ -43,8 +44,12 @@ function createRender(params: {
...commonHandlers,
http.post('/api/admin/emoji/v2/list', async (req) => {
await delay(100);
const bodyStream = req.request.body.
const body = req.body as entities.AdminEmojiV2ListRequest;
console.log(req);
const emojis = params.emojis;
const limit = body.limit ?? 10;
const page = body.page ?? 1;
@ -66,3 +71,9 @@ function createRender(params: {
export const Default = createRender({
emojis: [],
});
export const Max10 = createRender({
emojis: [
emoji(), emoji(), emoji(), emoji(), emoji(), emoji(), emoji(), emoji(), emoji(), emoji(),
],
});