Merge remote-tracking branch 'misskey-dev/develop' into io

This commit is contained in:
まっちゃとーにゅ 2024-05-04 12:34:38 +09:00
commit 1a243d8ae8
No known key found for this signature in database
GPG key ID: 6AFBBF529601C1DB
53 changed files with 2071 additions and 2004 deletions

View file

@ -4,8 +4,10 @@
*/
/* eslint-disable @typescript-eslint/explicit-function-return-type */
import { expect, userEvent, waitFor, within } from '@storybook/test';
import { StoryObj } from '@storybook/vue3';
import MkAd from './MkAd.vue';
import { i18n } from '@/i18n.js';
let lock: Promise<undefined> | undefined;
@ -30,7 +32,6 @@ const common = {
template: '<MkAd v-bind="props" />',
};
},
/* FIXME: disabled because it still didnt pass after applying #11267
async play({ canvasElement, args }) {
if (lock) {
console.warn('This test is unexpectedly running twice in parallel, fix it!');
@ -44,7 +45,7 @@ const common = {
try {
const canvas = within(canvasElement);
const a = canvas.getByRole<HTMLAnchorElement>('link');
await expect(a.href).toMatch(/^https?:\/\/.*#test$/);
// await expect(a.href).toMatch(/^https?:\/\/.*#test$/);
const img = within(a).getByRole('img');
await expect(img).toBeInTheDocument();
let buttons = canvas.getAllByRole<HTMLButtonElement>('button');
@ -52,13 +53,14 @@ const common = {
const i = buttons[0];
await expect(i).toBeInTheDocument();
await userEvent.click(i);
await waitFor(() => expect(canvasElement).toHaveTextContent(i18n.ts._ad.back));
// await expect(canvasElement).toHaveTextContent(i18n.ts._ad.back);
await expect(a).not.toBeInTheDocument();
await expect(i).not.toBeInTheDocument();
buttons = canvas.getAllByRole<HTMLButtonElement>('button');
await expect(buttons).toHaveLength(args.__hasReduce ? 2 : 1);
const reduce = args.__hasReduce ? buttons[0] : null;
const back = buttons[args.__hasReduce ? 1 : 0];
const hasReduceFrequency = args.specify?.ratio !== 0;
await expect(buttons).toHaveLength(hasReduceFrequency ? 2 : 1);
const reduce = hasReduceFrequency ? buttons[0] : null;
const back = buttons[hasReduceFrequency ? 1 : 0];
if (reduce) {
await expect(reduce).toBeInTheDocument();
await expect(reduce).toHaveTextContent(i18n.ts._ad.reduceFrequencyOfThisAd);
@ -80,15 +82,16 @@ const common = {
lock = undefined;
}
},
*/
args: {
prefer: [],
specify: {
id: 'someadid',
radio: 1,
ratio: 1,
url: '#test',
place: '',
imageUrl: '',
dayOfWeek: 7,
},
__hasReduce: true,
},
parameters: {
layout: 'centered',
@ -138,6 +141,5 @@ export const ZeroRatio = {
...Square.args.specify,
ratio: 0,
},
__hasReduce: false,
},
} satisfies StoryObj<typeof MkAd>;

View file

@ -33,7 +33,7 @@ const common = {
},
decorators: [
(Story, context) => ({
// eslint-disable-next-line quotes
// @ts-expect-error size is for test
template: `<div :style="{ display: 'grid', width: '${context.args.size}px', height: '${context.args.size}px' }"><story/></div>`,
}),
],
@ -45,6 +45,7 @@ export const ProfilePage = {
...common,
args: {
...common.args,
// @ts-expect-error size is for test
size: 120,
indicator: true,
},

View file

@ -28,6 +28,7 @@ export const Default = {
};
},
args: {
// @ts-expect-error text is for test
text: 'This is a condensed line.',
},
parameters: {
@ -41,4 +42,5 @@ export const ContainerIs100px = {
template: '<div style="width: 100px;"><story/></div>',
}),
],
// @ts-expect-error text is for test
} satisfies StoryObj<typeof MkCondensedLine>;

View file

