From d086fcbd9208eb76ab09a1997e80a2cbca918bf6 Mon Sep 17 00:00:00 2001 From: Frederic Jung Date: Tue, 10 Nov 2026 06:51:34 +0000 Subject: [PATCH 1/2] 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). --- CHANGELOG.md | 2 + site/i18n/de.js | 6 ++ site/i18n/es.js | 6 ++ site/i18n/fr.js | 6 ++ site/i18n/it.js | 6 ++ site/i18n/pt.js | 6 ++ .../80-simulation/75-customer-lifecycle.js | 12 +++- src/game/93-ui/70-link-panels.js | 8 ++- src/i18n/en.js | 6 ++ src/styles/20-drawers.css | 2 + tests/link-panel-cities.test.js | 58 +++++++++++++++ tests/renewal-details.test.js | 72 +++++++++++++++++++ 12 files changed, 186 insertions(+), 4 deletions(-) create mode 100644 tests/link-panel-cities.test.js create mode 100644 tests/renewal-details.test.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 744dfae..68dcebc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ All notable changes to this project are documented here. The project follows ## [Unreleased] - A link that a closed border has taken down, like Doha to Dubai or Abu Dhabi while the neighbours have fallen out, now says so in its panel, with the days until it comes back, instead of showing nothing wrong. Leasing a new wave or fiber pair across that border during the spat warns you first that it will stay dark (#329). +- A customer asking for a discount at renewal now shows how much traffic they book and get, the price per Gbps now and asked, and any latency limit or path terms they signed for, each ticked or crossed as your network stands today (#292). +- The two city names at the top of a wave, dark fiber or virtual circuit panel now open that city, for example to upgrade the router there before a bigger link (#196). ## [3.3.0] — 2026-11-09 diff --git a/site/i18n/de.js b/site/i18n/de.js index 5402b72..9f2feba 100644 --- a/site/i18n/de.js +++ b/site/i18n/de.js @@ -2738,6 +2738,12 @@ "lifecycle.odd_wireguard":"Sie gehen komplett remote. Alle 40 Leute fahren WireGuard aus ihren Küchen, und die Büroleitung ist nur noch für die Pflanzen.", "lifecycle.odd_wrong_blue":"Die neue Büroleitung will alle Kabel in derselben Farbe, und deins ist das falsche Blau.", "lifecycle.referred_by":"Empfohlen von {name}, einem deiner zufriedensten Kunden.", +"lifecycle.ren_diverse":"zwei getrennte Pfade", +"lifecycle.ren_lat":"Latenz bis {max} ms (jetzt {now})", +"lifecycle.ren_no_subsea":"kein Seekabel", +"lifecycle.ren_per_g":"{was} → {price} pro Gbps", +"lifecycle.ren_sites_traffic":{"one":"{n} Standort × {bw} gebucht, {srv} geliefert","other":"{n} Standorte × {bw} gebucht, {srv} geliefert"}, +"lifecycle.ren_traffic":"{bw} gebucht, {srv} geliefert", "lifecycle.renewal_haggle":"Verlängerung am {date}: wird verhandelt", "lifecycle.renewals":"Verlängerungen", "lifecycle.renewals_soon":"Verlängerungen", diff --git a/site/i18n/es.js b/site/i18n/es.js index feaa272..3b2f43e 100644 --- a/site/i18n/es.js +++ b/site/i18n/es.js @@ -2736,6 +2736,12 @@ "lifecycle.odd_wireguard":"Se pasan al teletrabajo total. Los 40 empleados usarán WireGuard desde sus cocinas, y la línea de la oficina es solo para las plantas.", "lifecycle.odd_wrong_blue":"La nueva responsable de oficina quiere todos los cables del mismo color, y el tuyo es del azul equivocado.", "lifecycle.referred_by":"Recomendado por {name}, uno de tus clientes más contentos.", +"lifecycle.ren_diverse":"dos rutas diversas", +"lifecycle.ren_lat":"latencia de hasta {max} ms (ahora {now})", +"lifecycle.ren_no_subsea":"sin cable submarino", +"lifecycle.ren_per_g":"{was} → {price} por Gbps", +"lifecycle.ren_sites_traffic":{"one":"{n} sede × {bw} contratados, {srv} servidos","other":"{n} sedes × {bw} contratados, {srv} servidos"}, +"lifecycle.ren_traffic":"{bw} contratados, {srv} servidos", "lifecycle.renewal_haggle":"renovación el {date}: negociando", "lifecycle.renewals":"Renovaciones", "lifecycle.renewals_soon":"Renovaciones", diff --git a/site/i18n/fr.js b/site/i18n/fr.js index f971279..fd6e367 100644 --- a/site/i18n/fr.js +++ b/site/i18n/fr.js @@ -2736,6 +2736,12 @@ "lifecycle.odd_wireguard":"Ils passent en télétravail complet. Les 40 salariés utiliseront WireGuard depuis leur cuisine, et la ligne du bureau ne sert plus qu'aux plantes.", "lifecycle.odd_wrong_blue":"La nouvelle responsable des locaux veut tous les câbles de la même couleur, et le vôtre n'est pas le bon bleu.", "lifecycle.referred_by":"Recommandé par {name}, l'un de vos clients les plus satisfaits.", +"lifecycle.ren_diverse":"deux chemins diversifiés", +"lifecycle.ren_lat":"latence jusqu’à {max} ms (maintenant {now})", +"lifecycle.ren_no_subsea":"pas de câble sous-marin", +"lifecycle.ren_per_g":"{was} → {price} par Gbps", +"lifecycle.ren_sites_traffic":{"one":"{n} site × {bw} réservés, {srv} servis","other":"{n} sites × {bw} réservés, {srv} servis"}, +"lifecycle.ren_traffic":"{bw} réservés, {srv} servis", "lifecycle.renewal_haggle":"renouvellement le {date} : en négociation", "lifecycle.renewals":"Renouvellements", "lifecycle.renewals_soon":"Renouvellements", diff --git a/site/i18n/it.js b/site/i18n/it.js index 9034753..797cb9b 100644 --- a/site/i18n/it.js +++ b/site/i18n/it.js @@ -2736,6 +2736,12 @@ "lifecycle.odd_wireguard":"Passano al lavoro tutto da remoto. I 40 dipendenti useranno WireGuard dalle loro cucine, e la linea dell'ufficio serve solo alle piante.", "lifecycle.odd_wrong_blue":"Il nuovo responsabile dell'ufficio vuole tutti i cavi dello stesso colore, e il tuo è del blu sbagliato.", "lifecycle.referred_by":"Consigliato da {name}, uno dei tuoi clienti più contenti.", +"lifecycle.ren_diverse":"due percorsi diversi", +"lifecycle.ren_lat":"latenza entro {max} ms (ora {now})", +"lifecycle.ren_no_subsea":"niente cavi sottomarini", +"lifecycle.ren_per_g":"{was} → {price} per Gbps", +"lifecycle.ren_sites_traffic":{"one":"{n} sede × {bw} prenotati, {srv} serviti","other":"{n} sedi × {bw} prenotati, {srv} serviti"}, +"lifecycle.ren_traffic":"{bw} prenotati, {srv} serviti", "lifecycle.renewal_haggle":"rinnovo il {date}: si tratta", "lifecycle.renewals":"Rinnovi", "lifecycle.renewals_soon":"Rinnovi", diff --git a/site/i18n/pt.js b/site/i18n/pt.js index 0657f8f..626a03a 100644 --- a/site/i18n/pt.js +++ b/site/i18n/pt.js @@ -2736,6 +2736,12 @@ "lifecycle.odd_wireguard":"Vão trabalhar 100% remoto. Os 40 funcionários vão usar WireGuard da cozinha, e a linha do escritório fica só para as plantas.", "lifecycle.odd_wrong_blue":"A nova gerente do escritório quer todos os cabos da mesma cor, e o seu é do azul errado.", "lifecycle.referred_by":"Indicado por {name}, um dos seus clientes mais felizes.", +"lifecycle.ren_diverse":"dois caminhos diversos", +"lifecycle.ren_lat":"latência de até {max} ms (agora {now})", +"lifecycle.ren_no_subsea":"sem cabo submarino", +"lifecycle.ren_per_g":"{was} → {price} por Gbps", +"lifecycle.ren_sites_traffic":{"one":"{n} unidade × {bw} contratados, {srv} entregues","other":"{n} unidades × {bw} contratados, {srv} entregues"}, +"lifecycle.ren_traffic":"{bw} contratados, {srv} entregues", "lifecycle.renewal_haggle":"renovação em {date}: negociando", "lifecycle.renewals":"Renovações", "lifecycle.renewals_soon":"Renovações", diff --git a/src/game/80-simulation/75-customer-lifecycle.js b/src/game/80-simulation/75-customer-lifecycle.js index aa9bc4c..d7b60e2 100644 --- a/src/game/80-simulation/75-customer-lifecycle.js +++ b/src/game/80-simulation/75-customer-lifecycle.js @@ -113,11 +113,21 @@ function mktPrice(from){const m=mkt();for(let i=from;iMath.round((b.rate+b.hag.rate)/2); const clBill=(b,rate)=>BIZ_T[b.type].fiber?rate:b.bw*rate; const clHags=()=>S?S.biz.reduce((a,b)=>a+(b.hag?1:0),0):0; +/* What is at stake in a renewal (#292): how much traffic they book and get, the price per Gbps now and asked, and the + path terms they signed for (latency, diverse, no subsea), each ticked as it stands today. Two short lines for a phone. */ +function clRenInfo(b){const T=BIZ_T[b.type],tick=v=>`${v?'✓':'✗'} `,top=[],rq=[]; + if(!T.fiber){const sf=bizSf(b),srv=`${fmtG(b.bw*sf)}`; + top.push(b.sites?trn('lifecycle.ren_sites_traffic',b.sites.length,{bw:fmtG(b.bw),srv}):tr('lifecycle.ren_traffic',{bw:fmtG(b.bw),srv})); + top.push(tr('lifecycle.ren_per_g',{was:fmt$(b.rate),price:fmt$(b.hag.rate)}));} + for(const k of b.reqs||[]){const Q=REQS[k];if(!Q)continue;const ok=Q.ok(b); + if(k==='lat'){const v=R.l2lat[b.id]!==undefined?R.l2lat[b.id]:bestLat(b.city,b.city2);rq.push(tick(ok)+tr('lifecycle.ren_lat',{max:b.latMax,now:isFinite(v)?tr('common.ms_ms_one_way',{ms:v.toFixed(1)}):tr('common.no_path')}));} + else rq.push(tick(ok)+(k==='diverse'?tr('lifecycle.ren_diverse'):k==='sharks'?tr('lifecycle.ren_no_subsea'):esc(typeof Q.l==='function'?Q.l(b):Q.l)));} + return (top.length?`
${top.join(' · ')}
`:'')+(rq.length?`
${rq.join(' · ')}
`:'');} // The renewals waiting for an answer, at the top of Deals. function clDealsHtml(){const hs=S.biz.filter(b=>b.hag).sort((a,b)=>a.hag.until-b.hag.until);if(!hs.length)return ''; return `

