Some checks are pending
CI / plan (push) Waiting to run
CI / part (push) Blocked by required conditions
CI / build (push) Waiting to run
CI / translations (push) Waiting to run
CI / test (push) Blocked by required conditions
CI / timings (push) Blocked by required conditions
Container image / gate (push) Waiting to run
Container image / test (push) Blocked by required conditions
Container image / publish (push) Blocked by required conditions
Conflicts, file by file:
- CHANGELOG.md: the fork's Unreleased bullets on top; 3.5.0 and 3.4.0 exactly as upstream has them.
- src/i18n/en.js, site/i18n/{de,es,fr,it,pt}.js: merged label by label, sorted; the labels each side dropped stay dropped.
- src/agent/10-domains.js, 30-docs.js, 40-read.js: both sides' enums, state docs and tables (popStd as the build standard, popTiers, ip4, mp).
- src/agent/20-commands.js: the fork's wording on accept and upRouter, upstream's acceptFix, utilityKitAll/New and pt*; theme, session and transfer acts in the local table.
- src/game/60-features/80-new-game.js: ip4, rgen and mp next to popTiers.
- src/game/80-simulation/29-route-core.js, 30-compute.js: the route core takes both SATN and the spill tiers (TT).
- src/game/80-simulation/40-billing.js: upstream's gulfPair and borderShut; linkCut() is built on borderShut, linkDown() keeps express and satellite.
- src/game/80-simulation/50-sanitize.js: PNI bundles up to PNI_LAG_MAX next to the fork's link kinds; popStdSanitize then ptSanitize; mpSanitize then lcSanitize.
- src/game/80-simulation/75-customer-lifecycle.js: clGrow() stops at a type's most (#137) and at an IPv4 block that is not free (#150).
- src/game/90-actions/60-links.js: rmLink keeps the express guard and moves on to the next parallel link (#119).
- src/game/90-actions/85-routing-and-routers.js: rmRouter checks the PNIs on its routers (#323), upRouter keeps own().
- src/game/90-actions/89-game-and-settings.js: the menu keeps the build standard and session tiles and gains Send to another device.
- src/game/93-ui/40-hud-and-panels.js, 70-link-panels.js: offers show both the IPv4 note and Buy and sign; link headers name their cities, the closed-border section reads in dark mode; the express count stays.
- src/game/93-ui/50-city-panel.js: the teleport section and Link to a city.
- src/game/94-dashboard/40-connections.js: upstream's per-table next port size replaces the fork's own 400G guard.
- src/game/94-dashboard/90-noc-window.js, 96-map/95-clicks.js, 99-loop.js: both sides' acts and boot steps.
- src/styles/40-modal.css: the dark-mode tag tokens and the transfer textarea.
- tests/mcp-commands.test.js: both sides' sample args.
Interaction fixes:
- POP standards and the build standard: a POP marked as a kind keeps its kind's routers (ptKind). The build
standard's router jobs and the intern's model swaps leave it alone; every other target still applies. Both sheets say so.
- Spill tiers: pathMs() fills a path's ground latency and satellite edges too, so a tier's detour costs users its
latency (it went uncharged before).
- Send to another device: a session network goes by the session's own #mp= link; its save file is called a copy.
- Buy and sign (#241) does not buy for an offer whose IPv4 block does not fit.
- Dark mode: the closed-border title and the renewal ticks use the dark-aware red (upstream's #292 test follows).
- Server-run tables: the new acts classified (pt*, acceptFix and utilityKitAll quote their cost); mp-sim fixtures
written again with tests/lib/mp-sim-fixtures.js.
Review fixes:
- POP standards: ptSave, ptApply, ptPlan, ptAll and popStdSet find a POP with own(), so 'toString' is no POP (also
decomToggle, decomGo, dkStay).
- Server-run envelope: an arg value that names anything on Object.prototype is refused, in args, drafts and
ctx.win.ui.
- Decommissioning a POP drops its POP-standard mark, so live state stays what a reload makes of it (the T2 gate
refused later pt* acts).
- acceptFix, ptApply, ptAll and utilityKitAll take a quote within 1% (quoteNear), like utilityKit and bstdApply:
router prices drift daily.
- The transfer paste box reads in dark mode (--text, as input.t).
- A session's #mp= link pasted under From another device opens it (saved, then loaded again with it), in MP builds.
- The express and satellite circuit panels name their cities as links (#196); a circuit shows the closed-border
section (#329).
- CHANGELOG: the fork's 400G connections bullet goes (3.5.0 ships it); bullets for POP kinds, the session link and Buy
and sign's IPv4 check.
261 lines
16 KiB
JavaScript
261 lines
16 KiB
JavaScript
// Late-game busywork: one policy or one button instead of many clicks, never a decision taken away.
|
|
// #316 the intern can leave new fiber dark, #119 the link panel stays open on a sibling, #317 the kit at every POP,
|
|
// #241 buy what a customer needs on signing, #315 POP standards by kind, #199 find a network at a POP.
|
|
const test = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const { load } = require('./harness');
|
|
const { lit } = require('../scripts/lib/js-literal');
|
|
|
|
function setup(t, extra = '') {
|
|
const h = load();
|
|
t.after(() => h.dom.window.close());
|
|
h.ev("ACT.start({});S.cash=1e8;for(const g of GOALS)S.done[g.id]=0;S.nextFail=S.nextEvent=1e9;UI.speed=0;compute();" + extra);
|
|
return h;
|
|
}
|
|
const doc = h => h.dom.window.document;
|
|
const text = (h, sel) => [...doc(h).querySelectorAll(sel)].map(e => e.textContent).join('\n');
|
|
const reload = ev => ev("save();S=migrate(JSON.parse(slotRaw(UI.slot)));compute()");
|
|
|
|
/* ---------- #316: new fiber stays dark when the player says so ---------- */
|
|
const FIBER = "S.lvl=4;S.rules=makeRules('freeze');ACT.launchBB({city:'fra'});S.pops.fra.rgen=2;ACT.buildPop({city:'ams'});S.pops.ams.rgen=2;compute();" +
|
|
"ACT.opsHire({id:'kevin'});S.ops.floor=0;closeModal();" +
|
|
"S.links.push({id:'f',a:'fra',b:'ams',kind:'df',sys:'roadm',ch:[],km:450,sub:false,ready:0,cut:0,mo:1,trench:'f'});compute();S.ops.on.optics=true;";
|
|
const ch = ev => JSON.parse(ev("JSON.stringify(S.links.find(l=>l.id==='f').ch)"));
|
|
|
|
test('#316 by default the intern still lights new fiber, also in a save from before the switch', t => {
|
|
const { ev, errors } = setup(t, FIBER);
|
|
assert.equal(ev("opsP('optics','fresh')"), true);
|
|
ev("S.ops.p.optics={}");
|
|
reload(ev);
|
|
assert.equal(ev("opsP('optics','fresh')"), true, 'an old save has no setting: the old behaviour');
|
|
ev('opsDay(S.day)');
|
|
assert.ok(ch(ev).length > 0);
|
|
assert.deepEqual(errors, []);
|
|
});
|
|
|
|
test('#316 told not to, the intern leaves new fiber dark but still grows hot lit fiber', t => {
|
|
const { ev, errors } = setup(t, FIBER);
|
|
ev("ACT.opsOpen();ACT.opsParam({k:'optics',p:'fresh',v:1})");
|
|
assert.equal(ev("opsP('optics','fresh')"), false);
|
|
ev('opsDay(S.day)');
|
|
assert.deepEqual(ch(ev), [], 'dark fiber stays dark');
|
|
ev("S.links.find(l=>l.id==='f').ch=['zr8'];compute();R.load.f=dfCap(S.links.find(l=>l.id==='f'))*0.95;opsDay(S.day)");
|
|
assert.ok(ch(ev).length > 1, 'a lit, hot fiber still gets more optics');
|
|
reload(ev);
|
|
assert.equal(ev("opsP('optics','fresh')"), false, 'the switch survives a reload');
|
|
ev("S.ops.p.optics.fresh='maybe';S=migrate(JSON.parse(JSON.stringify(S)))");
|
|
assert.equal(ev("opsP('optics','fresh')"), true, 'a bad value is repaired to the default');
|
|
assert.deepEqual(errors, []);
|
|
});
|
|
|
|
test('#316 the switch is in the Ops sheet', t => {
|
|
const h = setup(t, FIBER);
|
|
h.ev('ACT.opsOpen()');
|
|
assert.match(h.ev("document.getElementById('modalCard').textContent"), /Light new fiber/);
|
|
assert.deepEqual(h.errors, []);
|
|
});
|
|
|
|
/* ---------- #119: decommissioning one of several waves keeps the panel open ---------- */
|
|
test('#119 the link panel moves on to the next parallel link, and closes after the last', t => {
|
|
const h = setup(t, "ACT.buildPop({city:'ams'});" +
|
|
"for(const id of ['w1','w2','w3'])S.links.push({id,a:'fra',b:'ams',kind:'wave',tier:0,km:450,sub:false,cut:0,mo:1000});compute();UI.sel={type:'link',id:'w1'};renderAll()");
|
|
const { ev, errors } = h;
|
|
ev("ACT.rmLink({id:'w1'});ACT.rmLink({id:'w1'})");
|
|
assert.equal(ev("S.links.some(l=>l.id==='w1')"), false);
|
|
assert.equal(ev('JSON.stringify(UI.sel)'), JSON.stringify({ type: 'link', id: 'w2' }));
|
|
assert.equal(ev("document.getElementById('panel').hidden"), false, 'the panel is still open');
|
|
ev("ACT.rmLink({id:'w2'});ACT.rmLink({id:'w2'})");
|
|
assert.equal(ev('UI.sel.id'), 'w3');
|
|
ev("ACT.rmLink({id:'w3'});ACT.rmLink({id:'w3'})");
|
|
assert.equal(ev('UI.sel'), null, 'the last link closes it');
|
|
assert.deepEqual(errors, []);
|
|
});
|
|
|
|
/* ---------- #317: the redundancy kit at every POP ---------- */
|
|
const POPS = "for(const c of ['ams','lon','par'])ACT.buildPop({city:c});compute();";
|
|
test('#317 one button kits every POP, at the sum of the per-POP quotes', t => {
|
|
const { ev, errors } = setup(t, POPS + 'S.lvl=2;');
|
|
const q = JSON.parse(ev('JSON.stringify(utilityKitAll())'));
|
|
assert.equal(q.cities.length, 4);
|
|
assert.equal(q.cost, ev("Object.keys(S.pops).reduce((a,c)=>a+utilityKit(c).cost,0)"));
|
|
ev("ACT.utilities({})");
|
|
assert.match(ev("document.getElementById('modalCard').textContent"), /Kit all 4 POPs/);
|
|
const cash = ev('S.cash');
|
|
ev(`ACT.utilityKitAll({cost:${Math.round(q.cost * 0.9)}})`);
|
|
assert.equal(ev('S.cash'), cash, 'a stale quote buys nothing');
|
|
assert.match(ev("document.getElementById('modalCard').textContent"), /quote changed/);
|
|
ev(`ACT.utilityKitAll({cost:${q.cost}})`);
|
|
assert.equal(ev('S.cash'), cash - q.cost);
|
|
assert.equal(ev("Object.values(S.pops).every(p=>p.gen&&p.site2&&p.routers>=2)"), true);
|
|
assert.match(ev("document.getElementById('modalCard').textContent"), /Every POP has the full kit/);
|
|
assert.deepEqual(errors, []);
|
|
});
|
|
|
|
test('#317 needs level 2, never spends what is not there, and can put the kit in the intern\'s template', t => {
|
|
const { ev, errors } = setup(t, POPS);
|
|
ev('S.lvl=1;ACT.utilities({})');
|
|
assert.equal(ev('utilityKitAll()'), null);
|
|
assert.doesNotMatch(ev("document.getElementById('modalCard').textContent"), /Redundancy kit everywhere/);
|
|
ev('S.lvl=2;window.q=utilityKitAll().cost;S.cash=q-1;ACT.utilityKitAll({cost:q})');
|
|
assert.equal(ev('S.cash'), ev('q-1'));
|
|
assert.equal(ev("Object.values(S.pops).some(p=>p.gen)"), false);
|
|
ev("S.cash=1e8;ACT.opsHire({id:'annie'});closeModal();S.ops.tpl.kit=false;ACT.utilities({})");
|
|
assert.match(ev("document.getElementById('modalCard').textContent"), /come without the kit/);
|
|
ev('ACT.utilityKitNew({})');
|
|
assert.equal(ev('S.ops.tpl.kit'), true);
|
|
assert.match(ev("document.getElementById('modalCard').textContent"), /get the kit too/);
|
|
assert.deepEqual(errors, []);
|
|
});
|
|
|
|
/* ---------- #241: buy what the customer asks for, on signing ---------- */
|
|
const OFFER = (reqs, extra = {}) => `ACT.buildPop({city:'ams'});S.offers.push(${lit({ id: 'o1', city: 'fra', city2: 'ams', name: 'Needy Corp', type: 'l2vpn', bw: 1, rate: 900, reqs, exp: 30, ...extra })});compute();`;
|
|
test('#241 the offer shows what is missing with its price, and one button buys it and signs', t => {
|
|
const h = setup(t, OFFER(['gen', 'routers']));
|
|
const { ev, errors } = h;
|
|
const q = JSON.parse(ev("JSON.stringify(reqFix(S.offers[0]))"));
|
|
assert.deepEqual(q.items.map(x => x.k + '@' + x.city), ['gen@fra', 'gen@ams', 'routers@fra']);
|
|
assert.equal(q.cost, ev("2*GEN_COST+routerCost(0,1)"));
|
|
ev("UI.left='deals';UI.leftOpen=true;window.innerWidth=390;renderAll()");
|
|
const card = text(h, '#left');
|
|
assert.match(card, /Missing: a backup generator in Frankfurt, a backup generator in Amsterdam, a second router in Frankfurt/);
|
|
assert.match(card, /Buy it and sign/);
|
|
assert.ok(doc(h).querySelector('[data-act="acceptFix"]'), 'the button is there on a phone');
|
|
const cash = ev('S.cash');
|
|
ev(`ACT.acceptFix({id:'o1',cost:${q.cost}})`);
|
|
assert.equal(ev('S.cash'), cash - q.cost);
|
|
assert.equal(ev("S.pops.fra.gen&&S.pops.ams.gen&&S.pops.fra.routers===2"), true);
|
|
assert.equal(ev("S.biz.some(b=>b.id==='o1')&&!S.offers.length"), true, 'signed');
|
|
assert.equal(ev("reqOk(S.biz.find(b=>b.id==='o1'))"), true, 'and every requirement is met');
|
|
assert.deepEqual(errors, []);
|
|
});
|
|
|
|
test('#241 never silent: a stale price, too little cash or a deal that cannot be signed buys nothing', t => {
|
|
const { ev, errors } = setup(t, OFFER(['metro']));
|
|
const cost = ev("reqFix(S.offers[0]).cost");
|
|
assert.equal(cost, ev('2*SITE2_COST'));
|
|
ev(`ACT.acceptFix({id:'o1',cost:${Math.round(cost * 0.9)}})`);
|
|
assert.equal(ev("!!S.pops.fra.site2||S.biz.length>0"), false);
|
|
ev(`S.cash=${cost - 1};ACT.acceptFix({id:'o1',cost:${cost}})`);
|
|
assert.equal(ev("!!S.pops.fra.site2||S.biz.length>0"), false);
|
|
ev(`S.cash=1e8;S.offers[0].city2='lon';ACT.acceptFix({id:'o1',cost:${cost}})`);
|
|
assert.equal(ev("!!S.pops.fra.site2||S.biz.length>0"), false, 'no POP in London: nothing is bought');
|
|
assert.equal(ev("reqFixHtml(S.offers[0])"), '');
|
|
ev("S.offers[0].city2='ams';S.offers[0].reqs=['nocog']");
|
|
assert.equal(ev("reqFix(S.offers[0])"), null, 'only hardware at a POP is offered');
|
|
assert.deepEqual(errors, []);
|
|
});
|
|
|
|
/* ---------- #315: POP standards by kind ---------- */
|
|
test('#315 save a standard, bring a POP up to it, then every POP of that kind at once', t => {
|
|
const h = setup(t, POPS + "S.lvl=4;S.pops.fra.routers=2;S.pops.fra.rgen=1;compute();");
|
|
const { ev, errors } = h;
|
|
ev("UI.sel={type:'city',id:'fra'};UI.tab='links';window.innerWidth=390;renderAll()");
|
|
assert.match(text(h, '#panel'), /POP standards/);
|
|
assert.match(text(h, '#panel'), /Regional hub/);
|
|
ev("ACT.ptSave({city:'fra',k:'medium'})");
|
|
assert.equal(ev("JSON.stringify(S.popTiers.def.medium)"), JSON.stringify({ g: 1, rt: 2 }));
|
|
assert.equal(ev('S.popTiers.at.fra'), 'medium');
|
|
const q = JSON.parse(ev("JSON.stringify(ptPlan('ams','medium'))"));
|
|
assert.deepEqual(q.steps, ['swap', 'add'], 'an empty POP swaps first, then adds');
|
|
const cash = ev('S.cash');
|
|
ev(`ACT.ptApply({city:'ams',k:'medium',cost:${q.cost}})`);
|
|
assert.equal(ev('S.cash'), cash - q.cost, 'charged exactly the quote');
|
|
assert.equal(ev("S.pops.ams.routers===2&&S.pops.ams.rgen===1&&S.popTiers.at.ams==='medium'"), true);
|
|
// The standard grows: one button brings both medium POPs up.
|
|
ev("S.pops.fra.routers=3;S.pops.fra.rgen=2;S.pops.fra.rupDay=-1;ACT.ptSave({city:'fra',k:'medium'});S.pops.fra.routers=2;S.pops.fra.rgen=1;S.pops.ams.rupDay=-1;compute()");
|
|
const A = JSON.parse(ev("JSON.stringify({n:ptAll('medium').todo.length,cost:ptAll('medium').cost})"));
|
|
assert.equal(A.n, 2);
|
|
ev('ACT.utilities({})');
|
|
assert.match(ev("document.getElementById('modalCard').textContent"), /Bring 2 POPs up/);
|
|
ev(`ACT.ptAll({k:'medium',cost:${A.cost}})`);
|
|
assert.equal(ev("['fra','ams'].every(c=>S.pops[c].routers===3&&S.pops[c].rgen===2)"), true);
|
|
assert.equal(ev("ptAll('medium').todo.length"), 0);
|
|
assert.deepEqual(errors, []);
|
|
});
|
|
|
|
test('#315 a busy lone router gets its partner before the swap, and never a step down', t => {
|
|
const { ev, errors } = setup(t, POPS + "S.lvl=4;ACT.launchBB({city:'ams'});S.popTiers.def.hub={g:2,rt:2};S.popTiers.def.micro={g:0,rt:1};compute();");
|
|
assert.deepEqual(JSON.parse(ev("JSON.stringify(ptPlan('ams','hub').steps)")), ['add', 'swap']);
|
|
ev("ACT.ptApply({city:'ams',k:'hub',cost:ptPlan('ams','hub').cost})");
|
|
assert.equal(ev("S.pops.ams.routers===2&&S.pops.ams.rgen===2"), true);
|
|
assert.equal(ev("S.inc.some(i=>i.type==='maint'&&i.ref==='ams')"), false, 'a rolling upgrade, no maintenance window');
|
|
assert.equal(ev("ptPlan('ams','micro')"), null, 'a smaller standard asks for nothing');
|
|
ev("ACT.ptApply({city:'ams',k:'micro',cost:0})");
|
|
assert.equal(ev("S.pops.ams.rgen===2&&S.pops.ams.routers===2&&S.popTiers.at.ams==='micro'"), true, 'only marked');
|
|
assert.deepEqual(errors, []);
|
|
});
|
|
|
|
test('#315 level 1 has no standards, and saves old and broken load', t => {
|
|
const h = setup(t, POPS);
|
|
const { ev, errors } = h;
|
|
ev("UI.sel={type:'city',id:'fra'};UI.tab='links';renderAll()");
|
|
assert.doesNotMatch(text(h, '#panel'), /POP standards/);
|
|
ev("ACT.ptSave({city:'fra',k:'micro'})");
|
|
assert.equal(ev('S.popTiers.def.micro'), null);
|
|
ev('delete S.popTiers;S=migrate(JSON.parse(JSON.stringify(S)))');
|
|
assert.equal(ev('JSON.stringify(S.popTiers)'), JSON.stringify({ def: { micro: null, medium: null, hub: null }, at: {} }));
|
|
ev("S.popTiers={def:{micro:{g:999,rt:2},hub:{g:1,rt:99},bogus:{g:1,rt:1}},at:{fra:'hub',ams:'nope',xyz:'micro',ber:'hub'}};S=migrate(JSON.parse(JSON.stringify(S)))");
|
|
assert.equal(ev('JSON.stringify(S.popTiers)'), JSON.stringify({ def: { micro: null, medium: null, hub: { g: 1, rt: ev('RMAX') } }, at: { fra: 'hub' } }));
|
|
assert.deepEqual(errors, []);
|
|
});
|
|
|
|
/* ---------- #199: find a network at a POP ---------- */
|
|
test('#199 search and connected-only filter the transit, exchange and PNI lists, on a phone', t => {
|
|
const h = setup(t, "S.lvl=4;ACT.buyTransit({city:'fra',net:'cog',tier:0});compute();window.innerWidth=390;UI.sel={type:'city',id:'fra'};UI.tab='up';renderAll()");
|
|
const { ev, errors } = h;
|
|
const rows = () => [...doc(h).querySelectorAll('#panel .row .nm')].map(e => e.textContent.trim());
|
|
const all = rows().length;
|
|
assert.ok(doc(h).getElementById('netQ'), 'the search box is there');
|
|
ev("ACT.netOnly()");
|
|
assert.equal(rows().length, 1);
|
|
assert.match(rows()[0], /Cogentle/);
|
|
ev("ACT.netClear()");
|
|
assert.equal(rows().length, all);
|
|
// Typing into the box filters as you go, and the box keeps focus and text.
|
|
ev("const i=document.getElementById('netQ');i.focus();i.value='goggle';i.dispatchEvent(new window.Event('input',{bubbles:true}))");
|
|
assert.equal(ev("document.activeElement.id"), 'netQ');
|
|
assert.equal(ev("UI.netQ"), 'goggle');
|
|
ev("UI.tab='peer';renderAll()");
|
|
const peer = rows();
|
|
assert.ok(peer.length > 0 && peer.every(r => /Goggle/.test(r)), peer.join(' | '));
|
|
ev("ACT.netFind({q:'zzzz'})");
|
|
assert.match(text(h, '#panel'), /No network here matches this filter/);
|
|
ev("ACT.netFind({q:String(NET.ggl.asn)})");
|
|
assert.match(text(h, '#panel'), /Goggle/, 'an AS number finds the network');
|
|
assert.deepEqual(errors, []);
|
|
});
|
|
|
|
/* ---------- a quote a day old: hardware prices drift, the plan does not ---------- */
|
|
// Under the market rule router prices move a little every day. On a server-run network the days go on while a window is
|
|
// open, so a price shown yesterday must still buy today when only that drift moved it (quoteNear: within 1%), as the
|
|
// redundancy kit at one POP and the build standard already do. A price a whole part away is still refused (above).
|
|
test('#315 #317 #241 a price shown the day before still buys, when only the day\'s hardware drift moved it', t => {
|
|
const { ev, errors } = setup(t, "closeModal();S.rules=makeRules('oncall');S.cash=1e9;S.lvl=7;S.offers=[];ACT.launchBB({city:'fra'});ACT.buyTransit({city:'fra',net:'cog',tier:1});" +
|
|
"for(const c of ['ams','par','ber','mad'])ACT.buildPop({city:c});for(const c of ['fra','ams','par','ber','mad']){S.pops[c].rgen=1;S.pops[c].routers=1;S.pops[c].gen=false;delete S.pops[c].site2;}" +
|
|
"S.day=500;S.hw={};compute();");
|
|
assert.equal(ev("rule('market')"), true);
|
|
const day = (f) => { const shown = ev(f); ev('S.day++;compute()'); const now = ev(f); assert.notEqual(now, shown, `${f} drifted`); assert.ok(ev(`quoteNear(${shown},${now})`)); return shown; };
|
|
// The redundancy kit everywhere (#317).
|
|
let shown = day('utilityKitAll().cost'), c0 = ev('S.cash');
|
|
ev(`ACT.utilityKitAll({cost:${shown},city:'ams'})`);
|
|
assert.ok(c0 - ev('S.cash') > 0, 'the kit everywhere');
|
|
assert.equal(ev("Object.values(S.pops).every(p=>p.gen&&p.site2&&p.routers>=2)"), true);
|
|
ev('closeModal()');
|
|
// A POP standard at one POP, then at every POP of the kind (#315).
|
|
ev("S.popTiers.def.medium={g:2,rt:3};S.popTiers.at.mad='medium';S.popTiers.at.ber='medium';compute()");
|
|
shown = day("ptPlan('par','medium').cost"); c0 = ev('S.cash');
|
|
ev(`ACT.ptApply({city:'par',k:'medium',cost:${shown}})`);
|
|
assert.ok(c0 - ev('S.cash') > 0 && ev('S.pops.par.rgen') === 2, 'one POP');
|
|
ev('S.pops.par.rupDay=-1;');
|
|
shown = day("ptAll('medium').cost"); c0 = ev('S.cash');
|
|
ev(`ACT.ptAll({k:'medium',cost:${shown},city:'ber'})`);
|
|
assert.ok(c0 - ev('S.cash') > 0, 'every POP of the kind');
|
|
assert.equal(ev("ptAll('medium').todo.length"), 0);
|
|
ev('closeModal()');
|
|
// Buy what an offer asks for, and sign (#241): a second router.
|
|
ev("S.pops.fra.routers=1;S.offers.push({id:'o1',city:'fra',name:'Pixel Palace',city2:'ams',type:'l2vpn',bw:1,rate:900,reqs:['routers'],exp:S.day+30});compute()");
|
|
shown = day('reqFix(S.offers[0]).cost'); c0 = ev('S.cash');
|
|
ev(`ACT.acceptFix({id:'o1',cost:${shown}})`);
|
|
assert.ok(c0 - ev('S.cash') > 0 && ev("S.biz.some(b=>b.id==='o1')"), 'bought and signed');
|
|
assert.deepEqual(errors, []);
|
|
});
|