fix(frontend): workaround storybook issue (#11334)
This commit is contained in:
parent
509e3f979e
commit
df2b61fcc6
1 changed files with 48 additions and 31 deletions
|
@ -4,6 +4,9 @@ import { userEvent, waitFor, within } from '@storybook/testing-library';
|
||||||
import { StoryObj } from '@storybook/vue3';
|
import { StoryObj } from '@storybook/vue3';
|
||||||
import MkAd from './MkAd.vue';
|
import MkAd from './MkAd.vue';
|
||||||
import { i18n } from '@/i18n';
|
import { i18n } from '@/i18n';
|
||||||
|
|
||||||
|
let lock: Promise<undefined> | undefined;
|
||||||
|
|
||||||
const common = {
|
const common = {
|
||||||
render(args) {
|
render(args) {
|
||||||
return {
|
return {
|
||||||
|
@ -26,6 +29,16 @@ const common = {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
async play({ canvasElement, args }) {
|
async play({ canvasElement, args }) {
|
||||||
|
if (lock) {
|
||||||
|
console.warn('This test is unexpectedly running twice in parallel, fix it!');
|
||||||
|
console.warn('See also: https://github.com/misskey-dev/misskey/issues/11267');
|
||||||
|
await lock;
|
||||||
|
}
|
||||||
|
|
||||||
|
let resolve: (value?: any) => void;
|
||||||
|
lock = new Promise(r => resolve = r);
|
||||||
|
|
||||||
|
try {
|
||||||
const canvas = within(canvasElement);
|
const canvas = within(canvasElement);
|
||||||
const a = canvas.getByRole<HTMLAnchorElement>('link');
|
const a = canvas.getByRole<HTMLAnchorElement>('link');
|
||||||
await expect(a.href).toMatch(/^https?:\/\/.*#test$/);
|
await expect(a.href).toMatch(/^https?:\/\/.*#test$/);
|
||||||
|
@ -59,6 +72,10 @@ const common = {
|
||||||
await expect(aAgain).toBeInTheDocument();
|
await expect(aAgain).toBeInTheDocument();
|
||||||
const imgAgain = within(aAgain).getByRole('img');
|
const imgAgain = within(aAgain).getByRole('img');
|
||||||
await expect(imgAgain).toBeInTheDocument();
|
await expect(imgAgain).toBeInTheDocument();
|
||||||
|
} finally {
|
||||||
|
resolve!();
|
||||||
|
lock = undefined;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
args: {
|
args: {
|
||||||
prefer: [],
|
prefer: [],
|
||||||
|
|
Loading…
Reference in a new issue