diff --git a/site/i18n/it.js b/site/i18n/it.js index 22444a5..bca1042 100644 --- a/site/i18n/it.js +++ b/site/i18n/it.js @@ -2158,4 +2158,20 @@ "Viewport info":"Info viewport", "For reporting layout bugs: shows what your screen tells the game.":"Per segnalare bug di layout: mostra cosa lo schermo dice al gioco.", "Done":"Fatto", +"Lv {n}":"Liv. {n}", +"Done!":"Fatto!", +"A path from Marseille to Singapore":"Un percorso da Marsiglia a Singapore", +"Carnaval delivered in full":"Carnevale servito per intero", +"POP in {city}":"POP a {city}", +"Days in a row with 99.5% served":"Giorni di fila con il 99,5% servito", +"{n} of {m}":"{n} su {m}", +"Your score: peak traffic":"Il tuo punteggio: picco di traffico", +"Done in {d} days!":"Fatto in {d} giorni!", +"Scenario":"Scenario", +"Time":"Tempo", +"Continents":"Continenti", +"Customer level {lv} of {max}":"Livello clienti {lv} di {max}", +"Next: {name} unlocks {what}":"Prossimo: {name} sblocca {what}", +"Overview":"Panoramica", +"Links & routers":"Collegamenti e router", }; diff --git a/site/index.html b/site/index.html index 9ed1851..8a4b80f 100644 --- a/site/index.html +++ b/site/index.html @@ -375,6 +375,13 @@ input.t{width:100%;box-sizing:border-box;border:3px solid var(--ink);border-radi A decluttered, app-like layout: a one-row status strip at the top, a tab bar at the bottom (play, speed, goals, deals, NOC, networks), and bottom sheets you drag up, down or away. */ html,body{overscroll-behavior:none} +.dtabs{position:sticky;top:-12px;z-index:3;display:flex;gap:6px;overflow-x:auto;margin:10px -4px 4px;padding:8px 4px;background:var(--paper);border-bottom:2.5px solid var(--ink);scrollbar-width:none} +.dtabs button{flex:0 0 auto;font:800 13px Nunito,sans-serif;border:2.5px solid var(--ink);border-radius:999px;background:#fff;padding:5px 12px;cursor:pointer;color:var(--ink)} +.dtabs button.on{background:var(--pink,#FF4F9A);color:#fff} +.dtabs .cnt{display:inline-block;margin-left:5px;min-width:16px;padding:0 4px;border-radius:8px;background:var(--bad);color:#fff;font-size:10.5px;line-height:16px;text-align:center} +.pcard{border:2.5px solid var(--ink);border-radius:14px;padding:8px 10px;margin:0 0 10px;background:#FFF6CF} +.pcard .pt{font-weight:900;font-size:15px;margin:1px 0 2px}.pcard .kv{margin-top:5px}.pcard .bar{margin-top:2px} +.pcard.lv{background:#EAF6FF} .pitch{list-style:none;padding:0;margin:10px 0}.pitch li{margin:7px 0;line-height:1.38;font-size:14px}.pitch li.warn{background:#FFF4D6;border:2px solid var(--ink);border-radius:10px;padding:6px 8px} .isteps{padding-left:22px;margin:8px 0 4px}.isteps li{margin:5px 0;line-height:1.38;font-size:14px}.isteps svg{vertical-align:-3px} .icard{margin:8px 0 10px;border:2.5px solid var(--ink);border-radius:14px;padding:8px 10px;background:#FFF4D6} @@ -500,6 +507,7 @@ button,.chip,.b,a{touch-action:manipulation;-webkit-tap-highlight-color:transpar
Traffic served
0
Reach
0%
Rank
Tier 3
+
@@ -2404,6 +2412,7 @@ const ACT={ help:()=>showHelp(), dash:()=>{if(!S)return;const d=$('dash');d.hidden=!d.hidden;if(!d.hidden)renderDash();}, dashClose:()=>{$('dash').hidden=true;}, + dashTab:({k})=>{if(!DTABS.includes(k))return;UI.dtab=k;renderDash();const d=$('dash');if(d)d.scrollTop=0;}, dashSort:({k})=>{if(!['name','asn','type','traffic','cost','lost'].includes(k))return;if(UI.dashSort===k)UI.dashDir=-(UI.dashDir||-1);else{UI.dashSort=k;UI.dashDir=k==='name'||k==='type'||k==='asn'?1:-1;}renderDash();}, bank:()=>{if(!S)return;UI.confirm=null;$('dash').hidden=true;const b=$('bankBox');b.hidden=false;UI._bh=null;renderBank();}, bankClose:()=>{UI.confirm=null;$('bankBox').hidden=true;}, @@ -2535,14 +2544,14 @@ const ACT={ custF:({v})=>{UI.kf=UI.kf||{};UI.kf.f=v==='sad'?'sad':'';renderDash();}, custCity:({v})=>{UI.kf=UI.kf||{};UI.kf.city=isCity(v)?v:'';renderDash();}, custSort:({k})=>{if(!['mood','mo','name','city'].includes(k))return;if(UI.custSort===k)UI.custDir=-(UI.custDir||1);else{UI.custSort=k;UI.custDir=k==='mo'?-1:1;}renderDash();}, - custOpen:({sad}={})=>{if(!S)return;UI.kf=sad?{f:'sad'}:{};const d=$('dash');d.hidden=false;renderDash();setTimeout(()=>{const el=$('custSec');if(el)el.scrollIntoView({block:'start'});},30);}, + custOpen:({sad}={})=>{if(!S)return;UI.kf=sad?{f:'sad'}:{};UI.dtab='cust';const d=$('dash');d.hidden=false;renderDash();d.scrollTop=0;}, goConn:({city,k})=>{if(!isCity(city)||!own(CONN_K,k))return;$('dash').hidden=true;ACT.goEgress({city,k});}, connF:({f,v})=>{const F=UI.cf=UI.cf||{};if(f==='all'){UI.cf={};}else if(f==='k'){F.k=own(CONN_K,v)?v:'';}renderDash();}, connCity:({v})=>{UI.cf=UI.cf||{};UI.cf.city=isCity(v)?v:'';renderDash();}, connNet:({v})=>{UI.cf=UI.cf||{};UI.cf.net=NET[v]?v:'';renderDash();}, connSort:({k})=>{if(!['k','city','name','use','mo'].includes(k))return;if(UI.connSort===k)UI.connDir=-(UI.connDir||1);else{UI.connSort=k;UI.connDir=k==='use'||k==='mo'?-1:1;}renderDash();}, connFor:({net})=>{if(!NET[net])return;UI.cf={net};ACT.connOpen();}, - connOpen:()=>{if(!S)return;const d=$('dash');d.hidden=false;renderDash();setTimeout(()=>{const el=$('connSec');if(el)el.scrollIntoView({block:'start'});},30);}, + connOpen:()=>{if(!S)return;UI.dtab='conn';const d=$('dash');d.hidden=false;renderDash();d.scrollTop=0;}, applyCn:()=>{if(S.cnLic.state!=='none')return;if(!spend(CN_LIC))return;S.cnLic={state:'pending',ready:S.day+45};toast(tr('Application filed.
Your local partner says about 45 days. Probably.'),'goal');after();}, togglePrem:({id})=>{const t=S.transit.find(x=>x.id===id);if(!t)return;t.premium=!t.premium;sfx('click');after();}, buildScrub:({city,tier})=>{if(S.scrubAt)return;const T=SCRUB_TIERS[tier||0];if((lvl()||1){tier} scrubbing unlocks at customer level {lv}.',{tier:T.n,lv:T.lvl}),'bad');sfx('err');return;}if(!spend(T.cost))return;S.scrubAt=city;S.scrubTier=tier||0;S.scrubMode='always';toast(tr('{tier} scrubbing center online in {city}.
Attacks up to {g} are cleaned, and you can sell DDoS protection.',{tier:T.n,city:CITY[city].name,g:fmtG(T.g)}),'good');after();}, @@ -2692,7 +2701,7 @@ function renderTabbar(){const tb=$('tabbar');if(!tb)return;if(!isPhone()||!S||!U const tab=(k,ic,l,cnt,red)=>``; const h=``+ ``+ - tab('goals','🎯',tr('Goals'),`${ndone}/${GOALS.length}`)+(()=>{const u=custStats().unhappy;return u?tab('deals','💼',tr('Deals'),u,true):tab('deals','💼',tr('Deals'),S.offers.length||'');})()+tab('noc','🚨','NOC',S.inc.length||'',true)+tab('nets','🌐',tr('Networks')); + (()=>{const P=scnProg();return tab('goals','🎯',tr('Goals'),P&&!S.scn.done&&!S.scn.failed?`${Math.round(P.f*100)}%`:`${ndone}/${GOALS.length}`);})()+(()=>{const u=custStats().unhappy;return u?tab('deals','💼',tr('Deals'),u,true):tab('deals','💼',tr('Deals'),S.offers.length||'');})()+tab('noc','🚨','NOC',S.inc.length||'',true)+tab('nets','🌐',tr('Networks')); if(h!==UI._tb){UI._tb=h;tb.innerHTML=h;} document.body.classList.toggle('sheet-open',!!(UI.sel||UI.leftOpen));} function haptic(ms){if(UI.muted)return;try{navigator.vibrate&&navigator.vibrate(ms||12);}catch(e){}} @@ -2744,7 +2753,8 @@ function renderHUD(){ $('hTrafBar').style.width=(R.demand?R.served/R.demand*100:0)+'%'; $('hTrafBar').style.background=R.demand&&R.served/R.demand<0.9?'var(--bad)':'var(--ok)'; $('hReach').textContent=pct(R.reach);$('hReach').style.color=R.reach<0.99?'var(--bad)':'var(--eye)'; - $('hTier').textContent=tierLabel(); + $('hTier').textContent=tierLabel()+' · '+tr('Lv {n}',{n:S.lvl||1}); + {const P=scnProg(),hs=$('hScn');hs.hidden=!P;if(P){const sc=S.scn;$('hScnVal').textContent=sc.done?tr('Done!'):sc.failed?tr("Time's up"):`${Math.round(P.f*100)}% · ${tr('{n}d left',{n:Math.max(0,sc.days-S.day)})}`;}} $('hDate').textContent=dateStr(S.day); {const bo=(S.loanOffers||[]).length,hb=$('hBank');hb.hidden=!bo;hb.textContent=bo;} {const st=custStats(),hc=$('hCust');hc.hidden=!st.n;if(st.n){$('hCustVal').innerHTML=`${st.avg>=80?'😀':st.avg>=60?'🙂':st.avg>=30?'😟':'😡'} ${Math.round(st.avg)}%${st.unhappy?` ${st.unhappy}`:''}`;hc.classList.toggle('hot',st.furious>0);}} @@ -2763,6 +2773,7 @@ function renderLeft(){ $('leftTabs').innerHTML=tabs.map(([k,l])=>``).join('')+(innerWidth<760?``:''); let h=''; if(UI.left==='goals'){ + h+=scnCard()+lvlCard(); const cur=GOALS.find(g=>S.done[g.id]===undefined); h+=GOALS.map(g=>{const d=S.done[g.id]!==undefined,c=g===cur;return `
${d?'✓':''}
${esc(g.t)}
${c||!d?`
${esc(g.d)}
`:''}${!d&&g.r?`
${tr('Reward {cash}',{cash:fmt$(g.r)})}
`:''}
`;}).join(''); h+=badgeGrid(); @@ -3068,6 +3079,26 @@ function offTransitHint(id,city){const n=NET[id];if(n.type==='t1')return tr('Tie if(ixOk)return `${ixName(pick1)}: ${ixOk.why}`; return pniC.length?tr('PNI in {city}: {why}',{city:CITY[pniC[0]].name,why:pOk.why}):tr('Not present in any of your cities yet');} function transitTop(ids,k=5){const m={};for(const id of ids)for(const [n,v] of Object.entries(R.tNet[id]||{}))m[n]=(m[n]||0)+v;return Object.entries(m).filter(([,v])=>v>0.01).sort((a,b)=>b[1]-a[1]).slice(0,k);} +/* ---------- scenario and level progress (#34) ---------- */ +const pSrv=g=>({l:tr('Traffic served'),v:R.served,max:g,txt:`${fmtG(R.served)} / ${fmtG(g)}`}); +const pReach=()=>({l:tr('Reach'),v:R.reach,max:0.99,txt:`${pct(R.reach)} / 99%`}); +const pChk=(l,ok)=>({l,v:ok?1:0,max:1,txt:ok?'✓':'—'}); +const SCN_PROG={stg:()=>[pSrv(200)],redsea:()=>[pChk(tr('A path from Marseille to Singapore'),pathExists('mrs','sin')),pSrv(300)],spat:()=>[pReach(),pSrv(150)], + carnaval:()=>[pChk(tr('Carnaval delivered in full'),(S.stats.evFull||0)>=1)],darien:()=>[...['bog','lim','scl','sao'].map(c=>pChk(tr('POP in {city}',{city:CITY[c].name}),!!S.pops[c])),pSrv(150)], + gangnam:()=>[pReach(),pSrv(200)],baltic:()=>[{l:tr('Days in a row with 99.5% served'),v:S.stats.clean||0,max:90,txt:tr('{n} of {m}',{n:S.stats.clean||0,m:90})}]}; +function scnProg(){const sc=S&&S.scn;if(!sc)return null; + if(sc.id==='weekly')return {goal:tr('Serve as much traffic as you can in one year.'),items:[{l:tr('Your score: peak traffic'),v:0,max:0,txt:fmtG(S.stats.peak||0)}],f:Math.min(1,S.day/sc.days)}; + const def=SCN.find(x=>x.id===sc.id),fn=SCN_PROG[sc.id];if(!def)return null;let items=[];try{items=fn?fn():[];}catch(e){items=[];} + const f=sc.done?1:items.length?items.reduce((a,x)=>a+Math.min(1,x.max?x.v/x.max:0),0)/items.length:0;return {goal:def.goal,items,f};} +const pRow=x=>`
${esc(x.l)}${esc(x.txt)}
${x.max?`
`:''}`; +function scnCard(){const sc=S.scn,P=scnProg();if(!sc||!P)return '';const left=Math.max(0,sc.days-S.day); + const st=sc.done?`${tr('Done in {d} days!',{d:sc.done})}`:sc.failed?`${tr("Time's up")}`:tr('{n} days left',{n:left}); + return `
${tr('Scenario')} · ${Math.round(P.f*100)}%
${esc(sc.name)}
🎯 ${esc(P.goal)}
${P.items.map(pRow).join('')}
${tr('Time')}${st}
`;} +function lvlItems(){const lv=S.lvl||1,pk=S.stats.peak||0,pops=Object.keys(S.pops).length,G=(l,v,max,txt)=>({l,v,max,txt}); + const peak=m=>G(tr('Peak traffic'),pk,m,`${fmtG(pk)} / ${fmtG(m)}`),pp=m=>G(tr('POPs'),pops,m,`${pops} / ${m}`); + return lv===1?[peak(200),pp(3)]:lv===2?[peak(1000),pp(6)]:lv===3?[peak(3000),pp(10),G(tr('Continents'),regionsCount(),3,`${regionsCount()} / 3`)]:[];} +function lvlCard(){const lv=S.lvl||1,nx=LEVELS[lv]; + return `
${tr('Customer level {lv} of {max}',{lv,max:LEVELS.length})}
${esc(LEVELS[lv-1].n)}
${nx?`
${tr('Next: {name} unlocks {what}',{name:esc(nx.n),what:esc(nx.unlock.toLowerCase())})}
${lvlItems().map(pRow).join('')}`:`
${tr('Every customer type is unlocked. Go get those terabits.')}
`}
`;} /* ---------- customers overview (#13, #14, #15) ---------- */ const bizMo=b=>{const T=BIZ_T[b.type];return T.event?0:T.fiber?b.rate:b.bw*b.rate;}; // Why a customer is unhappy, in the same terms the daily mood update uses. @@ -3140,12 +3171,15 @@ function netWhere(n){const ch=[]; for(const c of new Set(S.caches.filter(x=>x.net===n.id).map(x=>x.city)))ch.push([tr('Cache'),c,'c']); if(!ch.length)return '';const MAX=6; return `
${ch.slice(0,MAX).map(([l,c,k])=>btn(`${esc(l)} ${esc(CITY[c].name)}`,'goConn',{city:c,k},'ghost sm')).join('')}${ch.length>MAX?btn(tr('+{n} more',{n:ch.length-MAX}),'connFor',{net:n.id},'ghost sm'):''}
`;} +const DTABS=['overview','cust','conn','traffic','infra']; +function dashTabs(){const u=custStats().unhappy,cur=UI.dtab||'overview',L={overview:tr('Overview'),cust:tr('Customers'),conn:tr('Connections'),traffic:tr('Traffic'),infra:tr('Links & routers')}; + return ``;} function renderDash(){ const H=S.hist||[],rows=H.slice(-90),last30=H.slice(-30); const up=last30.length?last30.reduce((a,r)=>a+(r.dem?Math.min(1,r.srv/r.dem):1),0)/last30.length:1; const net=R.revMo-R.costMo,tot=Object.values(R.egT).reduce((a,b)=>a+b,0)||1; const tile=(l,v,sub)=>`
${l}
${v}
${sub?`
${sub}
`:''}
`; - let h=`
AS${S.asn} · ${esc(S.name)} · ${tierLabel()}

${tr('NOC dashboard')}

+ let h=`
AS${S.asn} · ${esc(S.name)} · ${tierLabel()}

${tr('NOC dashboard')}

`+dashTabs();const DT=UI.dtab||'overview';if(DT==='overview')h+=`
${tile(tr('Traffic now'),fmtG(R.served),tr('of {g} wanted',{g:fmtG(R.demand)}))}${tile(tr('Peak'),fmtG(S.stats.peak))}${tile(tr('Delivered, 30 days'),(up*100).toFixed(1)+'%',up>=0.999?tr('five nines-ish'):up>=0.99?tr('two nines and change'):tr('customers are upset'))}${tile(tr('Peering ratio'),pct(R.peerShare||0),tr('caches, PNIs and IX'))}${tile(tr('Monthly P&L'),`${net>=0?'+':''}${fmt$(net)}`,tr('{in} in · {out} out',{in:fmt$(R.revMo),out:fmt$(R.costMo)}))}${tile(tr('Incidents'),S.stats.incidents,tr('{n} shrugged off',{n:S.stats.survived}))}

${tr('Traffic by way out')}

${svgChart(rows,['c','p','ix','t','l2'],[{k:'dem',col:'#1E2640',dash:true}],v=>fmtCap(Math.round(v)))}
${Object.keys(EGC).map(k=>`${EGC[k][0]} ${pct((R.egT[k]||0)/tot)}`).join('')}${tr('Demand')}

${tr('Money per month')}

${svgChart(rows,[],[{k:'rev',col:'#16A866'},{k:'cost',col:'#FF4D5E'}],v=>fmt$(v))}
${tr('Revenue')}${tr('Costs')}
@@ -3156,14 +3190,14 @@ function renderDash(){ {const e={c:0,p:0,ix:0,t:0};let w=0;for(const n of NETS)if(n.tail){const x=R.netEg[n.id];if(x)for(const k in e)e[k]+=x[k]||0;w+=R.demTo[n.id]||0;}nets.push(row({id:'_tail',name:tr('The long tail ({n} small networks)',{n:NETS.filter(n=>n.tail).length}),asn:'many',type:'eye',col:'#8A93B8'},e,w));} for(let i=nets.length-1;i>=0;i--)if(!(nets[i].t>0.01||nets[i].want>0.01))nets.splice(i,1); {const k=UI.dashSort||'traffic',dir=UI.dashDir||-1,val=x=>k==='name'?x.n.name.toLowerCase():k==='asn'?x.n.asn:k==='type'?x.n.type:k==='cost'?x.cost:k==='lost'?x.lost:x.t;nets.sort((a,b)=>{const A=val(a),B=val(b);return (AB?1:0)*dir||b.t-a.t;});} - h+=custSection(); - h+=connSection(); - h+=`

${tr('Traffic by network (ASN)')}

${tr("Where your users' traffic comes from, and how it gets to you. Transit is the only part you pay per gigabit; caches, PNIs and IX peering are free or flat-rate. Tap a column to sort.")}

${['c','p','ix','t'].map(k=>`${EGC[k][0]}`).join('')}
${[['name',tr('Network'),''],['asn','AS',''],['type',tr('Type'),''],['traffic',tr('Traffic'),'r'],['mix',tr('How it arrives'),''],['cost',tr('Transit cost'),'r'],['lost',tr('Lost'),'r']].map(([k,l,c])=>``).join('')} + if(DT==='cust')h+=custSection(); + if(DT==='conn')h+=connSection(); + if(DT==='traffic')h+=`

${tr('Traffic by network (ASN)')}

${tr("Where your users' traffic comes from, and how it gets to you. Transit is the only part you pay per gigabit; caches, PNIs and IX peering are free or flat-rate. Tap a column to sort.")}

${['c','p','ix','t'].map(k=>`${EGC[k][0]}`).join('')}
${k==='mix'?l:``}
${[['name',tr('Network'),''],['asn','AS',''],['type',tr('Type'),''],['traffic',tr('Traffic'),'r'],['mix',tr('How it arrives'),''],['cost',tr('Transit cost'),'r'],['lost',tr('Lost'),'r']].map(([k,l,c])=>``).join('')} ${nets.map(({n,e,t,want})=>{return ``;}).join('')}
${k==='mix'?l:``}
${logo(n)}${esc(n.name)}${n.asn}${TYPE_L[n.type]}${fmtG(t)}
${['c','p','ix','t'].map(k=>``).join('')}
${e.t>0.01?tr('{price}/mo',{price:fmt$((R.cost.transit||0)*e.t/tT)}):'—'}${want>0.01?pct(Math.max(0,1-t/want)):'—'}
`; - {const top=transitTop(S.transit.map(t=>t.id),8);if(top.length)h+=`

${tr('Who your transit carries')}

${tr('The networks you pay transit to reach, biggest first, and the cheapest way to move each one to peering. This is your to-do list on the way to Tier 1.')}

${top.map(([id,v])=>`
${logo(NET[id])}
${esc(NET[id].name)} AS${NET[id].asn} · ${fmtG(v)} · ${tr('about {price}/mo',{price:fmt$((R.cost.transit||0)*v/tT)})}
${esc(offTransitHint(id))}
`).join('')}
`;} + if(DT==='traffic'){const top=transitTop(S.transit.map(t=>t.id),8);if(top.length)h+=`

${tr('Who your transit carries')}

${tr('The networks you pay transit to reach, biggest first, and the cheapest way to move each one to peering. This is your to-do list on the way to Tier 1.')}

${top.map(([id,v])=>`
${logo(NET[id])}
${esc(NET[id].name)} AS${NET[id].asn} · ${fmtG(v)} · ${tr('about {price}/mo',{price:fmt$((R.cost.transit||0)*v/tT)})}
${esc(offTransitHint(id))}
`).join('')}
`;} const ls=S.links.filter(l=>capOf(l)>0).map(l=>({l,u:(R.load[l.id]||0)/capOf(l)})).sort((a,b)=>b.u-a.u).slice(0,8); const rs=Object.keys(S.pops).map(c=>({c,u:(R.nodeLoad[c]||0)/(R.nodeCap[c]||1)})).sort((a,b)=>b.u-a.u).slice(0,6); - h+=`

${tr('Busiest links')}

${ls.length?ls.map(({l,u})=>`
${CITY[l.a].name} ⇄ ${CITY[l.b].name} ${capName(l)} · ${linkLat(l).toFixed(1)} ms
${pct(u)}${btn(tr('Open'),'dashLink',{id:l.id},'ghost sm')}
`).join(''):'

'+tr('No links yet.')+'

'}
+ if(DT==='infra')h+=`

${tr('Busiest links')}

${ls.length?ls.map(({l,u})=>`
${CITY[l.a].name} ⇄ ${CITY[l.b].name} ${capName(l)} · ${linkLat(l).toFixed(1)} ms
${pct(u)}${btn(tr('Open'),'dashLink',{id:l.id},'ghost sm')}
`).join(''):'

'+tr('No links yet.')+'

'}

${tr('Router load')}

${rs.map(({c,u})=>`
${CITY[c].name} ${(S.pops[c].routers||1)} × ${esc(RG[S.pops[c].rgen||0].n)}
${pct(u)}
`).join('')}

${tr('Your AS')}

${tr('AS number')}AS${S.asn}
${tr('Prefixes')}${Math.max(1,Math.ceil(Object.keys(S.pops).length/3))} × /22 IPv4, 1 × /32 IPv6
${tr('BGP sessions')}${R.sessions}
${tr('Upstreams')}${new Set(S.transit.map(t=>t.net)).size}
${tr('Reach')}${pct(R.reach)}
${tr('Customers')}${tr('{n} businesses',{n:S.biz.length})}
`; if(h!==UI._dh){UI._dh=h;$('dashCard').innerHTML=h;} diff --git a/tests/issues.test.js b/tests/issues.test.js index a2024a9..3923613 100644 --- a/tests/issues.test.js +++ b/tests/issues.test.js @@ -164,7 +164,7 @@ test('rare badges hook into incidents and deals', () => { test('#7 NOC legend, sortable network table and transit destinations', () => { const { ev, errors } = load(); base(ev); - ev("ACT.buyTransit({city:'fra',net:'cog',tier:1});compute();ACT.dash()"); + ev("ACT.buyTransit({city:'fra',net:'cog',tier:1});compute();ACT.dash();ACT.dashTab({k:'traffic'})"); let t = ev("document.getElementById('dashCard').textContent"); assert.match(t, /Who your transit carries/); assert.match(t, /IX peering/, 'legend explains the colours'); diff --git a/tests/modes.test.js b/tests/modes.test.js index 7757378..f45b0bc 100644 --- a/tests/modes.test.js +++ b/tests/modes.test.js @@ -252,3 +252,44 @@ test('the installed app and desktop browsers start straight away', () => { assert.deepEqual(errors, []); } }); + +test('#34 scenario goal, progress and customer level are always in view', () => { + const { ev, dom, errors } = load(); + ev("ACT.startScn({id:'darien',sure:1})"); + 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(), /days left/); + assert.match(left(), /Customer level 1 of 4/); + 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()"); + 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/); + // every scenario has measurable progress + for (const id of JSON.parse(ev("JSON.stringify(SCN.filter(s=>s.ok).map(s=>s.id))"))) { + ev(`ACT.startScn({id:'${id}',sure:1})`); + const P = JSON.parse(ev('JSON.stringify(scnProg())')); + assert.ok(P && P.items.length > 0, `${id} shows progress`); + } + ev('ACT.startWeekly({sure:1})'); + assert.match(ev('scnCard()'), /score/); + assert.deepEqual(errors, []); +}); + +test('NOC dashboard has a tab bar for its sections', () => { + const { ev, errors } = load(); + ev("ACT.start({});ACT.dash()"); + const card = () => ev("document.getElementById('dashCard').textContent"); + assert.match(card(), /Traffic by way out/); + assert.doesNotMatch(card(), /Busiest links/); + for (const [k, re] of [['cust', /Customers/], ['conn', /Every port that connects/], ['traffic', /Traffic by network/], ['infra', /Busiest links/]]) { + ev(`ACT.dashTab({k:'${k}'})`); + assert.match(card(), re, k); + } + ev("ACT.dashTab({k:'nope'})"); + assert.equal(ev('UI.dtab'), 'infra', 'unknown tabs are ignored'); + assert.deepEqual(errors, []); +});