Tests: Mind the Gap, Order and Progress, Fibre to the Basement and Flood Season checks follow the tuned goals

This commit is contained in:
Frederic Jung 2026-10-29 20:22:20 +01:00
parent d309b70e0e
commit 271c562205
No known key found for this signature in database
2 changed files with 12 additions and 6 deletions

View file

@ -299,12 +299,12 @@ test('#34 scenario goal, progress and customer level are always in view', () =>
ev("UI.left='goals';UI.leftOpen=true;UI.sel=null;renderAll()");
const left = () => dom.window.document.getElementById('leftBody').textContent;
assert.match(left(), /Mind the Gap/);
assert.match(left(), /POP in Bogotá/);
assert.match(left(), /Bogotá on your network/);
assert.match(left(), /days left/);
assert.match(left(), /Customer level 1 of 13/);
assert.equal(ev("$('hScn').hidden"), false, 'scenario chip in the top bar');
const f0 = ev('scnProg().f');
ev("S.cash=1e8;ACT.buildPop({city:'bog'});ACT.buildPop({city:'lim'});compute();renderAll()");
ev("S.cash=1e8;UI.via='pccs';openLinkModal('pan','bog');ACT.buildLink({tier:1});closeModal();compute();renderAll()");
assert.ok(ev('scnProg().f') > f0, 'progress moves when a goal step is reached');
assert.match(ev("$('hScnVal').textContent"), /%/);
assert.match(ev("$('hTier').textContent"), /Lv 1/);
@ -361,8 +361,10 @@ test('Flood Season: attacks keep coming, grow, and only count when service held'
for (let i = 0; i < 40; i++) { ev('dayTick()'); if (ev('ddosAll().some(a=>a.start===S.day)')) n++; }
assert.ok(n >= 4, `attacks keep coming (${n} in 40 days)`);
assert.ok(ev('(S.stats.ddosOk||0)+(S.stats.ddosLost||0)') >= 3, 'finished attacks are scored');
// scoring: held only if service stayed at 97%+
ev("S.stats.ddosOk=0;S.stats.ddosOkBig=0;S.stats.ddosLost=0;ddosDone({city:'ams',gbps:1500,worst:0.99});ddosDone({city:'ams',gbps:20,worst:0.5});ddosDone({city:'xyz',gbps:30,worst:1})");
// scoring: held only if service stayed at 97%+, and a terabit one only with scrubbing or Flowspec
ev("S.stats.ddosOk=0;S.stats.ddosOkBig=0;S.stats.ddosLost=0;ddosDone({city:'ams',gbps:1500,vec:'http',worst:0.99})");
assert.equal(ev('S.stats.ddosOk+S.stats.ddosOkBig'), 1, 'held, but no terabit credit without mitigation');
ev("S.scrubs.push({city:'ams',tier:1});S.stats.ddosOk=0;S.stats.ddosOkBig=0;S.stats.ddosLost=0;ddosDone({city:'ams',gbps:1500,worst:0.99});ddosDone({city:'ams',gbps:20,worst:0.5});ddosDone({city:'xyz',gbps:30,worst:1})");
assert.equal(ev('S.stats.ddosOk'), 2);
assert.equal(ev('S.stats.ddosOkBig'), 1);
assert.equal(ev('S.stats.ddosLost'), 1);

View file

@ -563,8 +563,10 @@ test('the Amazon doubles overland fiber, and there is a national-operator scenar
assert.equal(ev('S.scn.id'), 'ixbr');
assert.equal(ev('brIxN()'), 0);
ev("S.cash=1e9;for(const c of ['sao','rio','mao'])ACT.buildPop({city:c});S.ixp.sao=1;S.ixp.mao=1;compute()");
assert.equal(ev('brIxN()'), 2);
assert.equal(ev('brIxN()'), 1, 'a Manaus port on a POP the backbone does not reach does not count');
assert.equal(ev("scnProg().items[1].v"), 1, 'Manaus step done');
ev("S.links.push({id:'y1',a:'sao',b:'mao',km:2700,sub:false,kind:'wave',tier:0,mo:1});compute()");
assert.equal(ev('brIxN()'), 2, 'joined up, it counts');
assert.deepEqual(errors, []);
});
@ -670,8 +672,10 @@ test('Fibre to the Basement: own fibre skips the wholesale cut but pays the levy
assert.equal(ev("SCN.find(s=>s.id==='fttb').ok()"), false, 'still needs cables overseas');
ev("S.links.push({id:'x1',a:'syd',b:'tok',km:8000,sub:true,cable:'sushi',kind:'wave',tier:1,mo:1},{id:'x2',a:'per',b:'sin',km:4000,sub:true,cable:'avo',kind:'wave',tier:1,mo:1},{id:'x3',a:'mel',b:'hba',km:600,sub:true,cable:'ferry',kind:'wave',tier:1,mo:1})");
assert.equal(ev('auExits()'), 2, 'Bass Strait does not count as overseas');
assert.equal(ev("SCN.find(s=>s.id==='fttb').ok()"), false, 'still needs the traffic');
ev('R.served=FTTB_G');
assert.equal(ev("SCN.find(s=>s.id==='fttb').ok()"), true);
assert.equal(ev("SCN_PROG.fttb().length"), 6);
assert.equal(ev("SCN_PROG.fttb().length"), 7);
assert.deepEqual(errors, []);
});