Files
2026-11-14 09:56:45 +00:00

54 lines
2.1 KiB
TypeScript

// What the generated tenant-isolation suite (test/isolation.test.ts) needs of this module, from this
// folder: one fixture per tenant-scoped procedure, each called as a member of one organization with
// another's slugs, which the resolver must refuse before the CRM service is reached.
//
// The module keeps no row of its own, so it seeds nothing: what a fixture names is the other tenant's
// project, and an id is any well-formed one (the service is never asked). The suite reads this file by
// its place whether or not the module is on, and checks only the procedures the app registers, so
// while the module is off (the template's default) it brings no fixture; `procedures.test.ts` runs the
// same fixtures against the module on its own, on or off.
import type { TransportCaller } from "@conusai-kit/core"
import type { IsolationFixture, IsolationTenant } from "@conusai-kit/testing"
import { businessModulesOn } from "../../index.js"
const SOMEWHERE = "00000000-0000-4000-8000-000000000001"
const inProjectOf = (t: IsolationTenant) => ({ org: t.orgSlug, workspace: t.workspaceSlug, project: t.projectSlug })
export const crmIsolationFixtures: Record<string, IsolationFixture> = {
"crm.party.list": { input: (t) => inProjectOf(t) },
"crm.party.get": { input: (t) => ({ ...inProjectOf(t), partyId: SOMEWHERE }) },
"crm.party.create": {
input: (t) => ({
...inProjectOf(t),
kind: "organization",
displayName: "Intruder",
country: "LT",
requestId: SOMEWHERE,
}),
},
"crm.contact.add": {
input: (t) => ({
...inProjectOf(t),
partyId: SOMEWHERE,
kind: "email",
value: "intruder@example.test",
purposes: [],
isPrimary: false,
requestId: SOMEWHERE,
}),
},
}
/** The shape the suite reads (`modules/notes/__tests__/isolation.ts` names it), so no other module is imported. */
export const isolation: {
seed(
call: TransportCaller,
inProject: { org: string; workspace: string; project: string },
): Promise<Record<string, string>>
fixtures: Record<string, IsolationFixture>
} = {
seed: async () => ({}),
fixtures: businessModulesOn.includes("crm") ? crmIsolationFixtures : {},
}