From ed5b9a6f7cc2d7d6620d4d7bd4c9084a09a9df7c Mon Sep 17 00:00:00 2001 From: simoleo89 Date: Thu, 30 Jul 2026 19:41:45 +0200 Subject: [PATCH] fix(test): align media path mocks and deploy contract with main Use path.join in admin-media tests for Windows path.sep checks, and drop the deploy-job pnpm test expectation after it moved to CI. Co-authored-by: Cursor --- src/actions/admin-media.test.ts | 13 +++++++++---- src/lib/deploy-workflow-contract.test.ts | 7 +++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/actions/admin-media.test.ts b/src/actions/admin-media.test.ts index 3829b72d..99f7f56d 100644 --- a/src/actions/admin-media.test.ts +++ b/src/actions/admin-media.test.ts @@ -1,5 +1,7 @@ // @ts-nocheck + import { mkdir, writeFile } from "node:fs/promises"; +import path from "node:path"; import { revalidatePath } from "next/cache"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { requirePermission } from "@/lib/admin/guard"; @@ -9,10 +11,13 @@ import { deleteMedia, uploadMedia, uploadMediaAndReturn } from "./admin-media"; vi.mock("@/lib/admin/guard", () => ({ requirePermission: vi.fn() })); vi.mock("@/lib/permissions", () => ({ PERMS: { PAGES_EDIT: "pages.edit" } })); -vi.mock("@/lib/media-storage", () => ({ - MEDIA_ROOT: "/tmp/nexst-test-media", - resolveMediaPath: vi.fn((name: string) => `/tmp/nexst-test-media/${name}`), -})); +vi.mock("@/lib/media-storage", () => { + const root = path.join("/tmp", "nexst-test-media"); + return { + MEDIA_ROOT: root, + resolveMediaPath: vi.fn((name: string) => path.join(root, name)), + }; +}); vi.mock("node:fs/promises", () => ({ mkdir: vi.fn(), writeFile: vi.fn(), diff --git a/src/lib/deploy-workflow-contract.test.ts b/src/lib/deploy-workflow-contract.test.ts index 45545357..0f7a97c2 100644 --- a/src/lib/deploy-workflow-contract.test.ts +++ b/src/lib/deploy-workflow-contract.test.ts @@ -83,13 +83,12 @@ describe("production deploy workflow", () => { expect(workflow).not.toContain("PNPM_CONFIG_ONLY_BUILT_DEPENDENCIES"); }); - it("runs typecheck and tests before build in the stage", () => { + it("runs typecheck before build in the stage", () => { const typecheckAt = deployJob.indexOf("pnpm typecheck"); - const testAt = deployJob.indexOf("pnpm test"); const buildAt = deployJob.indexOf("pnpm build"); expect(typecheckAt).toBeGreaterThan(-1); - expect(testAt).toBeGreaterThan(typecheckAt); - expect(buildAt).toBeGreaterThan(testAt); + expect(buildAt).toBeGreaterThan(typecheckAt); + expect(deployJob).not.toContain("pnpm test"); }); it("exports APP_VERSION from git for Sentry releases", () => {