Files
webstudio/apps/builder/vitest.config.ts
Oleg Isonen 4273b7001f refactor: Organize Builder development and test tooling (#6285)
## Outcome

Builder development, backend, E2E, and CI tooling now share one
ownership model: Builder defines named commands and backend modes, while
CI only schedules those commands.

## Technical choices

- Group shared Compose files, PostgreSQL initialization, and backend
helpers under `apps/builder/backend`.
- Resolve `compose.<mode>.yaml` by convention instead of maintaining
Compose filename lists in scripts and workflows.
- Keep persistent development and disposable test Compose projects
separate by default, while allowing the standard `COMPOSE_PROJECT_NAME`
override.
- Make schema snapshots invalidate from discovered migration sources and
backend files.
- Move E2E behavior recipes into named Builder commands; retain concise
root proxies for developer entry points.
- Let Vitest allocate available browser ports instead of maintaining a
cross-package port registry.
- Keep test-suite scheduling explicit in `main.yml`, but move executable
test commands to root package scripts.
- Move fixture-size enforcement from inline GitHub JavaScript into a
locally runnable repository script.

## Todo

- [x] Consolidate Builder backend and Compose ownership.
- [x] Add named development, E2E, schema-cache, Supabase, and CI-shard
commands.
- [x] Remove Compose topology and behavior flags from CI.
- [x] Remove the static Vitest browser-port registry.
- [x] Extract fixture-size checking from the workflow.
- [x] Verify migration bootstrap, snapshot-backed E2E, tests, builds,
types, formatting, lint, generated contracts, and workflow syntax.
- [x] Review documentation impact: updated the E2E developer guide; no
user-facing `docs/` content is affected.

## Verification

- Full package, CLI, Builder core, and Builder app test suites
- Full workspace typecheck
- Builder production build
- Schema-cache generation through the complete migration history
- Supabase migration compatibility
- Snapshot-backed Playwright animation workflow
- Backend regression tests, including demonstrated fail/pass coverage
- All four Compose mode configurations
- `oxfmt`, `oxlint`, package boundaries, generated API, and generated
docs checks
- `actionlint` and Bash syntax checks

The fixture-size checker preserves the existing Linux `du` thresholds.
Its three inputs build locally; macOS allocation sizes are not directly
comparable to the Linux CI thresholds, so CI remains the authoritative
size result.
2026-08-31 21:09:54 +02:00

101 lines
2.5 KiB
TypeScript

import { resolve } from "node:path";
import { defineConfig } from "vitest/config";
const nodeTestGlob = "**/*.{server,node}.{test,spec}.{ts,tsx}";
const browserProject = (
group: "core" | "app",
name: string,
include: string[],
exclude: string[] = []
) => ({
extends: "./vitest.config.ts",
test: {
name: `${group}-browser-${name}`,
include,
exclude: [nodeTestGlob, ...exclude],
browser: {
provider: "playwright" as const,
enabled: true,
headless: true,
screenshotFailures: false,
instances: [{ browser: "chromium" as const }],
},
},
});
const serverProject = {
extends: "./vitest.config.ts",
test: {
name: "core-server",
include: [nodeTestGlob],
environment: "node",
},
};
const projects = [
serverProject,
browserProject("core", "builder-settings", [
"app/builder/features/{settings-panel,style-panel}/**/*.{test,spec}.{ts,tsx}",
]),
browserProject(
"core",
"builder-features",
["app/builder/features/**/*.{test,spec}.{ts,tsx}"],
[
"app/builder/features/{settings-panel,style-panel}/**/*.{test,spec}.{ts,tsx}",
]
),
browserProject("app", "builder-shared", [
"app/builder/shared/**/*.{test,spec}.{ts,tsx}",
"app/builder/*.{test,spec}.{ts,tsx}",
]),
browserProject("app", "shared-heavy", [
"app/shared/{copy-paste,instance-utils,sync}/**/*.{test,spec}.{ts,tsx}",
]),
browserProject(
"app",
"shared",
["app/shared/**/*.{test,spec}.{ts,tsx}"],
["app/shared/{copy-paste,instance-utils,sync}/**/*.{test,spec}.{ts,tsx}"]
),
browserProject("app", "canvas-dashboard", [
"app/{canvas,dashboard}/**/*.{test,spec}.{ts,tsx}",
]),
];
export default defineConfig({
optimizeDeps: {
entries: ["app/**/*.{test,spec}.{ts,tsx}"],
include: [
"react/jsx-dev-runtime",
"react-router-dom",
"css.escape",
"@lexical/react/LexicalComposer",
"@lexical/react/LexicalContentEditable",
"@lexical/react/LexicalErrorBoundary",
"@lexical/react/LexicalHistoryPlugin",
"@lexical/react/LexicalLinkPlugin",
"@lexical/react/LexicalRichTextPlugin",
],
},
resolve: {
alias: [
{
find: "~",
replacement: resolve("app"),
},
],
conditions: ["webstudio", "browser", "development|production"],
},
ssr: {
resolve: {
conditions: ["webstudio", "node", "development|production"],
},
},
test: {
silent: "passed-only",
workspace: projects,
},
});