${tr('lifecycle.renewals')}

${tr('lifecycle.unanswered_matches')}

`+hs.map(b=>{const now=BIZ_T[b.type].fiber?b.hag.rate:b.bw*b.hag.rate,was=bizMo(b); return `
${esc(b.name)}
${esc(BIZ_T[b.type].l)} · ${esc(clWhere(b))} · ${tr('ui.n_d_left',{n:b.hag.until-S.day})}
-
${tr('lifecycle.wants_price',{was:fmt$(was),price:fmt$(now),p:pct(1-now/Math.max(1,was))})}
${slRenRow(b)} +
${tr('lifecycle.wants_price',{was:fmt$(was),price:fmt$(now),p:pct(1-now/Math.max(1,was))})}
${clRenInfo(b)}${slRenRow(b)}
${btn(tr('lifecycle.match'),'renewMatch',{id:b.id},'green sm')}${btn(tr('lifecycle.meet_halfway',{price:fmt$(clBill(b,clMid(b)))}),'renewMeet',{id:b.id},'sm')}${btn(tr('lifecycle.let_them_go'),'renewLet',{id:b.id},'ghost sm')}
`;}).join('');} // The contract line on a customer row. const clTermTxt=b=>clOn(b)&&b.te?(b.hag?tr('lifecycle.renewal_haggle',{date:dateStr(b.te)}):tr('lifecycle.contract_until',{date:dateStr(b.te)})):''; diff --git a/src/game/93-ui/70-link-panels.js b/src/game/93-ui/70-link-panels.js index 39c6541..ff99639 100644 --- a/src/game/93-ui/70-link-panels.js +++ b/src/game/93-ui/70-link-panels.js @@ -23,9 +23,11 @@ function ixBlock(c,multi){const city=ixCity(c),C=CITY[city],ix=ixName(c),X=XIXM[ h+=``;return h; } function borderSection(l){const w=borderShut(l);return w?`

