From c2c920c4a208ab095dc46a248e00d7dfbad032d0 Mon Sep 17 00:00:00 2001 From: samunohito <46447427+samunohito@users.noreply.github.com> Date: Fri, 23 Feb 2024 09:34:26 +0900 Subject: [PATCH] [wip] add custom-emojis-manager2.stories.impl.ts --- packages/frontend/.storybook/fakes.ts | 40 +++++++++++++++++++ .../custom-emojis-manager2.stories.impl.ts | 11 +++++ 2 files changed, 51 insertions(+) diff --git a/packages/frontend/.storybook/fakes.ts b/packages/frontend/.storybook/fakes.ts index ef969e2321..20f07f46fe 100644 --- a/packages/frontend/.storybook/fakes.ts +++ b/packages/frontend/.storybook/fakes.ts @@ -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(), + } +} diff --git a/packages/frontend/src/pages/admin/custom-emojis-manager2.stories.impl.ts b/packages/frontend/src/pages/admin/custom-emojis-manager2.stories.impl.ts index 7b47bedb10..0e6852a342 100644 --- a/packages/frontend/src/pages/admin/custom-emojis-manager2.stories.impl.ts +++ b/packages/frontend/src/pages/admin/custom-emojis-manager2.stories.impl.ts @@ -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(), + ], +});