From 271c562205fad79e3ac6423b7b0d6e78ba27a758 Mon Sep 17 00:00:00 2001 From: Frederic Jung Date: Thu, 29 Oct 2026 20:22:20 +0100 Subject: [PATCH] Tests: Mind the Gap, Order and Progress, Fibre to the Basement and Flood Season checks follow the tuned goals --- tests/modes.test.js | 10 ++++++---- tests/regions.test.js | 8 ++++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/modes.test.js b/tests/modes.test.js index 95ef1bd..92c56c8 100644 --- a/tests/modes.test.js +++ b/tests/modes.test.js @@ -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); diff --git a/tests/regions.test.js b/tests/regions.test.js index 0ae73fa..202def9 100644 --- a/tests/regions.test.js +++ b/tests/regions.test.js @@ -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, []); });