@ -3,8 +3,11 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { Meta } from '@storybook/vue3';
import MkError from './MkError.vue';
export const argTypes = {
retry: {
onRetry: {
action: 'retry',
},
};
} satisfies Meta<typeof MkError>['argTypes'];

View file

@ -33,7 +33,6 @@ export const Empty = {
await waitFor(async () => await wait);
},
args: {
static: true,
tabs: [],
},
parameters: {
@ -71,8 +70,8 @@ export const IconOnly = {
...Icon.args,
tabs: [
{
...Icon.args.tabs[0],
title: undefined,
key: Icon.args.tabs[0].key,
icon: Icon.args.tabs[0].icon,
iconOnly: true,
},
],

View file

@ -38,7 +38,6 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts">
export type Tab = {
key: string;
title: string;
onClick?: (ev: MouseEvent) => void;
} & (
| {

View file

@ -60,7 +60,7 @@ export const RelativeFuture = {
export const AbsoluteFuture = {
...Empty,
async play({ canvasElement, args }) {
await expect(canvasElement).toHaveTextContent(dateTimeFormat.format(args.time));
await expect(canvasElement).toHaveTextContent(dateTimeFormat.format(typeof args.time === 'string' ? new Date(args.time) : args.time ?? undefined));
},
args: {
...Empty.args,
@ -97,7 +97,7 @@ export const RelativeNow = {
export const AbsoluteNow = {
...Empty,
async play({ canvasElement, args }) {
await expect(canvasElement).toHaveTextContent(dateTimeFormat.format(args.time));
await expect(canvasElement).toHaveTextContent(dateTimeFormat.format(typeof args.time === 'string' ? new Date(args.time) : args.time ?? undefined));
},
args: {
...Empty.args,
@ -136,7 +136,7 @@ export const RelativeOneHourAgo = {
export const AbsoluteOneHourAgo = {
...Empty,
async play({ canvasElement, args }) {
await expect(canvasElement).toHaveTextContent(dateTimeFormat.format(args.time));
await expect(canvasElement).toHaveTextContent(dateTimeFormat.format(typeof args.time === 'string' ? new Date(args.time) : args.time ?? undefined));
},
args: {
...Empty.args,
@ -175,7 +175,7 @@ export const RelativeOneDayAgo = {
export const AbsoluteOneDayAgo = {
...Empty,
async play({ canvasElement, args }) {
await expect(canvasElement).toHaveTextContent(dateTimeFormat.format(args.time));
await expect(canvasElement).toHaveTextContent(dateTimeFormat.format(typeof args.time === 'string' ? new Date(args.time) : args.time ?? undefined));
},
args: {
...Empty.args,
@ -214,7 +214,7 @@ export const RelativeOneWeekAgo = {
export const AbsoluteOneWeekAgo = {
...Empty,
async play({ canvasElement, args }) {
await expect(canvasElement).toHaveTextContent(dateTimeFormat.format(args.time));
await expect(canvasElement).toHaveTextContent(dateTimeFormat.format(typeof args.time === 'string' ? new Date(args.time) : args.time ?? undefined));
},
args: {
...Empty.args,
@ -253,7 +253,7 @@ export const RelativeOneMonthAgo = {
export const AbsoluteOneMonthAgo = {
...Empty,
async play({ canvasElement, args }) {
await expect(canvasElement).toHaveTextContent(dateTimeFormat.format(args.time));
await expect(canvasElement).toHaveTextContent(dateTimeFormat.format(typeof args.time === 'string' ? new Date(args.time) : args.time ?? undefined));
},
args: {
...Empty.args,
@ -292,7 +292,7 @@ export const RelativeOneYearAgo = {
export const AbsoluteOneYearAgo = {
...Empty,
async play({ canvasElement, args }) {
await expect(canvasElement).toHaveTextContent(dateTimeFormat.format(args.time));
await expect(canvasElement).toHaveTextContent(dateTimeFormat.format(typeof args.time === 'string' ? new Date(args.time) : args.time ?? undefined));
},
args: {
...Empty.args,

View file

@ -30,7 +30,7 @@ export const Default = {
};
},
async play({ canvasElement }) {
await expect(canvasElement).toHaveTextContent(userDetailed().name);
await expect(canvasElement).toHaveTextContent(userDetailed().name as string);
},
args: {
user: userDetailed(),