22 lines
2.4 KiB
JavaScript
22 lines
2.4 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import {readFile} from 'node:fs/promises';
|
|
import {POST_IMPORTS} from '../control-panel/public/cp-v2/cp-v2-post-pages.mjs';
|
|
import {nativeServiceURL,nativeServiceAccess,NATIVE_SERVICES} from '../control-panel/public/cp-v2/cp-v2-native-services.mjs';
|
|
|
|
test('Imperial Post imports existing mailbox clients with fixed folders and explicit compose intent',()=>{
|
|
for(const [id,folder]of [['mail-inbox','INBOX'],['mail-sent','Sent'],['mail-drafts','Drafts'],['mail-trash','Trash'],['mail-archive','Archive']]){const page=POST_IMPORTS[id],url=new URL(nativeServiceURL(page.service,page));assert.equal(url.origin,'https://cp.dunerealms.com');assert.equal(url.searchParams.get('service'),'inbox');assert.equal(url.searchParams.get('folder'),folder);assert.equal(url.searchParams.has('compose'),false);}
|
|
assert.equal(new URL(nativeServiceURL('post-mail',POST_IMPORTS['mail-compose'])).searchParams.get('compose'),'1');
|
|
assert.equal(new URL(nativeServiceURL('post-mail',{folder:'../../other-mailbox'})).searchParams.has('folder'),false);
|
|
assert.equal(new URL(nativeServiceURL('post-mail',{initialTab:'clan-inbox'})).hash,'#clan-inbox');
|
|
});
|
|
test('mail settings and external mail retain their own existing services without player eligibility',()=>{
|
|
for(const id of ['post-mail','post-settings','post-webmail']){assert.equal(nativeServiceAccess(null,NATIVE_SERVICES[id]),false);assert.equal(nativeServiceAccess({username:'member',permissions:[]},NATIVE_SERVICES[id]),true);}
|
|
assert.equal(new URL(nativeServiceURL(POST_IMPORTS['mail-settings'].service)).searchParams.get('service'),'mail-settings');
|
|
assert.equal(new URL(nativeServiceURL(POST_IMPORTS.webmail.service)).searchParams.get('service'),'webmail');
|
|
});
|
|
test('the imported mailbox adapter never creates folders or sends messages while navigating',async()=>{
|
|
const source=await readFile(new URL('../control-panel/public/internal-mail.mjs',import.meta.url),'utf8'),adapter=source.slice(source.indexOf('export async function openInternalMailView'));
|
|
assert.match(adapter,/view\.folderNames/);assert.match(adapter,/await loadMessages/);assert.doesNotMatch(adapter,/folders\/create|messages\/send|internal_send/);
|
|
const entry=await readFile(new URL('../control-panel/public/user-service-entry.mjs',import.meta.url),'utf8');assert.match(entry,/modules:\['\.\/webmail\.mjs'\]/);assert.match(entry,/openInternalMailView/);
|
|
});
|

Staff