/** * Drift guard: proves the desktop Drizzle baseline still reflects schema.ts. * * This is the safety net for the re-baseline — if someone edits schema.ts and * forgets to regenerate apps/desktop/drizzle, reconcile would silently miss the * new objects on real user DBs. The check shells out to drizzle-kit against a * throwaway copy of the migrations folder (see scripts/check-desktop-drift.ts), * so it never mutates apps/desktop. * * The test invokes the standalone script as a subprocess (the script lives * outside this package's tsconfig rootDir, so it is run, not imported). It is * slower than a unit test — it spawns drizzle-kit plus the TS schema loader — * hence the generous timeout. If drizzle-kit is unavailable the script exits * non-zero and this test fails loudly rather than silently skipping; a hidden * drift check is worse than none. */ import { expect, test } from "bun:test"; import { join } from "node:path"; const SCRIPT = join( import.meta.dir, "..", "..", "..", "scripts", "check-desktop-drift.ts", ); test( "desktop Drizzle baseline is in sync with schema.ts (no pending migration)", () => { const proc = Bun.spawnSync(["bun", "run", SCRIPT], { stdout: "pipe", stderr: "pipe", }); const output = `${proc.stdout.toString()}\n${proc.stderr.toString()}`; // Exit 0 = in sync. Non-zero = drift (or tooling failure); surface output. if (proc.exitCode !== 0) { throw new Error(`check-desktop-drift failed:\n${output}`); } expect(proc.exitCode).toBe(0); }, { timeout: 120_000 }, );