${tr('link_panels.border_closed')}

${w==='gulf'?tr('link_panels.a_diplomatic_spat_has_closed_the')+' '+tr('link_panels.back_in_n_days',{n:S.ev.gulf-S.day}):tr('link_panels.russia_has_unplugged_itself_from_the')}

`:'';} +// Both ends of a link in its panel header open that city (#196), say to upgrade the router there for a bigger wave. +const lkEnds=l=>[l.a,l.b].map(c=>cityOn(c)?btn(esc(CITY[c].name),'popGo',{city:c},'clink'):esc(CITY[c].name)).join(' ⇄ '); function vxcPanel(l){ const load=R.load[l.id]||0,cap=VXC[l.vt].g,u=load/cap,down=linkDown(l),f=FAB[l.prov]; - let h=`
${tr('link_panels.virtual_circuit_name_km_km',{name:esc(f.name),km:l.km.toLocaleString()})}

${CITY[l.a].name} ⇄ ${CITY[l.b].name}

`; + let h=`
${tr('link_panels.virtual_circuit_name_km_km',{name:esc(f.name),km:l.km.toLocaleString()})}

${lkEnds(l)}

`; h+=borderSection(l);if(down&&!borderShut(l))h+=`

${tr('common.fabric_outage')}

${tr('link_panels.name_is_down_nothing_you_can',{name:esc(f.name)})}

