Build the agent-native compute CRM platform
CI / verify (push) Successful in 3m6s

This commit is contained in:
2026-08-13 01:39:01 -07:00
parent bfd2f8d95a
commit 853bde2265
160 changed files with 61812 additions and 483 deletions
+48
View File
@@ -0,0 +1,48 @@
import { strict as assert } from 'node:assert';
import { describe, it } from 'node:test';
import { permissionGranted, resolvePermissionGrants } from '../src/permissions';
describe('role permissions', () => {
it('keeps deal writes on the side where the person is a member', () => {
const grants = resolvePermissionGrants({
isPlatformAdmin: false,
teams: [{ team: 'demand', role: 'member' }],
});
assert.equal(permissionGranted(grants, 'deal:write', 'demand'), true);
assert.equal(permissionGranted(grants, 'deal:write', 'supply'), false);
assert.equal(permissionGranted(grants, 'commitment:write', 'demand'), false);
});
it('allows supply leads to commit capacity without letting them sign contracts', () => {
const grants = resolvePermissionGrants({
isPlatformAdmin: false,
teams: [{ team: 'supply', role: 'lead' }],
});
assert.equal(permissionGranted(grants, 'commitment:write', 'supply'), true);
assert.equal(permissionGranted(grants, 'contract:sign', 'supply'), false);
});
it('keeps signing and bulk import at team-admin level', () => {
const grants = resolvePermissionGrants({
isPlatformAdmin: false,
teams: [{ team: 'demand', role: 'admin' }],
});
assert.equal(permissionGranted(grants, 'contract:sign', 'demand'), true);
assert.equal(permissionGranted(grants, 'contract:sign', 'supply'), false);
assert.equal(permissionGranted(grants, 'data:import', 'demand'), true);
assert.equal(permissionGranted(grants, 'data:import', 'research'), false);
assert.equal(permissionGranted(grants, 'settings:admin'), false);
});
it('gives platform admins global grants without synthetic team memberships', () => {
const grants = resolvePermissionGrants({ isPlatformAdmin: true, teams: [] });
assert.equal(permissionGranted(grants, 'deal:write', 'demand'), true);
assert.equal(permissionGranted(grants, 'commitment:write', 'supply'), true);
assert.equal(permissionGranted(grants, 'data:import', 'research'), true);
assert.equal(permissionGranted(grants, 'settings:admin'), true);
});
});