Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(frontend): fix Chromatic test fails #13826

Merged
merged 2 commits into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/frontend/src/components/MkModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,11 @@ const align = () => {
const onOpened = () => {
emit('opened');

// NOTE: Chromatic テストの際に undefined になる場合がある
if (content.value == null) return;

// モーダルコンテンツにマウスボタンが押され、コンテンツ外でマウスボタンが離されたときにモーダルバックグラウンドクリックと判定させないためにマウスイベントを監視しフラグ管理する
const el = content.value!.children[0];
const el = content.value.children[0];
el.addEventListener('mousedown', ev => {
contentClicking = true;
window.addEventListener('mouseup', ev => {
Expand Down
8 changes: 7 additions & 1 deletion packages/frontend/src/components/global/MkAd.stories.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import { i18n } from '@/i18n.js';

let lock: Promise<undefined> | undefined;

function sleep(ms: number) {
return new Promise(resolve => setTimeout(resolve, ms));
}

const common = {
render(args) {
return {
Expand Down Expand Up @@ -43,6 +47,8 @@ const common = {
lock = new Promise(r => resolve = r);

try {
// NOTE: sleep しないと何故か落ちる
await sleep(100);
const canvas = within(canvasElement);
const a = canvas.getByRole<HTMLAnchorElement>('link');
// await expect(a.href).toMatch(/^https?:\/\/.*#test$/);
Expand All @@ -53,7 +59,7 @@ const common = {
const i = buttons[0];
await expect(i).toBeInTheDocument();
await userEvent.click(i);
// await 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');
Expand Down
Loading