test(ci): validate the generated publication marker in the streamed bundle
This commit is contained in:
parent
cf8f9ceef9
commit
21d3a57e43
1 changed files with 5 additions and 4 deletions
|
|
@ -9,7 +9,7 @@ import {scanAssetChunk,ASSET_ENTRY} from './build-artifact-scan.mjs';
|
|||
test('built Worker embeds complete public assets and runtime without loading the bundle',async()=>{
|
||||
const path=fileURLToPath(new URL('../dist/server/index.js',import.meta.url));
|
||||
assert.ok(statSync(path).size>1000,'Build output is missing or empty');
|
||||
let count=0,prefix='',suffix='',carry='';
|
||||
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 found=new Set();
|
||||
|
|
@ -20,16 +20,17 @@ test('built Worker embeds complete public assets and runtime without loading the
|
|||
suffix=(suffix+text).slice(-4096);
|
||||
const combined=carry+text;
|
||||
const scanned=scanAssetChunk(combined),entries=scanned.entries;count+=entries.length;
|
||||
for(const match of entries){const key=JSON.parse(match.slice(0,match.indexOf(':')));assert.ok(!nativeOnly.has(key),'CP-only artwork must stay out of the public bundle');if(required.has(key))found.add(key);}
|
||||
for(const match of entries){const key=JSON.parse(match.slice(0,match.indexOf(':')));assert.ok(!nativeOnly.has(key),'CP-only artwork must stay out of the public bundle');if(required.has(key))found.add(key);if(key==='/ci-build.json')hasBuildStamp=true;}
|
||||
carry=scanned.carry;
|
||||
}
|
||||
const remaining=carry.match(entry)||[];count+=remaining.length;
|
||||
for(const match of remaining){const key=JSON.parse(match.slice(0,match.indexOf(':')));assert.ok(!nativeOnly.has(key),'CP-only artwork must stay out of the public bundle');if(required.has(key))found.add(key);}
|
||||
for(const match of remaining){const key=JSON.parse(match.slice(0,match.indexOf(':')));assert.ok(!nativeOnly.has(key),'CP-only artwork must stay out of the public bundle');if(required.has(key))found.add(key);if(key==='/ci-build.json')hasBuildStamp=true;}
|
||||
assert.match(prefix,/^const ASSET_DATA=\{"\/[^"\n]+":\[/);
|
||||
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),'Unexpected number of embedded public assets');
|
||||
assert.equal(count,expected(web)+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.
|
||||
const marker='"/portal-navigation.js":["text/javascript; charset=utf-8","';
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff