import test from 'node:test'; import assert from 'node:assert/strict'; import {readFile} from 'node:fs/promises'; import {LocalD1} from './d1-adapter.mjs'; import {createPanel} from '../control-panel/server.mjs'; import {NATIVE_SERVICES,nativeServiceAccess} from '../control-panel/public/cp-v2/cp-v2-native-services.mjs'; test('actual CP router serves the dedicated clan page and assets without requiring the full CP shell',async()=>{ const db=new LocalD1(),app=createPanel(db); try{ for(const [file,mime]of [['clan-center.html','text/html'],['clan-center-entry.mjs','javascript'],['clan-center.css','text/css']]){ const response=await app(new Request('https://cp.dunerealms.com/'+file));assert.equal(response.status,200,file);assert.ok(response.headers.get('content-type').includes(mime)); if(file.endsWith('.html')){const html=await response.text();assert.match(html,/id="dashboard"/);assert.doesNotMatch(html,/v2\/v2\.js|src="\/panel\.js"|id="portals"/);} } }finally{db.close();} }); test('clan portal and User navigation target the isolated functional clan workspace',async()=>{ const spec=NATIVE_SERVICES.clans;assert.equal(spec.url,'https://cp.dunerealms.com/clan-center.html#clans');assert.equal(spec.selfResize,true); assert.equal(nativeServiceAccess({permissions:['web.menu.game']},spec),true);assert.equal(nativeServiceAccess({permissions:[]},spec),false); const html=await readFile(new URL('../ops/clan-center-index.html',import.meta.url),'utf8');assert.match(html,/src="https:\/\/cp\.dunerealms\.com\/clan-center\.html#clans"/);assert.doesNotMatch(html,/\?embedded=1#clans/); });