Skip to content
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
2 changes: 1 addition & 1 deletion messages/ja/dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@
"configTotalTimeout": "全体タイムアウト",
"configStickyCooldown": "Sticky タイムアウトのクールダウン",
"configStickyBindingTtl": "Sticky バインドの有効期間 (SESSION_TTL)",
"slotSaturation": "Hedge スロット飽和{count} 件",
"slotSaturation": "Hedge スロット飽和 ({count} 件)",
"slotSaturationEvent": "{provider} · {active}/{cap} 件がアクティブ · 経過 {elapsed}ms",
"attemptDetails": {
"providerId": "Provider ID",
Expand Down
49 changes: 49 additions & 0 deletions tests/framer-motion.mock.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { createElement, type ComponentType, type ReactNode } from "react";
import { vi } from "vitest";

type MotionProps = {
children?: ReactNode;
[key: string]: unknown;
};

const motionOnlyProps = new Set([
"animate",
"custom",
"exit",
"initial",
"layout",
"layoutId",
"onAnimationComplete",
"onAnimationStart",
"transition",
"variants",
"whileFocus",
"whileHover",
"whileInView",
"whileTap",
]);

function createMotionComponent(tag: string): ComponentType<MotionProps> {
return ({ children, ...props }) => {
const domProps = Object.fromEntries(
Object.entries(props).filter(([name]) => !motionOnlyProps.has(name))
);
return createElement(tag, domProps, children);
};
}

const motionComponents = new Map<string, ComponentType<MotionProps>>();
const motion = new Proxy({} as Record<string, ComponentType<MotionProps>>, {
get: (_target, property: string | symbol) => {
if (typeof property !== "string") return undefined;

const existing = motionComponents.get(property);
if (existing) return existing;

const component = createMotionComponent(property);
motionComponents.set(property, component);
return component;
},
});

vi.mock("framer-motion", () => ({ motion }));
1 change: 1 addition & 0 deletions tests/unit/auth/login-page-site-title.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import { act } from "react";
import { createRoot } from "react-dom/client";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import "../../framer-motion.mock";
import LoginPage from "../../../src/app/[locale]/login/page";

const mockPush = vi.hoisted(() => vi.fn());
Expand Down
1 change: 1 addition & 0 deletions tests/unit/login/login-footer-system-name.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { act } from "react";
import { createRoot } from "react-dom/client";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import "../../framer-motion.mock";
import LoginPage from "@/app/[locale]/login/page";
import { DEFAULT_SITE_TITLE } from "@/lib/site-title";

Expand Down
1 change: 1 addition & 0 deletions tests/unit/login/login-footer-version.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { act } from "react";
import { createRoot } from "react-dom/client";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import "../../framer-motion.mock";
import LoginPage from "@/app/[locale]/login/page";

const mockPush = vi.hoisted(() => vi.fn());
Expand Down
1 change: 1 addition & 0 deletions tests/unit/login/login-loading-state.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { describe, expect, it, vi, beforeEach, afterEach } from "vitest";
import { createRoot } from "react-dom/client";
import { act } from "react";
import "../../framer-motion.mock";
import LoginPage from "@/app/[locale]/login/page";

const mockPush = vi.hoisted(() => vi.fn());
Expand Down
1 change: 1 addition & 0 deletions tests/unit/login/login-overlay-a11y.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { describe, expect, it, vi, beforeEach, afterEach } from "vitest";
import { createRoot } from "react-dom/client";
import { act } from "react";
import "../../framer-motion.mock";
import LoginPage from "@/app/[locale]/login/page";

const mockPush = vi.hoisted(() => vi.fn());
Expand Down
1 change: 1 addition & 0 deletions tests/unit/login/login-ui-redesign.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { describe, expect, it, vi, beforeEach, afterEach } from "vitest";
import { createRoot } from "react-dom/client";
import { act } from "react";
import "../../framer-motion.mock";
import LoginPage from "@/app/[locale]/login/page";

const mockPush = vi.hoisted(() => vi.fn());
Expand Down
1 change: 1 addition & 0 deletions tests/unit/login/login-visual-regression.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { describe, expect, it, vi, beforeEach, afterEach } from "vitest";
import { createRoot } from "react-dom/client";
import { act } from "react";
import "../../framer-motion.mock";
import LoginPage from "@/app/[locale]/login/page";

// Mocks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { act } from "react";
import { createRoot } from "react-dom/client";
import { NextIntlClientProvider } from "next-intl";
import { beforeEach, describe, expect, test, vi } from "vitest";
import "../../../framer-motion.mock";
import { ProviderForm } from "../../../../src/app/[locale]/settings/providers/_components/forms/provider-form";
import { Dialog } from "../../../../src/components/ui/dialog";
import enMessages from "../../../../messages/en";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { act } from "react";
import { createRoot } from "react-dom/client";
import { NextIntlClientProvider } from "next-intl";
import { beforeEach, describe, expect, test, vi } from "vitest";
import "../../../framer-motion.mock";
import { ProviderForm } from "../../../../src/app/[locale]/settings/providers/_components/forms/provider-form";
import { Dialog } from "../../../../src/components/ui/dialog";
import enMessages from "../../../../messages/en";
Expand Down
Loading