web/website/tests/kit-routine-equipment.test.mjs
unimatrixgit 99b4c89ee9
All checks were successful
DuneRealms Kit Delivery CI / kits (push) Successful in 58s
Add receipt-bound native kit delivery and Paper metadata verification
2026-11-16 02:45:25 +01:00

13 lines
1 KiB
JavaScript

import test from 'node:test';import assert from 'node:assert/strict';
import {kitRoutineWithEquipment} from '../scripts/install-kit-routines.mjs';
const routine="CREATE PROCEDURE dune_kit_catalogue() READS SQL DATA BEGIN SELECT b.lore_json AS kit_lore_json FROM website.site_kit_blueprints b JOIN website.site_accounts a ON a.id=b.owner_user_id WHERE b.active=1 FOR SHARE; END";
test('kit routine update adds revision-bound cosmetics without changing authority filters or locks',()=>{
const after=kitRoutineWithEquipment(routine);
assert.ok(after.includes('ke.blueprint_version=b.version'));
assert.ok(after.includes('WHERE b.active=1 FOR SHARE; END'));
assert.equal(kitRoutineWithEquipment(after),after);
assert.ok(!after.includes('UPDATE '));assert.ok(!after.includes('INSERT '));
});
test('unexpected native routine definitions are rejected before replacement',()=>{
for(const source of ['',routine.replace('READS SQL DATA','MODIFIES SQL DATA'),routine.replace('b.lore_json','x.lore_json'),routine+routine])assert.throws(()=>kitRoutineWithEquipment(source));
});