Merge remote-tracking branch 'origin/main' into keyboard-shortcuts

This commit is contained in:
Charlie Allom 2026-11-03 10:48:01 +00:00
commit c5c5aac970
No known key found for this signature in database
14 changed files with 92 additions and 2 deletions

View file

@ -225,7 +225,7 @@ test('a dry run prices every command that has a price, and changes nothing', ()
crews: { id: df }, addCh: { id: df, o: 'zr4' }, addPair: { id: df }, upSys: { id: df }, regen: { id: df, d: 1 }, buySpare: { o: 'zr4' }, sellSpare: { o: 'zr4' },
setChCount: { id: df, o: 'zr4', n: 2 }, repayLoan: { id: 'none' }, buildScrub: { city: 'ams', tier: 1 }, scrubUp: { city: 'fra', tier: 1 },
fixInc: { id: 'none' }, confGo: { key: T('catalog', { name: 'conferences' })[0].key }, confSponsor: { key: T('catalog', { name: 'conferences' })[0].key },
opsHire: { id: ev('Object.keys(INTERNS)[0]') }, opsNewPop: { city: 'nyc' }, pniAll: { net: 'cog', tier: 1 }, seatBuy: { n: 2 }, layShip: { id: df },
opsHire: { id: ev('Object.keys(INTERNS)[0]') }, opsNewPop: { city: 'nyc' }, pniAll: { net: 'cog', tier: 1 }, seatBuy: { n: 2 }, layShip: { id: df }, seaRush: { id: df },
utilityKit: { city: 'fra' }, utilityCaches: { city: 'fra' }, teDeploy: { script: 'spill at 85%' }, upLinkX: {},
};
const missing = quoted.filter((n) => !sample[n] && T('schema', { section: 'commands' })[n].args.some((a) => a.required));

View file

@ -78,7 +78,9 @@ test('pages: the shipped page and dictionaries, with labels shrunk to ids, still
for (const [lang, word] of [['en', 'Customers'], ['it', 'Clienti'], ['fr', null]]) {
const { ev, errors } = load(lang === 'en' ? { file } : { file, lang, dir });
ev("ACT.start({});S.cash=1e8;ACT.launchBB({city:'fra'});for(let i=0;i<40;i++)dayTick();ACT.leftTab({t:'noc'});renderAll()");
const text = ev("['hud','leftBody','panelBody','modalCard','toasts'].map(i=>document.getElementById(i)?.textContent||'').join(' ')");
// Text node by text node: a raw label sits inside one, while two elements' text run together ("facendo." then
// "proprio ora") only looks like one.
const text = ev("['hud','leftBody','panelBody','modalCard','toasts'].map(i=>{const e=document.getElementById(i);if(!e)return '';const w=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),out=[];while(w.nextNode())out.push(w.currentNode.nodeValue);return out.join(' ');}).join(' ')");
if (word) assert.ok(text.includes(word), `${lang}: ${word}`);
assert.doesNotMatch(text, /\b[a-z_]+\.[a-z0-9_]{6,}\b/, `${lang}: no raw labels`);
assert.equal(ev("tr(FLOOD_WHO[0])"), ev("tr('failures.a_botnet_of_40_000_smart')"), `${lang}: labels kept for saves still translate`);

51
tests/sea-rush.test.js Normal file
View file

@ -0,0 +1,51 @@
// #258: money hurries the survey, permits and factory of your own subsea cable, 30 days a step, but never below what the
// factory needs to make the cable (two months plus a day per 80 km); the lay ships still sail after that.
const test = require('node:test');
const assert = require('node:assert/strict');
const { load } = require('./harness');
const start = "ACT.start({});S.cash=1e9;S.lvl=13;S.day=200;S.nextFail=S.nextEvent=1e8;for(const g of GOALS)S.done[g.id]=0;";
const own = (km, ready) => `S.links=[{id:'own',a:'lag',b:'bde',kind:'df',own:true,sub:true,sys:'roadm',km:${km},ch:[],day:200,ready:${ready},cut:0,mo:1}];`;
test('#258 paying hurries the permits and the factory, 30 days a step, down to what the factory needs', () => {
const { ev, dom, errors } = load();
ev(start + own(6000, 800));
// 6000 km: 60 + 72 days to make it, then 40 days at sea.
assert.equal(ev('prepMin(S.links[0])'), 132);
assert.equal(ev('prepFloor(S.links[0])'), 200 + 132 + 40);
assert.equal(ev('prepSteps(S.links[0])'), 15);
ev("UI.sel={type:'link',id:'own'};renderPanel()");
const panel = () => dom.window.document.querySelector('#panelBody').textContent;
assert.match(panel(), /Hurry the permits and the factory/);
assert.match(panel(), /As fast as money goes/);
assert.match(panel(), /132 days from the order at the soonest/);
const step = ev('prepCost(S.links[0])'), cash = ev('S.cash');
ev("ACT.seaRush({id:'own'})");
assert.equal(ev('S.links[0].ready'), 770, 'one step: 30 days sooner');
assert.equal(cash - ev('S.cash'), step);
ev("ACT.seaRush({id:'own',all:1})");
assert.equal(ev('S.links[0].ready'), 372, 'all the way: the factory floor, then the ships');
assert.equal(cash - ev('S.cash'), 15 * step);
assert.equal(ev('layStart(S.links[0])'), 332);
assert.equal(ev('prepSteps(S.links[0])'), 0, 'no faster than that');
ev("ACT.seaRush({id:'own'})");
assert.equal(cash - ev('S.cash'), 15 * step, 'and nothing more is charged');
// The second lay ship still halves the time at sea on top.
ev("ACT.layShip({id:'own'})");
assert.equal(ev('S.links[0].ready'), 352);
assert.deepEqual(errors, []);
});
test('#258 a short cable is quick; once the ships sail, money buys no more paperwork', () => {
const { ev, errors } = load();
ev(start + own(800, 600));
assert.equal(ev('prepMin(S.links[0])'), 70, 'a short hop: a couple of months');
ev("ACT.seaRush({id:'own',all:1})");
assert.equal(ev('S.links[0].ready'), 200 + 70 + 6);
ev(start + own(6000, 800) + 'S.day=770');
assert.equal(ev('prepSteps(S.links[0])'), 0, 'laying has started');
const cash = ev('S.cash');
ev("ACT.seaRush({id:'own'})");
assert.equal(ev('S.cash'), cash);
assert.deepEqual(errors, []);
});