From 1ec05cda3942e2a468078854fb2d7bf20818564b Mon Sep 17 00:00:00 2001 From: simoleo89 Date: Sun, 30 Aug 2026 12:27:12 +0200 Subject: [PATCH] test: make media route fixture cross-platform --- src/app/api/media/[...path]/route.test.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/app/api/media/[...path]/route.test.ts b/src/app/api/media/[...path]/route.test.ts index c7c35dd22e..3cad745740 100644 --- a/src/app/api/media/[...path]/route.test.ts +++ b/src/app/api/media/[...path]/route.test.ts @@ -5,12 +5,14 @@ import { GET } from "./route"; vi.mock("node:fs", () => ({ existsSync: vi.fn() })); vi.mock("node:fs/promises", () => ({ readFile: vi.fn() })); -vi.mock("@/lib/media-storage", () => ({ - MEDIA_ROOT: "C:\\media", - resolveMediaPath: vi.fn( - (name: string) => `C:\\media\\${name.replaceAll("/", "\\")}`, - ), -})); +vi.mock("@/lib/media-storage", async () => { + const path = await import("node:path"); + const mediaRoot = path.resolve("media-fixture"); + return { + MEDIA_ROOT: mediaRoot, + resolveMediaPath: vi.fn((name: string) => path.join(mediaRoot, name)), + }; +}); describe("GET /api/media/[...path]", () => { beforeEach(() => {