From 4ba8cb723c8e5cb62c17da63e11e83b97133cc8d Mon Sep 17 00:00:00 2001 From: Formsmith Date: Sun, 14 Jun 2026 22:13:13 +0300 Subject: [PATCH] Organize test files --- package.json | 6 +++--- {apps/web/src => tests}/perf/stl-import.perf.ts | 2 +- {apps/web/src/lib => tests/unit}/shapeCatalog.test.ts | 2 +- {apps/web/src/lib => tests/unit}/workplaneSettings.test.ts | 2 +- {apps/web/src/lib => tests/unit}/workplaneShapes.test.ts | 2 +- vitest.config.ts => tests/vitest.config.ts | 7 +++++-- vitest.perf.config.ts => tests/vitest.perf.config.ts | 7 +++++-- 7 files changed, 17 insertions(+), 11 deletions(-) rename {apps/web/src => tests}/perf/stl-import.perf.ts (99%) rename {apps/web/src/lib => tests/unit}/shapeCatalog.test.ts (98%) rename {apps/web/src/lib => tests/unit}/workplaneSettings.test.ts (98%) rename {apps/web/src/lib => tests/unit}/workplaneShapes.test.ts (99%) rename vitest.config.ts => tests/vitest.config.ts (54%) rename vitest.perf.config.ts => tests/vitest.perf.config.ts (60%) diff --git a/package.json b/package.json index fa1af25..465063e 100644 --- a/package.json +++ b/package.json @@ -8,9 +8,9 @@ "export": "set STATIC_EXPORT=true&& next build apps/web", "start": "next start apps/web", "typecheck": "tsc -p apps/web/tsconfig.json --noEmit", - "test": "vitest run", - "test:watch": "vitest", - "perf": "vitest run --config vitest.perf.config.ts --reporter verbose", + "test": "vitest run --config tests/vitest.config.ts", + "test:watch": "vitest --config tests/vitest.config.ts", + "perf": "vitest run --config tests/vitest.perf.config.ts --reporter verbose", "ci": "npm run typecheck && npm run test" }, "dependencies": { diff --git a/apps/web/src/perf/stl-import.perf.ts b/tests/perf/stl-import.perf.ts similarity index 99% rename from apps/web/src/perf/stl-import.perf.ts rename to tests/perf/stl-import.perf.ts index ac8d3bd..8b47009 100644 --- a/apps/web/src/perf/stl-import.perf.ts +++ b/tests/perf/stl-import.perf.ts @@ -174,7 +174,7 @@ function printReport(rows: BenchRow[]) { describe("STL performance benchmark", () => { it("measures import and local-first persistence costs", async () => { const rows: BenchRow[] = []; - const stlModule = await measure(rows, "startup", "load STL import module", 1, {}, () => import("../lib/stlImport")); + const stlModule = await measure(rows, "startup", "load STL import module", 1, {}, () => import("@/lib/stlImport")); const importedShapeFromStl = stlModule.importedShapeFromStl as ImportedShapeFromStl; for (const workload of SYNTHETIC_WORKLOADS) { diff --git a/apps/web/src/lib/shapeCatalog.test.ts b/tests/unit/shapeCatalog.test.ts similarity index 98% rename from apps/web/src/lib/shapeCatalog.test.ts rename to tests/unit/shapeCatalog.test.ts index 7c11057..1768c58 100644 --- a/apps/web/src/lib/shapeCatalog.test.ts +++ b/tests/unit/shapeCatalog.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from "vitest"; import type { ShapeAsset } from "@/types/sketchforge"; -import { makeShapeFromAsset, sceneShape, toolbarShapeAssets } from "./shapeCatalog"; +import { makeShapeFromAsset, sceneShape, toolbarShapeAssets } from "@/lib/shapeCatalog"; describe("shape catalog", () => { it("does not expose removed decorative shapes in the toolbar catalog", () => { diff --git a/apps/web/src/lib/workplaneSettings.test.ts b/tests/unit/workplaneSettings.test.ts similarity index 98% rename from apps/web/src/lib/workplaneSettings.test.ts rename to tests/unit/workplaneSettings.test.ts index 8b75fe9..1d54006 100644 --- a/apps/web/src/lib/workplaneSettings.test.ts +++ b/tests/unit/workplaneSettings.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from "vitest"; import type { WorkplaneWorkspaceSettings } from "@/types/sketchforge"; -import { DEFAULT_SNAP_GRID, DEFAULT_WORKPLANE_WORKSPACE, normalizeSnapGrid, normalizeWorkspaceSettings, workplaneSettingsFingerprint } from "./workplaneSettings"; +import { DEFAULT_SNAP_GRID, DEFAULT_WORKPLANE_WORKSPACE, normalizeSnapGrid, normalizeWorkspaceSettings, workplaneSettingsFingerprint } from "@/lib/workplaneSettings"; describe("workplane settings helpers", () => { it("accepts known snap grid values and falls back for unknown values", () => { diff --git a/apps/web/src/lib/workplaneShapes.test.ts b/tests/unit/workplaneShapes.test.ts similarity index 99% rename from apps/web/src/lib/workplaneShapes.test.ts rename to tests/unit/workplaneShapes.test.ts index 64168aa..8783a91 100644 --- a/apps/web/src/lib/workplaneShapes.test.ts +++ b/tests/unit/workplaneShapes.test.ts @@ -14,7 +14,7 @@ import { shapeDepth, shapeWidth, workplaneShapesEqual, -} from "./workplaneShapes"; +} from "@/lib/workplaneShapes"; function shape(overrides: Partial = {}): WorkplaneShape { return { diff --git a/vitest.config.ts b/tests/vitest.config.ts similarity index 54% rename from vitest.config.ts rename to tests/vitest.config.ts index cc3f5a9..8e29ef4 100644 --- a/vitest.config.ts +++ b/tests/vitest.config.ts @@ -1,14 +1,17 @@ import path from "node:path"; import { defineConfig } from "vitest/config"; +const rootDir = path.resolve(__dirname, ".."); + export default defineConfig({ + root: rootDir, resolve: { alias: { - "@": path.resolve(__dirname, "apps/web/src"), + "@": path.resolve(rootDir, "apps/web/src"), }, }, test: { environment: "node", - include: ["apps/web/src/**/*.test.ts"], + include: ["tests/unit/**/*.test.ts"], }, }); diff --git a/vitest.perf.config.ts b/tests/vitest.perf.config.ts similarity index 60% rename from vitest.perf.config.ts rename to tests/vitest.perf.config.ts index 03cd1da..843579e 100644 --- a/vitest.perf.config.ts +++ b/tests/vitest.perf.config.ts @@ -1,15 +1,18 @@ import path from "node:path"; import { defineConfig } from "vitest/config"; +const rootDir = path.resolve(__dirname, ".."); + export default defineConfig({ + root: rootDir, resolve: { alias: { - "@": path.resolve(__dirname, "apps/web/src"), + "@": path.resolve(rootDir, "apps/web/src"), }, }, test: { environment: "node", - include: ["apps/web/src/perf/**/*.perf.ts"], + include: ["tests/perf/**/*.perf.ts"], testTimeout: 120000, hookTimeout: 120000, },