`; h+=`

${tr('common.capacity')}

${tr('link_panels.name_circuit',{name:VXC[l.vt].n})}${fmtG(load)} / ${fmtG(cap)}
${tr('common.monthly')}${tr('common.price_mo',{price:fmt$(l.mo)})}
${!S.pops[l.b]?`

${tr('link_panels.remote_peering_leg_into_ix',{ix:esc(CITY[l.b].ix)})}

`:''} @@ -114,7 +116,7 @@ function layPanel(l){const d=S.day,st=layStart(l),q=layQuote(l),km=Math.round(la return h;} function dfPanel(l){ const load=R.load[l.id]||0,cap=dfCap(l),u=cap?load/cap:0,bld=l.ready>S.day,A=CITY[l.a].name,B=CITY[l.b].name,inc=S.inc.find(i=>i.ref===l.id||i.ref===(l.trench||l.id)),amps=ampCount(l.km),sysD=DF_SYS[l.sys]; - let h=`
${tr('link_panels.dark_fiber_kind_km_km',{kind:l.own?tr('link_panels.your_own_build'):tr('common.leased_iru'),km:l.km.toLocaleString()})}

${A} ⇄ ${B}

`; + let h=`
${tr('link_panels.dark_fiber_kind_km_km',{kind:l.own?tr('link_panels.your_own_build'):tr('common.leased_iru'),km:l.km.toLocaleString()})}

${lkEnds(l)}

`; if(bld){const tot=Math.max(1,l.ready-l.day),done=clamp((S.day-l.day)/tot,0,1); h+=`

${l.own?tr('common.under_construction'):tr('common.being_spliced')}

${l.own?tr('link_panels.permits_trenching_splicing'):tr('common.iru_handover')}${tr('common.n_days_left',{n:l.ready-S.day})}
${l.own&&l.sub?layPanel(l):l.own?`
${btn(tr('link_panels.hire_extra_crews_price_30_days',{price:fmt$(crewCost(l))}),'crews',{id:l.id},'sm',!crewSteps(l)||S.cash${!crewSteps(l)&&l.ready>S.day+1?`

${tr('link_panels.crews_can_halve_a_build_at_most')}

`:''}`:''}

${tr('link_panels.you_can_pre_install_optics_now')}

`;} else if(inc&&linkDown(l))h+=`

${tr('common.dark_6bf5')}

${esc(inc.msg)}

${shipNote(inc)}${inc.cost?btn(`${esc(inc.fix||tr('common.rush_repair'))} ${fmt$(inc.cost)}`,'fixInc',{id:inc.id},'red',S.cash`; @@ -149,7 +151,7 @@ function linkPanel(id){ if(l.kind==='vxc')return vxcPanel(l); if(l.kind==='df')return dfPanel(l); const load=R.load[l.id]||0,cap=LT[l.tier].g,u=load/cap,cut=l.cut>S.day,trk=l.trench||l.id,inc=S.inc.find(i=>(LINKCUT_TR.includes(i.type)&&i.ref===trk)||((i.type==='fatwave'||i.type==='label'||i.type==='mtu')&&i.ref===l.id)),sib=pairLinks(l.a,l.b).filter(x=>x!==l&&x.kind!=='vxc'),mates=sib.filter(x=>(x.trench||x.id)===trk); - let h=`
${l.cable?esc(CAB[l.cable].name):l.sub?tr('common.subsea_cable'):tr('common.terrestrial_fiber')} · ${l.km.toLocaleString()} km

${CITY[l.a].name} ⇄ ${CITY[l.b].name}

`; + let h=`
${l.cable?esc(CAB[l.cable].name):l.sub?tr('common.subsea_cable'):tr('common.terrestrial_fiber')} · ${l.km.toLocaleString()} km

${lkEnds(l)}

`; if(cut)h+=`

${tr('common.cut_2e50')}

${inc?esc(inc.msg):''} ${inc&&shipSea(inc)?'':tr('link_panels.back_in_n_days',{n:l.cut-S.day})}

${shipNote(inc)}${inc&&inc.cost?btn(`${esc(inc.fix||tr('common.rush_repair'))} ${fmt$(inc.cost)}`,'fixInc',{id:inc.id},'red',S.cash`; h+=borderSection(l); h+=`

${tr('common.capacity')}

${tr('link_panels.name_wave',{name:LT[l.tier].n})}${fmtG(load)} / ${fmtG(cap)}
diff --git a/src/i18n/en.js b/src/i18n/en.js index bb7bbc3..2649cfc 100644 --- a/src/i18n/en.js +++ b/src/i18n/en.js @@ -2737,6 +2737,12 @@ "lifecycle.odd_wireguard":"They are going fully remote. All 40 staff will run WireGuard from their kitchens, and the office line is just for the plants.", "lifecycle.odd_wrong_blue":"The new office manager wants every cable the same colour, and yours is the wrong blue.", "lifecycle.referred_by":"Referred by {name}, one of your happiest customers.", +"lifecycle.ren_diverse":"two diverse paths", +"lifecycle.ren_lat":"latency within {max} ms (now {now})", +"lifecycle.ren_no_subsea":"no subsea cable", +"lifecycle.ren_per_g":"{was} → {price} per Gbps", +"lifecycle.ren_sites_traffic":{"one":"{n} site × {bw} booked, {srv} served","other":"{n} sites × {bw} booked, {srv} served"}, +"lifecycle.ren_traffic":"{bw} booked, {srv} served", "lifecycle.renewal_haggle":"renewal on {date}: haggling", "lifecycle.renewals":"Renewals", "lifecycle.renewals_soon":"Renewals", diff --git a/src/styles/20-drawers.css b/src/styles/20-drawers.css index 31fc819..8dfcadd 100644 --- a/src/styles/20-drawers.css +++ b/src/styles/20-drawers.css @@ -49,6 +49,8 @@ section h3{font-size:17px;margin-bottom:6px;display:flex;align-items:center;gap: .b.green{background:var(--ok);color:#fff} .b.sm{font-size:12px;padding:2px 8px 1px;border-radius:9px;box-shadow:0 2px 0 var(--ink)} .b.big{font-size:18px;padding:7px 18px 5px} +/* A city name in a heading that opens the city (link panels, #196): reads as the heading, underlined like a link. */ +.b.clink,.b.clink:active{font:inherit;color:inherit;background:none;border:0;box-shadow:none;transform:none;padding:2px 0;border-radius:0;white-space:normal;text-align:left;text-decoration:underline;text-decoration-thickness:2px;text-underline-offset:4px;text-decoration-color:var(--me)} .b small{font-family:var(--body);font-weight:800;font-size:10.5px;opacity:.85;margin-left:3px} .logo{width:30px;height:30px;border-radius:50%;background:var(--c);border:2.5px solid var(--ink);display:grid;place-items:center;color:#fff;font-family:var(--display);font-weight:800;font-size:11px;flex:none;letter-spacing:-.02em} diff --git a/tests/link-panel-cities.test.js b/tests/link-panel-cities.test.js new file mode 100644 index 0000000..5bbfef0 --- /dev/null +++ b/tests/link-panel-cities.test.js @@ -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, []); +}); diff --git a/tests/renewal-details.test.js b/tests/renewal-details.test.js new file mode 100644 index 0000000..091aee3 --- /dev/null +++ b/tests/renewal-details.test.js @@ -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, /^
/); + assert.doesNotMatch(info, /nowrap|width:\s*\d{3,}px/); + assert.deepEqual(errors, []); +}); From 870227100d024a5c502f696a3cd1e6dc16e77f39 Mon Sep 17 00:00:00 2001 From: Frederic Jung Date: Tue, 10 Nov 2026 07:56:26 +0000 Subject: [PATCH 2/2] Route fuzz: leave the link panel's header city links out of the buttons both pages offer They only change the view, and main's page has plain text there, so offering them would make the two pages diverge on a screen that routes the same. --- scripts/lib/fuzz-page.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/lib/fuzz-page.js b/scripts/lib/fuzz-page.js index 5b05a14..769b69c 100644 --- a/scripts/lib/fuzz-page.js +++ b/scripts/lib/fuzz-page.js @@ -56,7 +56,9 @@ const screen = (w) => { if (w.where === 'modal') return btns($('modal')); if (w.where === 'city') { UI.sel = { type: 'city', id: w.city }; UI.tab = w.tab; renderAll(); return btns($('panel')); } - if (w.where === 'link') { if (!S.links.some((l) => l.id === w.id)) return []; UI.sel = { type: 'link', id: w.id }; renderAll(); return btns($('panel')); } + // The city names in a link panel's header open the city (#196); older pages have plain text there. They only change + // the view, so neither page offers them, and both stay in lockstep. + if (w.where === 'link') { if (!S.links.some((l) => l.id === w.id)) return []; UI.sel = { type: 'link', id: w.id }; renderAll(); const P = $('panel'); for (const h of P.querySelectorAll('.ph h2 [data-act]')) h.removeAttribute('data-act'); return btns(P); } if (w.where === 'dash') { $('dash').hidden = false; UI.dtab = w.tab; renderDash(); const b = btns($('dash')); return b; } if (w.where === 'left') { UI.left = w.tab; UI.leftOpen = true; renderLeft(); let b = btns($('leftBody'));