web/website/tests/dunechest-cookbook.test.mjs
unimatrixgit a4e2fc64eb
All checks were successful
DuneRealms Web CI / web (push) Successful in 3m21s
Add the Ixian Powercore recipe and current device names to the Cookbook
2026-11-30 19:49:58 +01:00

33 lines
3.2 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import {readFileSync} from 'node:fs';
import {createHash} from 'node:crypto';
import {recipeCatalogue,recipeIcons} from '../scripts/recipe-catalogue.mjs';
test('DuneChest cookbook preserves shaped gaps, exact custom upgrade ingredients and all seven outputs',()=>{
const all=recipeCatalogue(),recipes=all.filter(r=>r.id.startsWith('dunechest_'));
assert.equal(recipes.length,7);assert.equal(new Set(recipes.map(r=>r.output.id)).size,7);
const by=id=>recipes.find(r=>r.id==='dunechest_'+id);
const wrench=by('wrench');assert.deepEqual(wrench.grid.map(i=>i?.material??null),['iron_ingot',null,'iron_ingot',null,'iron_ingot',null,null,'stick',null]);assert.equal(wrench.inputs.length,4);
for(const [tier,previous] of [[2,1],[3,2]]){
const upgrade=by('speed_hopper_'+tier),core=upgrade.grid[4];assert.equal(core.id,'dunechest_speed_hopper_'+previous);assert.equal(core.custom,true);assert.ok(all.some(r=>r.output.id===core.id));
}
assert.equal(by('ender_chest').inputs.filter(i=>i.material==='obsidian').length,7);
for(const r of recipes.filter(r=>r.shaped)){assert.equal(r.grid.length,9);assert.equal(r.amount,1);assert.equal(r.shaped,true);assert.match(r.notes,/all six servers, including Lobby/);assert.equal(r.output.quality,undefined);assert.equal(r.output.equipmentMark,undefined);}
const icons=new Map(recipeIcons(recipes));assert.equal(icons.size,6);for(const bytes of icons.values())assert.equal(bytes.subarray(0,8).toString('hex'),'89504e470d0a1a0a');
const provenance=JSON.parse(readFileSync(new URL('../data/cookbook/dunechest-source.json',import.meta.url)));assert.equal(provenance.sourceCommit,'56346a273d1b014fa256d26d34b4a4e33cc1d6b5');assert.equal(Object.keys(provenance.files).length,2);
for(const [path,source] of Object.entries(provenance.icons))assert.equal(createHash('sha256').update(readFileSync(new URL('../data/cookbook/'+path,import.meta.url))).digest('hex'),source.sha256);
});
// This recipe must remain shapeless; the existing six shaped recipes retain their layouts.
test('Ixian names and the beamless powercore recipe use stable custom identities',()=>{
const recipes=recipeCatalogue(),by=id=>recipes.find(r=>r.id==='dunechest_'+id);
for(const tier of [1,2,3])assert.equal(by('speed_hopper_'+tier).output.name,'Ixian sorting devices MK '+tier);
assert.equal(by('auto_crafter').output.name,'Ixian Replicator MK XIV');
const beacon=by('dune_beacon');assert.equal(beacon.output.name,'Ixian Powercore MK XIV');assert.equal(beacon.output.id,'dunechest_dune_beacon');
assert.deepEqual(beacon.inputs.map(i=>[i.material,i.custom]),[['beacon',false],['ender_eye',false]]);
assert.equal(beacon.shaped,false);assert.equal(beacon.grid.length,9);assert.equal(beacon.grid.filter(Boolean).length,2);assert.match(beacon.notes,/all six servers, including Lobby/);
assert.equal(beacon.output.equipmentMark,undefined);assert.equal(beacon.output.quality,undefined);
const provenance=JSON.parse(readFileSync(new URL('../data/cookbook/dunechest-source.json',import.meta.url)));
assert.equal(createHash('sha256').update(readFileSync(new URL('../data/cookbook/'+provenance.beacon.icon.path,import.meta.url))).digest('hex'),provenance.beacon.icon.sha256);
});