36 lines
1.5 KiB
TypeScript
36 lines
1.5 KiB
TypeScript
// @vitest-environment node
|
|
import { describe, expect, test } from "vitest";
|
|
import { readFileSync } from "node:fs";
|
|
import { fileURLToPath } from "node:url";
|
|
import path from "node:path";
|
|
|
|
const source = readFileSync(path.join(path.dirname(fileURLToPath(import.meta.url)), "users.db.server.ts"), "utf8");
|
|
|
|
describe("users db wrapper", () => {
|
|
test("allows user profile updates to persist light or dark mode", () => {
|
|
expect(source).toContain("lightOrDarkMode?: string");
|
|
});
|
|
|
|
test("provides a tenant-scoped user details helper for app routes", () => {
|
|
expect(source).toContain("export async function getTenantScopedUsersWithDetails(tenantId: string)");
|
|
expect(source).toContain("tenants: {\n where: {\n tenantId,\n },");
|
|
expect(source).toContain("roles: {\n where: {\n tenantId,\n },");
|
|
});
|
|
|
|
test("keeps core user registration free of CRM and marketing side effects", () => {
|
|
expect(source).not.toContain("~/modules/crm/services/CrmService");
|
|
expect(source).not.toContain("marketingSubscriber: true");
|
|
expect(source).not.toContain("Created user contact");
|
|
});
|
|
|
|
test("returns the persisted default tenant after user registration", () => {
|
|
expect(source).toContain("defaultTenantId: user.defaultTenantId");
|
|
});
|
|
|
|
test("parallelizes admin user pagination queries", () => {
|
|
expect(source).toContain("const [items, totalItems] = await Promise.all([");
|
|
expect(source).toContain("db.user.findMany({");
|
|
expect(source).toContain("db.user.count({\n where,\n }),");
|
|
});
|
|
});
|