// @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)), "EntityViewsApi.ts"), "utf8"); describe("EntityViewsApi tenant scope", () => { test("validates entity views against the current tenant/user scope", () => { expect(source).toContain("validateEntityView({ entityId: entity.id, isDefault, name, title, order: null, tenantId, userId })"); expect(source).toContain("tenantId: item.tenantId, userId: item.userId"); expect(source).toContain("const views = await getEntityViews(entityId, { tenantId, userId })"); }); test("loads entity views by id through the current entity and tenant scope", () => { expect(source).toContain("getEntityView(id, { entityId: entity.id, tenantId })"); }); });