9 lines
1.9 KiB
JavaScript
9 lines
1.9 KiB
JavaScript
import test from 'node:test';import assert from 'node:assert/strict';import {STAFF_DEPARTMENTS,shadowStaffAccess,canReviewPromotion,validateStaffPosition} from '../node/staff-bureau-policy.mjs';
|
|
test('four fixed staff departments',()=>assert.equal(Object.keys(STAFF_DEPARTMENTS).length,4));
|
|
test('department head has scoped rights, not other departments',()=>{const a=shadowStaffAccess({department:'community_moderation',level:'head'});assert.ok(a.nodes.includes('web.bans.manage'));assert.ok(!a.nodes.includes('web.servers.power'));assert.ok(!a.nodes.includes('web.bank.staff.manage'));});
|
|
test('trainee cannot issue bans',()=>{const a=shadowStaffAccess({department:'community_moderation',level:'trainee'});assert.ok(!a.nodes.includes('web.bans.manage'));});
|
|
test('temporary grants expire or are revoked',()=>{const p={department:'operations',level:'staff'};const a=shadowStaffAccess(p,[{node:'web.servers.power',expiresAt:2000},{node:'web.bans.manage',expiresAt:9999,revokedAt:100}],3000);assert.ok(!a.nodes.includes('web.servers.power'));assert.ok(!a.nodes.includes('web.bans.manage'));});
|
|
test('suspended staff has no rights',()=>assert.deepEqual(shadowStaffAccess({department:'operations',level:'head',status:'suspended'}).nodes,[]));
|
|
test('head can approve only own department and not self',()=>{const head={accountId:'1',department:'operations',level:'head'};assert.ok(canReviewPromotion(head,{accountId:'2',department:'operations',level:'staff'},'senior'));assert.ok(!canReviewPromotion(head,{accountId:'3',department:'development',level:'staff'},'senior'));assert.ok(!canReviewPromotion(head,{accountId:'1',department:'operations',level:'staff'},'senior'));});
|
|
test('director cannot appoint owner',()=>assert.ok(!canReviewPromotion({accountId:'1',level:'director',department:null},{accountId:'2',level:'director',department:null},'owner')));
|
|
test('unknown department fails closed',()=>assert.equal(validateStaffPosition({department:'unknown',level:'head'}),false));
|

Staff