18 lines
1.4 KiB
JavaScript
18 lines
1.4 KiB
JavaScript
import {readRepositoryMedia} from '../../scripts/managed-media.mjs';
|
|
import {createRequire} from 'node:module';
|
|
import {readFile,access} from 'node:fs/promises';
|
|
import {fileURLToPath} from 'node:url';
|
|
import path from 'node:path';
|
|
import assert from 'node:assert/strict';
|
|
const root=path.resolve(path.dirname(fileURLToPath(import.meta.url)),'../..'),require=createRequire(path.join(root,'apps/waterfall-wiki/package.json')),sharp=require('sharp');
|
|
const layouts=JSON.parse(await readFile(path.join(root,'content/layout-reference/manifest.json'),'utf8'));
|
|
const file=url=>readRepositoryMedia('content/layout-reference/assets/'+url.slice('asset:'.length));
|
|
assert.equal(layouts.length,27);assert.equal(new Set(layouts.map(l=>l.id)).size,27);
|
|
for(const l of layouts){
|
|
const actual=await sharp(await file(l.background)).composite(await Promise.all(l.elements.map(async e=>({input:await file(e.asset),left:e.box[0],top:e.box[1]})))).removeAlpha().raw().toBuffer(),expected=await sharp(await file(l.reference)).removeAlpha().raw().toBuffer();
|
|
assert.ok(actual.equals(expected),l.id);
|
|
for(const e of l.elements)for(const key of ['asset','mask','underlay'])if(e[key])await file(e[key]);
|
|
}
|
|
assert.deepEqual(layouts[0].elements.filter(e=>e.kind==='text').map(e=>e.id),['T01','T02']);
|
|
console.log('27 authoring manifests and 217 classified components verified; all physical composites equal their source crops.');
|