Merge remote-tracking branch 'origin/main' into claude/fix-198

# Conflicts:
#	CHANGELOG.md
This commit is contained in:
Frederic Jung 2026-10-30 19:48:22 +01:00
commit 816de9b5ec
No known key found for this signature in database
9 changed files with 68 additions and 6 deletions

View file

@ -1344,3 +1344,40 @@ test('link redundancy trials distinguish a bridge, a full fallback and a healthy
ev("window.saveRef=S;window.liveRef=R;window.originalCompute=compute;compute=()=>{throw Error('trial failed')}");assert.throws(()=>ev("linkTrial('main')"),/trial failed/);ev('compute=originalCompute');assert.equal(ev('S===saveRef&&R===liveRef'),true,'even a failed trial restores the live state');
assert.deepEqual(errors,[]);
});
test('#219 splitting a one-member PNI across both sites splits it when the augment lands', () => {
const { ev, errors } = load();
ev("ACT.start({});S.cash=1e8;UI.speed=0;for(const g of GOALS)S.done[g.id]=0;Object.assign(S.pops.fra,{site2:true,routers:4});S.pni.push({id:'x',net:'nfx',city:'fra',tier:1,ready:0});compute()");
const cash = ev('S.cash');
ev("ACT.siteSet({k:'p',id:'x',s:'ab'})");
assert.equal(ev('S.pni[0].up.n'), 2, 'second member ordered');
assert.equal(ev('S.pni[0].up.site'), 'ab', 'remembers the split');
assert.ok(ev('S.cash') < cash, 'paid once');
// clicking again while it is on order buys nothing more
const paid = ev('S.cash');
ev("ACT.siteSet({k:'p',id:'x',s:'ab'})");
assert.equal(ev('S.cash'), paid);
// the panel shows Both as chosen meanwhile
ev("selectCity('fra');ACT.tab({t:'peer'})");
assert.equal(ev(`[...document.querySelectorAll('[data-act=siteSet].pink')].filter(b=>JSON.parse(b.dataset.args).k==='p').map(b=>JSON.parse(b.dataset.args).s).join()`), 'ab', 'Both is shown as chosen');
assert.equal(ev("(()=>{const m=siteCtl('p','x','fra',S.pni[0].up&&S.pni[0].up.site==='ab'?'ab':S.pni[0].site).match(/<button[^>]*class=\"[^\"]*pink[^>]*>(.*?)<\\/button>/);return m&&m[1].includes(tr('common.site'))?'':m&&m[1]})()").startsWith('Both'), true);
// survives a save and load
ev('S=migrate(JSON.parse(JSON.stringify(S)));compute()');
assert.equal(ev('S.pni[0].up.site'), 'ab');
ev('S.day=S.pni[0].up.ready-1;dayTick()');
assert.equal(ev('S.pni[0].n'), 2);
assert.equal(ev('S.pni[0].site'), 'ab', 'one member in each building');
assert.equal(ev("liveN('fra','ab',2)"), 2);
assert.deepEqual(errors, []);
});
test('#219 choosing one site again while the augment is on order keeps the LAG in that site', () => {
const { ev, errors } = load();
ev("ACT.start({});S.cash=1e8;UI.speed=0;for(const g of GOALS)S.done[g.id]=0;Object.assign(S.pops.fra,{site2:true,routers:4});S.pni.push({id:'x',net:'nfx',city:'fra',tier:1,ready:0});compute()");
ev("ACT.siteSet({k:'p',id:'x',s:'ab'})");
ev("ACT.siteSet({k:'p',id:'x',s:'b'})");
assert.equal(ev('S.pni[0].up.site'), undefined);
ev('S.day=S.pni[0].up.ready-1;dayTick()');
assert.equal(ev('S.pni[0].site'), 'b');
assert.deepEqual(errors, []);
});

View file

@ -125,3 +125,22 @@ test('now and then a route is sold out of a wave size, for a while, and asking a
assert.match(ev("document.getElementById('toasts').textContent"), /No 400G capacity on this route/);
assert.deepEqual(errors, []);
});
test('#201 a sold-out wave size cannot be reached by upgrading a smaller wave on the route', () => {
const { ev, errors } = load();
setup(ev);
ev("ACT.buildPop({city:'ams'});S.pops.ams.rgen=3;S.cash=1e9");
const day = ev("(()=>{for(let d=90;d<20000;d++){S.day=d;if(soldOut('fra','ams',2,null)&&!soldOut('fra','ams',1,null))return d;}return -1;})()");
assert.ok(day > 0, 'it happens');
ev(`S.day=${day};S.links.push({id:'upw',a:'fra',b:'ams',kind:'wave',tier:1,km:400,sub:false,cable:null,mo:1,mult:1,trench:'upw',cut:0,day:0})`);
const cash = ev('S.cash');
ev("ACT.upLink({id:'upw',tier:2})");
assert.equal(ev("S.links.find(l=>l.id==='upw').tier"), 1, 'still the old size');
assert.equal(ev('S.cash'), cash, 'nothing charged');
assert.match(ev("document.getElementById('toasts').textContent"), /No 400G capacity on this route/);
// the link panel's button for that size is disabled and says why
ev("UI.sel={type:'link',id:'upw'};renderPanel()");
const b = ev(`(()=>{const b=[...document.querySelectorAll('[data-act=upLink]')].find(x=>JSON.parse(x.dataset.args).tier===2);return b?b.disabled+':'+b.textContent:''})()`);
assert.match(b, /^true:.*sold out/i);
assert.deepEqual(errors, []);
});