web/control-panel-inventory/tests/market-bridge.test.mjs
unimatrixgit 9dcd9b084a Integrate shared planetary inventories and account sales with the current site
Merge the supplied inventory/exchange package into the latest DuneRealms source.
Keep community-reward receipts, verified UUID linking, native menus and current
website artwork, Dutch naming and account controls. Wire the inventory/sales
adapters into the real CP session and verified-link schema, with isolated reads
and honest unconfigured states. Preserve lobby/ender separation and Core-owned
atomic exchange checkpoints.

Validation: website build and 56 tests; 12 inventory/market adapter tests;
Core/Essentials and NPC/Terrain/Lobby builds and tests; local browser inspection
of the themed inventory, mannequin and History of sales with fictional fixtures.
Paper 1.21.8 source only: live 1.21.4 binaries and databases are unchanged.
2026-10-27 19:44:22 +01:00

6 lines
848 B
JavaScript

import {test} from 'node:test';import assert from 'node:assert/strict';import {createMarketBridge} from '../market-bridge.mjs';
test('market bridge requires a private bearer before reading listings',async()=>{let calls=0;const h=createMarketBridge({readToken:'x'.repeat(40),pool:{query:async()=>{calls++;return{rows:[{id:'1',seller:'Trader',quantity:2,price:'25.00'}]};}}});
const url='https://cp.dunerealms.com/internal/exchange/listings';assert.equal((await h(new Request(url))).status,401);assert.equal(calls,0);
const r=await h(new Request(url,{headers:{Authorization:'Bearer '+'x'.repeat(40)}}));assert.equal((await r.json()).listings.length,1);assert.equal(calls,1);assert.match(r.headers.get('Cache-Control'),/no-store/);
});
test('market bridge refuses weak configuration',()=>assert.throws(()=>createMarketBridge({readToken:'short'})));