forked from unimatrix/web
Validate the restored guide and cookbook in the full site build
This commit is contained in:
parent
5bf16d4b58
commit
7a550821de
4 changed files with 12 additions and 7 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {createReadStream,statSync,readdirSync,readFileSync} from 'node:fs';
|
||||
import {recipeCatalogue,recipeIcons} from '../scripts/recipe-catalogue.mjs';
|
||||
import {MAIN_MENU} from '../scripts/main-menu.mjs';
|
||||
import {fileURLToPath} from 'node:url';
|
||||
import {scanAssetChunk,ASSET_ENTRY} from './build-artifact-scan.mjs';
|
||||
|
|
@ -12,7 +13,8 @@ test('built Worker embeds complete public assets and runtime without loading the
|
|||
const entrySource=readFileSync(path,'utf8'),assetFiles=[...entrySource.matchAll(/import DATA\d+ from ["']\.\/(assets-[a-f0-9]+\.mjs)["']/g)].map(m=>fileURLToPath(new URL('../dist/server/'+m[1],import.meta.url)));async function* builtStream(){for(const file of assetFiles.length?[...assetFiles,path]:[path])yield* createReadStream(file,{highWaterMark:65536});}
|
||||
let count=0,prefix='',suffix='',carry='',hasBuildStamp=false;
|
||||
const nativeOnly=new Set(['organisation-deed-keys-v1.png','organisation-deeds-clan-tiers-v1.png','organisation-deeds-company-tiers-v1.png','organisation-deeds-protected-v1.png'].map(name=>'/assets/'+name));
|
||||
const required=new Set(['/index.html','/kits.html','/manual-data.json','/assets/item-0.webp','/kits.js','/kits.css']);
|
||||
const generatedRecipes=['/recipe-catalogue.json',...recipeIcons(recipeCatalogue()).map(([url])=>url)];
|
||||
const required=new Set([...generatedRecipes,'/lets-play.html','/imperial-recipe-book.html','/index.html','/kits.html','/manual-data.json','/assets/item-0.webp','/kits.js','/kits.css']);
|
||||
const found=new Set();
|
||||
const entry=ASSET_ENTRY;
|
||||
for await(const chunk of builtStream()){
|
||||
|
|
@ -30,7 +32,7 @@ test('built Worker embeds complete public assets and runtime without loading the
|
|||
const web=fileURLToPath(new URL('../web/',import.meta.url));
|
||||
const expected=(dir)=>readdirSync(dir,{withFileTypes:true}).reduce((n,entry)=>{const name=dir+'/'+entry.name;if(entry.isDirectory())return n+expected(name);return n+(!/^assets\/seals\/[^/]+-provenance\.txt$/.test(name.slice(web.length+1))&&!nativeOnly.has('/'+name.slice(web.length+1))?1:0);},0);
|
||||
for(const asset of nativeOnly){assert.ok(statSync(web+asset).size>0);assert.ok(readFileSync(new URL('../control-panel/server.mjs',import.meta.url),'utf8').includes(asset.split('/').pop()),'CP artwork route must retain '+asset);}
|
||||
assert.equal(count,expected(web)+Number(hasBuildStamp),'Unexpected number of embedded public assets');
|
||||
assert.equal(count,expected(web)+generatedRecipes.length+Number(hasBuildStamp),'Unexpected number of embedded public assets');
|
||||
if(/^[0-9a-f]{40}$/.test(process.env.GITHUB_SHA||''))assert.ok(hasBuildStamp,'CI bundle must identify the exact publication');
|
||||
assert.deepEqual(found,required,'Essential pages or assets missing from built Worker');
|
||||
// A bounded rolling window extracts the navigation entry even when it crosses chunks.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@ import test from 'node:test';import assert from 'node:assert/strict';import {rea
|
|||
import {applyRealmPageDesign,REALM_PAGE_DESIGNS} from '../scripts/realm-page-design.mjs';
|
||||
const web=new URL('../web/',import.meta.url);
|
||||
test('every public document opts into the common design and every legacy page owns a labelled illustrated banner',()=>{
|
||||
const files=readdirSync(web).filter(f=>f.endsWith('.html'));assert.equal(files.length,38);
|
||||
const files=readdirSync(web).filter(f=>f.endsWith('.html'));assert.equal(files.length,40);
|
||||
for(const restored of ['lets-play.html','imperial-recipe-book.html'])assert(files.includes(restored),restored);
|
||||
for(const file of files){const html=readFileSync(new URL(file,web),'utf8');assert.match(html,/data-realm-design/,file);assert.match(html,/realm-design\.css/,file);assert.match(html,/realm-design\.js/,file);if(REALM_PAGE_DESIGNS[file]){assert.match(html,/data-realm-layout="2"/,file);assert.equal((html.match(/class="dr-page-banner"/g)||[]).length,1,file);assert(html.indexOf('class="dr-page-banner"')<html.indexOf('<main'),file+' banner must precede nested content grids');}}
|
||||
for(const d of Object.values(REALM_PAGE_DESIGNS))assert(existsSync(new URL('assets/'+d.icon,web)),d.icon);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@
|
|||
<meta name="description" content="Browse DuneRealms crafting, furnace and smoker recipes in the Imperial Recipe Book.">
|
||||
<link rel="stylesheet" href="/styles.css"><link rel="stylesheet" href="/imperial-recipe-book.css?v=8">
|
||||
<script type="module" src="/imperial-recipe-book.js?v=8"></script>
|
||||
<link rel="stylesheet" href="/portal-navigation.css"><script src="/portal-navigation.js" defer></script></head>
|
||||
<link rel="stylesheet" href="/portal-navigation.css"><script src="/portal-navigation.js" defer></script><link rel="stylesheet" data-realm-design href="/realm-design.css?v=every-page-1"><script src="/realm-design.js?v=every-page-1" defer></script>
|
||||
</head>
|
||||
<body><header class="dune-site-header"></header>
|
||||
<main id="main" class="realm-handbook">
|
||||
<p class="recipe-manual-link"><a href="/lets-play.html">Let’s Play Manual →</a></p>
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
<meta name="description" content="Your first session in DuneRealms, from joining the Guild lobby to choosing a House and beginning your first quest.">
|
||||
<link rel="stylesheet" href="/styles.css"><link rel="stylesheet" href="/imperial-recipe-book.css?v=8">
|
||||
<link rel="stylesheet" href="/portal-navigation.css"><script src="/portal-navigation.js" defer></script>
|
||||
<link rel="stylesheet" data-realm-design href="/realm-design.css?v=every-page-1"><script src="/realm-design.js?v=every-page-1" defer></script>
|
||||
</head>
|
||||
<body><header class="dune-site-header"></header>
|
||||
<main id="main" class="realm-handbook player-manual">
|
||||
|
|
@ -16,7 +17,7 @@
|
|||
<li><a href="#connect">Connect</a></li>
|
||||
<li><a href="#house">Choose a House</a></li>
|
||||
<li><a href="#travel">Travel</a></li>
|
||||
<li><a href="#arrakis">Survive Arrakis</a></li>
|
||||
<li><a href="#arrakis">Survive Arrakduin</a></li>
|
||||
<li><a href="#exchange">Trade</a></li>
|
||||
</ol>
|
||||
<a class="guide-book-link" href="/imperial-recipe-book.html"><img src="/assets/nav-manual-v2.webp" width="44" height="44" alt="">Imperial Recipe Book</a>
|
||||
|
|
@ -43,7 +44,7 @@
|
|||
</section>
|
||||
<section id="arrakis" class="guide-chapter">
|
||||
<div class="guide-chapter-art"><img src="/assets/arrakis.webp" alt="" loading="lazy"></div>
|
||||
<div class="guide-chapter-copy"><h2>Prepare for Arrakis</h2>
|
||||
<div class="guide-chapter-copy"><h2>Prepare for Arrakduin</h2>
|
||||
<p>Bring water and supplies before leaving the settlement. The recipe book shows what you can make, which ingredients you need and what each workstation produces.</p>
|
||||
<a class="guide-action" href="/imperial-recipe-book.html">Open the Imperial Recipe Book <span aria-hidden="true">→</span></a>
|
||||
</div>
|
||||
|
|
@ -51,7 +52,7 @@
|
|||
<section id="exchange" class="guide-chapter">
|
||||
<div class="guide-chapter-art"><img src="/assets/nav-exchange-full-v2.webp" alt="" loading="lazy"></div>
|
||||
<div class="guide-chapter-copy"><h2>Sell spice and trade</h2>
|
||||
<p>On Arrakis, <code>/spice</code> shows Guild and available Smuggler sales. The Smuggler route requires its quest. To sell eligible spice through the Guild in one go, use <code>/sellall guild</code>.</p>
|
||||
<p>On Arrakduin, <code>/spice</code> shows Guild and available Smuggler sales. The Smuggler route requires its quest. To sell eligible spice through the Guild in one go, use <code>/sellall guild</code>.</p>
|
||||
<p>Use <code>/exchange</code> to browse offers and kits, or <code>/drscoreboard</code> to toggle your personal scoreboard.</p>
|
||||
<a class="guide-action" href="/exchange.html">Browse the Player Exchange <span aria-hidden="true">→</span></a>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff