- Add lib/db (Drizzle schema: 7 tables + 6 enums + relations, postgres.js client), drizzle.config.ts, lib/db/enums.ts (Prisma-compatible enum objects) - Rewrite all 14 app consumers + 4 admin components to Drizzle - Move the test DB layer to Drizzle + in-process PGlite; convert all 8 integration test files + factories (371 tests green) - Remove Prisma: deps, prisma/ schema+migrations, lib/prisma.ts, Dockerfile prisma generate; wire db:generate/migrate/push/studio to drizzle-kit; update Makefile - Preserve the old seed as scripts/legacy-prisma-seed.cjs (needs a Drizzle rewrite)
43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
import { eq } from "drizzle-orm";
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
import { db } from "@/lib/db";
|
|
import { appConfig, category } from "@/lib/db/schema";
|
|
|
|
describe("integration harness smoke test", () => {
|
|
it("connects to the migrated test database and performs CRUD", async () => {
|
|
const [created] = await db
|
|
.insert(category)
|
|
.values({
|
|
slug: "smoke",
|
|
nameAr: "a",
|
|
nameEn: "b",
|
|
nameDe: "c",
|
|
descriptionAr: "a",
|
|
descriptionEn: "b",
|
|
descriptionDe: "c",
|
|
})
|
|
.returning();
|
|
|
|
expect(created.id).toBeTruthy();
|
|
expect(created.isActive).toBe(true);
|
|
|
|
const found = await db.query.category.findFirst({ where: eq(category.slug, "smoke") });
|
|
expect(found?.nameEn).toBe("b");
|
|
});
|
|
|
|
it("resets the database between tests", async () => {
|
|
const count = await db.$count(category);
|
|
expect(count).toBe(0);
|
|
});
|
|
|
|
it("supports enums and appconfig upsert", async () => {
|
|
await db
|
|
.insert(appConfig)
|
|
.values({ key: "k", value: "v1" })
|
|
.onConflictDoUpdate({ target: appConfig.key, set: { value: "v2" } });
|
|
const row = await db.query.appConfig.findFirst({ where: eq(appConfig.key, "k") });
|
|
expect(row?.value).toBe("v1");
|
|
});
|
|
});
|