Show traffic, price per Gbps and path terms on renewal haggles; link panel city names open the city
Renewal haggles in Deals now show booked and served Gbps (sites for SD-WAN), the price per Gbps now and asked, and the latency limit and path terms the customer signed for, each ticked as the network stands today (#292). The two city names in the header of wave, dark fiber and virtual circuit panels are buttons that open that city (#196).
This commit is contained in:
parent
80baa970e7
commit
d086fcbd92
12 changed files with 186 additions and 4 deletions
58
tests/link-panel-cities.test.js
Normal file
58
tests/link-panel-cities.test.js
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
// #196: the two city names at the top of a link panel (wave, dark fiber, virtual circuit) open that city's panel.
|
||||
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.nextFail=S.nextEvent=1e9;for(const g of GOALS)S.done[g.id]=0;";
|
||||
const ends = ev => JSON.parse(ev("JSON.stringify([...document.querySelectorAll('#panel .ph h2 button[data-act=\"popGo\"]')].map(b=>[b.textContent,JSON.parse(b.dataset.args).city]))"));
|
||||
const click = (ev, i) => ev(`document.querySelectorAll('#panel .ph h2 button[data-act="popGo"]')[${i}].click()`);
|
||||
|
||||
function setup(ev) {
|
||||
ev(start + "ACT.launchBB({city:'fra'});ACT.buildPop({city:'ams'});compute()");
|
||||
ev("S.links.push({id:'w1',a:'fra',b:'ams',kind:'wave',tier:0,km:360,sub:false,mo:1,cut:0,day:0})");
|
||||
ev("S.links.push({id:'df1',a:'fra',b:'ams',kind:'df',own:false,sys:'lite',ch:[],km:360,sub:false,mo:1,ready:0,cut:0,day:0})");
|
||||
ev("S.links.push({id:'vx1',a:'fra',b:'ams',kind:'vxc',prov:Object.keys(FAB)[0],vt:0,km:360,sub:false,mo:1,cut:0,day:0});compute()");
|
||||
}
|
||||
|
||||
for (const [id, kind] of [['w1', 'wave'], ['df1', 'dark fiber'], ['vx1', 'virtual circuit']]) {
|
||||
test(`#196 a ${kind} panel links both of its cities, and a click opens the city`, () => {
|
||||
const { ev, errors } = load();
|
||||
setup(ev);
|
||||
ev(`selectLink('${id}')`);
|
||||
assert.deepEqual(ends(ev), [['Frankfurt', 'fra'], ['Amsterdam', 'ams']]);
|
||||
assert.match(ev("document.querySelector('#panel .ph h2').textContent"), /Frankfurt ⇄ Amsterdam/);
|
||||
click(ev, 1);
|
||||
assert.equal(ev("UI.sel.type+':'+UI.sel.id"), 'city:ams', 'the far end is selected');
|
||||
assert.equal(ev("cam.x"), ev("CITY.ams.x"), 'and the map moves to it');
|
||||
assert.match(ev("document.querySelector('#panel .ph h2').textContent"), /Amsterdam/);
|
||||
ev(`selectLink('${id}')`);
|
||||
click(ev, 0);
|
||||
assert.equal(ev("UI.sel.id"), 'fra');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
|
||||
test('#196 on a 390 px phone the city links sit in the bottom sheet header and still open the city', () => {
|
||||
const { ev, errors } = load();
|
||||
setup(ev);
|
||||
ev("window.innerWidth=390;renderAll();selectLink('w1')");
|
||||
assert.equal(ev("isPhone()"), true);
|
||||
assert.equal(ends(ev).length, 2);
|
||||
// The link styling: reads as heading text that wraps, not a button that pushes the header wider.
|
||||
assert.match(ev("document.querySelector('#panel .ph h2 button').className"), /\bclink\b/);
|
||||
click(ev, 0);
|
||||
assert.equal(ev("UI.sel.type+':'+UI.sel.id"), 'city:fra');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('#196 a city the map does not show stays plain text', () => {
|
||||
const { ev, errors } = load();
|
||||
setup(ev);
|
||||
ev("selectLink('w1')");
|
||||
// cityOn() is false for an off-map city without a POP or IX port: no button to a panel that would not open.
|
||||
ev("CITY.ams.off=true;delete S.pops.ams;renderPanel()");
|
||||
assert.deepEqual(ends(ev), [['Frankfurt', 'fra']]);
|
||||
assert.match(ev("document.querySelector('#panel .ph h2').textContent"), /Frankfurt ⇄ Amsterdam/);
|
||||
ev("delete CITY.ams.off");
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
72
tests/renewal-details.test.js
Normal file
72
tests/renewal-details.test.js
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
// #292: a renewal haggle in Deals shows what is at stake: traffic booked and served, the price per Gbps now and asked,
|
||||
// and the path terms the customer signed for, each ticked as it stands today. It fits on a phone.
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const { load } = require('./harness');
|
||||
|
||||
const start = "ACT.start({});S.cash=1e9;S.lvl=6;S.nextFail=S.nextEvent=1e9;for(const g of GOALS)S.done[g.id]=0;";
|
||||
// Frankfurt, Paris and Amsterdam in a triangle, so Frankfurt-Amsterdam has a direct path and one round through Paris.
|
||||
function net(ev) {
|
||||
ev(start + "ACT.launchBB({city:'fra'});ACT.buildPop({city:'par'});ACT.buildPop({city:'ams'});for(const c in S.pops){S.pops[c].rgen=3;S.pops[c].routers=2}");
|
||||
for (const [a, b] of [['fra', 'par'], ['par', 'ams'], ['fra', 'ams']]) ev(`UI.via=null;openLinkModal('${a}','${b}');ACT.buildLink({tier:1});closeModal()`);
|
||||
}
|
||||
const deals = ev => { ev("UI.left='deals';renderLeft()"); return ev("document.getElementById('left').innerHTML"); };
|
||||
const row = (ev, name) => ev(`(()=>{const r=[...document.querySelectorAll('#left .row')].find(r=>r.querySelector('.nm')&&r.querySelector('.nm').textContent==='${name}');return r?r.textContent:''})()`);
|
||||
|
||||
test('#292 an IP customer\'s renewal shows booked and served traffic and the price per Gbps', () => {
|
||||
const { ev, errors } = load();
|
||||
net(ev);
|
||||
ev("S.biz.push({id:'h1',city:'ams',city2:null,name:'Haggle Hosting',type:'dia',bw:5,rate:600,reqs:[],mood:90,since:S.day-800,te:S.day+20,mk:1,hag:{rate:540,until:S.day+20}});compute()");
|
||||
deals(ev);
|
||||
const t = row(ev, 'Haggle Hosting');
|
||||
assert.match(t, /5\.0 Gbps booked, [\d.]+ Gbps served/);
|
||||
assert.ok(t.includes(ev("fmt$(600)") + ' → ' + ev("fmt$(540)") + ' per Gbps'), t);
|
||||
assert.match(t, /Pays .* wants .* to renew/, 'the monthly bills are still there');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('#292 a circuit\'s renewal shows its latency limit and path terms, ticked as they stand today', () => {
|
||||
const { ev, errors } = load();
|
||||
net(ev);
|
||||
ev("S.biz.push({id:'c1',city:'fra',city2:'ams',name:'Tulip Bank',type:'l2vpn',bw:10,rate:300,reqs:['lat','diverse','sharks'],latMax:50,route:'fast',mood:90,since:S.day-800,te:S.day+20,mk:1,hag:{rate:250,until:S.day+20}});compute()");
|
||||
deals(ev);
|
||||
let t = row(ev, 'Tulip Bank');
|
||||
assert.match(t, /10\.0 Gbps booked, 10\.0 Gbps served/);
|
||||
assert.match(t, /✓ latency within 50 ms \(now [\d.]+ ms one-way\)/);
|
||||
assert.match(t, /✓ two diverse paths/, 'direct and round through Paris');
|
||||
assert.match(t, /✓ no subsea cable/);
|
||||
// A tight budget the network cannot meet is crossed out, with what it gets today.
|
||||
ev("S.biz.find(b=>b.id==='c1').latMax=0.5;compute()");
|
||||
deals(ev);
|
||||
t = row(ev, 'Tulip Bank');
|
||||
assert.match(t, /✗ latency within 0\.5 ms/);
|
||||
assert.doesNotMatch(t, /undefined|NaN/);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('#292 SD-WAN shows its sites, fiber deals show no Gbps, and served traffic below what is booked is red', () => {
|
||||
const { ev, errors } = load();
|
||||
net(ev);
|
||||
ev("S.biz.push({id:'s1',city:'fra',city2:null,sites:['fra','par','ams'],name:'Kebab Kingdom',type:'sdwan',bw:2,rate:400,reqs:[],mood:90,since:S.day-800,te:S.day+20,mk:1,hag:{rate:360,until:S.day+20}});compute()");
|
||||
deals(ev);
|
||||
assert.match(row(ev, 'Kebab Kingdom'), /3 sites × 2\.0 Gbps booked/);
|
||||
assert.doesNotMatch(row(ev, 'Kebab Kingdom'), /✓|✗/, 'no path terms when they asked for none');
|
||||
assert.equal(ev("clRenInfo({...S.biz.find(b=>b.id==='s1'),type:'dfpair'})"), '', 'a fiber pair is not sold by the Gbps');
|
||||
ev("R.l2['s1']=0.5");
|
||||
assert.match(ev("clRenInfo(S.biz.find(b=>b.id==='s1'))"), /color:var\(--bad\)">0\.5 Gbps/);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('#292 the renewal row fits a 390 px phone', () => {
|
||||
const { ev, errors } = load();
|
||||
net(ev);
|
||||
ev("S.biz.push({id:'c1',city:'fra',city2:'ams',name:'Tulip Bank',type:'l2vpn',bw:10,rate:300,reqs:['lat','diverse'],latMax:50,route:'fast',mood:90,since:S.day-800,te:S.day+20,mk:1,hag:{rate:250,until:S.day+20}});compute()");
|
||||
ev("window.innerWidth=390;renderAll()");
|
||||
deals(ev);
|
||||
assert.match(row(ev, 'Tulip Bank'), /booked, .* served/);
|
||||
// Every new line is a wrapping meta line, never one wide nowrap element.
|
||||
const info = ev("clRenInfo(S.biz.find(b=>b.id==='c1'))");
|
||||
assert.match(info, /^<div class="meta">/);
|
||||
assert.doesNotMatch(info, /nowrap|width:\s*\d{3,}px/);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue