forked from unimatrix/web
23 lines
2.9 KiB
JavaScript
23 lines
2.9 KiB
JavaScript
import test from 'node:test';import assert from 'node:assert/strict';
|
|
import {projectPublicOrganisation} from '../node/organisation-public-roster.mjs';
|
|
import {OFFICIAL_ACCOUNT} from '../node/official-account.mjs';
|
|
const row=(username,scope_type,scope_key,role_key,extra={})=>({username,display_name:username,bio:'A public biography',scope_type,scope_key,role_key,...extra});
|
|
|
|
test('Official identity has a separate verification card and never adds a fifth executive',()=>{
|
|
const official={id:OFFICIAL_ACCOUNT.id,username:'dunerealms',role:'official_account'};
|
|
const data=projectPublicOrganisation([],[],[official,{...official,id:'impostor'}]);assert.equal(data.officialAccounts.length,1);assert.equal(data.officialAccounts[0].profile,'/people/dunerealms');assert.equal(data.staff.length,0);assert.equal(data.executives.length,0);
|
|
});
|
|
test('One public biography card per person retains multiple functions and executive ordering',()=>{
|
|
const data=projectPublicOrganisation([row('mr_blueray','branch','customer_support','branch_lead'),row('mr_blueray','organisation','dunerealms','executive'),row('unimatrix999','organisation','dunerealms','owner_ceo'),row('mr_blueray','branch','customer_support','branch_lead')]);
|
|
assert.equal(data.staff.length,2);assert.equal(data.staff[0].username,'unimatrix999');assert.equal(data.staff[1].functions.length,2);assert.equal(data.staff[1].title,'Chief Community Officer');assert.equal(data.organisation[0].branches[0].leads[0].username,'mr_blueray');assert.deepEqual(data.organisation[1].heads,[]);
|
|
});
|
|
test('Service and invalid staff scopes never appear; private database fields are not projected',()=>{
|
|
const data=projectPublicOrganisation([row('dev','branch','engineering','officer',{game_link_exempt:1}),row('hidden','branch','invented','officer'),row('staff','branch','news_media','officer',{email:'private@example.invalid',user_id:'private-id'})]);
|
|
assert.equal(data.staff.length,1);assert(!JSON.stringify(data).includes('private@example'));assert(!JSON.stringify(data).includes('private-id'));
|
|
});
|
|
test('Only verified Bedrock source identity strips the display prefix; canonical profile link is preserved',()=>{
|
|
const verified=row('bedrock_test','branch','news_media','officer',{source_name:'.test',source_uuid:'uuid',minecraft_uuid:'uuid'});assert.equal(projectPublicOrganisation([verified]).staff[0].displayName,'test');assert.equal(projectPublicOrganisation([verified]).staff[0].profile,'/people/bedrock_test');assert.equal(projectPublicOrganisation([{...verified,minecraft_uuid:'other'}]).staff[0].displayName,'bedrock_test');
|
|
});
|
|
test('Order membership is a separate gallery and never implies a staff role',()=>{
|
|
const data=projectPublicOrganisation([],[{username:'honoured',display_name:'Honoured',citation:'For service'},{username:'picard',slug:'picard',citation:'In remembrance'}]);assert.equal(data.staff.length,0);assert.equal(data.order.length,2);assert.equal(data.order[1].profile,'/memorial/picard');
|
|
});
|

Staff