forked from unimatrix/web
24 lines
1.5 KiB
JavaScript
24 lines
1.5 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import {STAFF_TOOL_NODES,staffToolPolicyPlan,enableStaffTools} from '../ops/enable-staff-tools.mjs';
|
|
import {defaultOrganisationPolicies} from '../node/organisation-default-policies.mjs';
|
|
import {GAME_NODE_SET} from '../node/game-ranks.mjs';
|
|
|
|
test('staff-tool plan adds only the three explicit nodes to existing staff policies',()=>{
|
|
const staff={scope_type:'branch',scope_key:'news_media',role_key:'officer',version:7,nodes:['web.posts.edit']};
|
|
const civil={scope_type:'clan',scope_key:'test',role_key:'officer',version:1,nodes:['dune.clans.view']};
|
|
const plan=staffToolPolicyPlan([staff,civil]);
|
|
assert.equal(plan.length,1);assert.equal(plan[0].version,7);
|
|
assert.deepEqual(plan[0].nodes,[...STAFF_TOOL_NODES,'web.posts.edit'].sort());
|
|
assert.deepEqual(staff.nodes,['web.posts.edit']);
|
|
assert.deepEqual(staffToolPolicyPlan([{...staff,nodes:plan[0].nodes}]),[]);
|
|
});
|
|
|
|
test('staff utility defaults are registered for native sync and absent from ordinary membership',()=>{
|
|
for(const node of STAFF_TOOL_NODES)assert(GAME_NODE_SET.has(node));
|
|
for(const p of defaultOrganisationPolicies().filter(p=>p.role!=='branch_lead'))for(const node of STAFF_TOOL_NODES)assert(p.nodes.includes(node));
|
|
});
|
|
|
|
test('the policy operator rejects a caller other than the verified Owner before any database access',async()=>{
|
|
await assert.rejects(enableStaffTools({},{id:'other',username:'unimatrix999'},{apply:true}),/verified Owner/);
|
|
});
|

Staff