Files
SnapOtter/tests/integration/platform/jobs-schema.test.ts
T
SnapOtter 1727a7a73e test: reorganize flat test files into purpose-based subdirectories (phase 6)
Group 245 flat integration tests and 25 loose unit tests into
discoverable subdirectories per spec section 6:

  integration/tools/{image,video,audio,document,data}/  (156 files)
  integration/platform/                                  (64 files)
  integration/generated/                                 (14 files)
  integration/security/                                  (10 files)

  unit/security/     (8 files, new subdir)
  unit/api/          (7 files moved in)
  unit/web/          (3 files moved in)
  unit/shared/       (6 files moved in)
  unit/image-engine/ (1 file moved in)

All moves via git mv (history preserved). Relative imports repaired
for both depth levels (platform/generated/security = +1, tools/ = +2):
static from-imports, dynamic import() calls, vi.mock() paths,
import.meta.dirname joins, and __dirname joins.

Vitest discovery unchanged (no test.include in config, recursive glob
matches subdirs, shard-by-hash unaffected). test-server.ts and
tool-route-drift.test.ts stay at integration root. fixtures/ untouched.

Parity gate: 13189 passing test names before = 13189 after (0 dropped).
2026-06-20 05:07:46 +08:00

35 lines
1.2 KiB
TypeScript

import { sql } from "drizzle-orm";
import { describe, expect, it } from "vitest";
import { db } from "../../../apps/api/src/db/index.js";
describe("jobs table (phase 2 spine)", () => {
it("has the spine columns and canceled status", async () => {
const cols = await db.execute(
sql`SELECT column_name FROM information_schema.columns WHERE table_name = 'jobs'`,
);
const names = cols.rows.map((r) => r.column_name);
for (const expected of [
"user_id",
"tool_id",
"pool",
"attempts",
"input_refs",
"output_refs",
"bytes_in",
"bytes_out",
"duration_ms",
"started_at",
"progress",
"error",
]) {
expect(names).toContain(expected);
}
const enumRows = await db.execute(sql`SELECT unnest(enum_range(NULL::job_status))::text AS v`);
expect(enumRows.rows.map((r) => r.v)).toContain("canceled");
await db.execute(
sql`INSERT INTO jobs (id, type, status, progress, input_refs, created_at) VALUES ('schema-test', 'single', 'canceled', '{"percent":50}', '["uploads/x"]', now())`,
);
await db.execute(sql`DELETE FROM jobs WHERE id = 'schema-test'`);
});
});