- Vitest multi-project setup (unit / integration / component) - Real-Postgres integration harness via in-process PGlite (TEST_DATABASE_URL override), migrations applied per worker; production code untouched - Unit: routing, locale, validation/Zod schemas, metadata, mail, site-theme, marquee, media, portfolio helpers, plus architecture-rule tests - Integration: Prisma data layer, API routes, and all server actions - Component: UI primitives and form components (jsdom + Testing Library) - 371 tests passing
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import { prisma } from "@/lib/prisma";
|
|
|
|
describe("integration harness smoke test", () => {
|
|
it("connects to the migrated test database and performs CRUD", async () => {
|
|
const created = await prisma.category.create({
|
|
data: {
|
|
slug: "smoke",
|
|
nameAr: "a",
|
|
nameEn: "b",
|
|
nameDe: "c",
|
|
descriptionAr: "a",
|
|
descriptionEn: "b",
|
|
descriptionDe: "c",
|
|
},
|
|
});
|
|
|
|
expect(created.id).toBeTruthy();
|
|
expect(created.isActive).toBe(true);
|
|
|
|
const found = await prisma.category.findUnique({ where: { slug: "smoke" } });
|
|
expect(found?.nameEn).toBe("b");
|
|
});
|
|
|
|
it("resets the database between tests", async () => {
|
|
const count = await prisma.category.count();
|
|
expect(count).toBe(0);
|
|
});
|
|
|
|
it("supports enums and appconfig upsert", async () => {
|
|
await prisma.appConfig.upsert({
|
|
where: { key: "k" },
|
|
update: { value: "v2" },
|
|
create: { key: "k", value: "v1" },
|
|
});
|
|
const row = await prisma.appConfig.findUnique({ where: { key: "k" } });
|
|
expect(row?.value).toBe("v1");
|
|
});
|
|
});
|