import { readFileSync } from "node:fs"; import { resolve } from "node:path"; import { describe, expect, it } from "vitest"; const rootPath = (...segments: string[]) => resolve(process.cwd(), ...segments); const readProjectFile = (path: string) => readFileSync(rootPath(path), "utf8"); describe("row tenant-scope guard", () => { it("requires explicit tenant and entity scope for row reloads", () => { const source = readProjectFile("apps/web/app/utils/db/entities/rows.db.server.ts"); expect(source).toContain("getRowById(id: string, scope: { entityId?: string; tenantId: string | null })"); expect(source).not.toContain("getRowById(id: string, scope?:"); expect(source).not.toContain("RowModelHelper.includeRowDetailsNested"); }); it("keeps legacy row relationship helpers tenant-scoped", () => { const source = readProjectFile("apps/web/app/utils/db/entities/rowRelationships.db.server.ts"); expect(source).toContain("type RowRelationshipTenantScope"); expect(source).toContain("parent: { deletedAt: null, tenantId: scope.tenantId }"); expect(source).toContain("child: { deletedAt: null, tenantId: scope.tenantId }"); expect(source).not.toContain("findUnique({"); expect(source).not.toContain("where: { id },"); }); });