forked from unimatrix/web
23 lines
1.6 KiB
JavaScript
23 lines
1.6 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import {organisationPersonalSeal,organisationFunctionSeals,FUNCTION_SEALS} from '../node/organisation-seals.mjs';
|
|
import {projectPublicOrganisation} from '../node/organisation-public-roster.mjs';
|
|
test('Personal seals follow active staff status and executive titles cannot follow a demotion',()=>{
|
|
assert.equal(organisationPersonalSeal('unimatrix999',['org_owner_ceo']),'/assets/seals/personal-unimatrix999-ceo-v1-150.png');
|
|
assert.equal(organisationPersonalSeal('grmacken',['org_officer']),null);
|
|
assert.equal(organisationPersonalSeal('am_mk',['user']),null);
|
|
assert.match(organisationPersonalSeal('bedrock_s73ffupk7hx',['org_officer']),/personal-staff-s73ffupk7hx/);
|
|
assert.equal(organisationPersonalSeal('dunerealms',['org_owner_ceo']),null);
|
|
});
|
|
test('Function seals use current scopes once, reject unrelated memberships, and cover the full organigram',()=>{
|
|
assert.equal(Object.keys(FUNCTION_SEALS).length,11);
|
|
const scope={scopeType:'branch',scopeKey:'news_media'};
|
|
assert.deepEqual(organisationFunctionSeals([scope,scope,{scopeType:'clan',scopeKey:'news_media'}]),[FUNCTION_SEALS.news_media]);
|
|
assert.deepEqual(organisationFunctionSeals([]),[]);
|
|
});
|
|
test('Public staff cards carry personal and active function seals without exposing account IDs',()=>{
|
|
const data=projectPublicOrganisation([{username:'am_mk',scope_type:'branch',scope_key:'customer_support',role_key:'officer',id:'secret'}]);
|
|
assert.match(data.staff[0].personalSeal.file,/personal-staff-am_mk/);
|
|
assert.equal(data.staff[0].functionSeals[0].label,'Customer Support');
|
|
assert(!JSON.stringify(data).includes('secret'));
|
|
});
|

Staff