web/website/tests/shared-chrome.test.mjs

15 lines
1.3 KiB
JavaScript

import test from 'node:test';import assert from 'node:assert/strict';import {readFileSync} from 'node:fs';
import worker from '../dist/server/index.js';
import {RELEASE_VERSION} from '../scripts/release-branding.mjs';
import {pagesForChanges} from '../scripts/menu-updates.mjs';
test('Native shared artifacts exactly match the public Worker responses, including compiled navigation and metadata',async()=>{
for(const name of ['portal-navigation.js','portal-navigation.css','release.json','menu-new-items.json','rates-and-charges.html','bank-rates.css']){
const response=await worker.fetch(new Request('https://www.dunerealms.com/'+name),{},{});
assert.equal(response.status,200,name);assert.equal(await response.text(),readFileSync(new URL('../dist/shared-chrome/'+name,import.meta.url),'utf8'),name);
}
const release=JSON.parse(readFileSync(new URL('../dist/shared-chrome/release.json',import.meta.url),'utf8'));assert.equal(release.version,RELEASE_VERSION);
});
test('A shared header change marks affected menu destinations as updates',()=>{
const pages=pagesForChanges(['website/web/portal-navigation.css']);
for(const url of ['https://www.dunerealms.com/','https://cp.dunerealms.com/','https://forums.dunerealms.com/','https://support.dunerealms.com/','https://clans.dunerealms.com/'])assert(pages.includes(url),url);
});