- Upgrades take effect: the optic speed cache from #89 is now kept per cable state (subsea, terminals in service, engineering in service), so a cable no longer stays at 400G after both upgrades are commissioned. - Refunds: a cable remembers what was paid for it, design and upgrades included. Calling off a 7x low-latency cable returned 10% of its price. 'Unusable' now means no optic lights it even with both upgrades. - Length limit: #88 counts the shortest design and both upgrades. The order screen says which upgrade a route needs and will not order without it; the order action checks the same. New York to Sydney needs terminals. No leased-wave payback hint where no leased wave reaches. - Choices start fresh when you open the own-cable view and after ordering. - The 'consider terminals or engineering' hint only on cables you own. - Low-latency builds take 1.7x as long (London-New York ~2.9 years), not 3.5x; optimized 1.3x. Each design is one tappable card. - The low-latency factor is worked out once per route instead of on every latency lookup. 'Number.isFinite' alone, no repeated guard in seaQuote, the express factor folded into seaLatencyFactor, '+{n} days' as one translatable string. - Portuguese and French for the new strings; one CHANGELOG bullet (#65). Big network vs main: no slowdowns, identical routing.
This commit is contained in:
parent
e76d68fc90
commit
6ddbc6ec7d
7 changed files with 120 additions and 25 deletions
|
|
@ -1058,7 +1058,11 @@ test('#104 declining a loan offer clears the bank badge while paused', () => {
|
|||
test('#88 no subsea cable longer than any optic can light, and a refund for calling one off', () => {
|
||||
const { ev, errors } = load();
|
||||
ev("ACT.start({});S.cash=1e10;S.lvl=13;S.won=true;for(const g of GOALS)S.done[g.id]=0");
|
||||
assert.match(ev("ownCabWhy('nyc','syd')"), /more than any optic can light/);
|
||||
// New York to Sydney is too long for plain optics; since #78 premium terminals light it, so the order screen asks
|
||||
// for them instead of refusing. Only a length beyond even both upgrades is refused.
|
||||
assert.equal(ev("ownCabWhy('nyc','syd')"), '');
|
||||
assert.deepEqual(JSON.parse(ev("JSON.stringify(subNeed(ownCabKm('nyc','syd')))")), ['terminal']);
|
||||
assert.equal(ev('subNeed(26000)'), null, 'nothing lights 26,000 km');
|
||||
assert.equal(ev("ownCabWhy('lax','syd')"), '', 'Los Angeles to Sydney still works');
|
||||
assert.ok(ev("subCarrier(ownCabKm('lax','syd'))") > 0);
|
||||
// half-way through laying it: most of the unlaid part comes back
|
||||
|
|
@ -1071,7 +1075,9 @@ test('#88 no subsea cable longer than any optic can light, and a refund for call
|
|||
assert.equal(ev('S.cash') - c0, want);
|
||||
// a finished cable that works is yours for good; one nothing can light (old saves) goes back in full
|
||||
assert.equal(ev("cabBack({kind:'df',own:true,sub:true,km:ownCabKm('lax','syd'),ready:0})"), 0);
|
||||
assert.equal(ev("cabBack({kind:'df',own:true,sub:true,km:18387,ready:0})"), ev('ownCabCost(18387)'));
|
||||
assert.equal(ev("cabBack({kind:'df',own:true,sub:true,km:26000,ready:0})"), ev('ownCabCost(26000)'));
|
||||
assert.equal(ev("cabBack({kind:'df',own:true,sub:true,km:26000,ready:0,paid:5e8})"), 5e8, 'what was really paid');
|
||||
assert.equal(ev("cabBack({kind:'df',own:true,sub:true,km:18387,ready:0})"), 0, 'a finished cable upgrades can light is yours for good');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -648,7 +648,8 @@ test('subsea cable designs trade construction cost and time for previewed latenc
|
|||
const quotes = JSON.parse(ev("JSON.stringify(['standard','optimized','express'].map(d=>seaQuote('lon','nyc',d)))"));
|
||||
assert.ok(quotes[0].ms > quotes[1].ms && quotes[1].ms > quotes[2].ms);
|
||||
assert.ok(quotes[1].cost >= quotes[0].cost * 3 && quotes[2].cost >= quotes[0].cost * 7);
|
||||
assert.ok(quotes[1].days >= quotes[0].days * 2 && quotes[2].days >= quotes[0].days * 3.5);
|
||||
assert.ok(quotes[1].days >= quotes[0].days * 1.3 && quotes[2].days >= quotes[0].days * 1.7);
|
||||
assert.ok(quotes[2].days < 3 * 365, 'a low-latency Atlantic cable takes years, not most of a decade');
|
||||
assert.equal(quotes[2].ms, ev("Math.min(...cablesFor('lon','nyc').map(c=>linkLat({kind:'wave',km:c.km,cable:c.cid})))"), 'express competes with Hibernia');
|
||||
for (const q of quotes) assert.ok(dom.window.document.getElementById('modalCard').textContent.includes(q.ms.toFixed(1) + ' ms one-way'), 'every latency is visible before ordering');
|
||||
for (const [i, design] of ['standard', 'optimized', 'express'].entries()) {
|
||||
|
|
@ -765,3 +766,45 @@ test('submarine upgrades reject invalid purchases and preserve baseline and terr
|
|||
assert.deepEqual(errors, []);
|
||||
} finally { dom.window.close(); }
|
||||
});
|
||||
|
||||
test('own subsea cables after #78: refunds of what was paid, upgrades a route needs, fresh choices', () => {
|
||||
const { ev, errors } = load();
|
||||
ev("ACT.start({});S.cash=1e11;S.lvl=13;S.won=true;for(const g of GOALS)S.done[g.id]=0;for(const c of ['lon','nyc','syd'])if(!S.pops[c])ACT.buildPop({city:c})");
|
||||
const open = (a, b) => ev(`UI.pending=null;openLinkModal('${a}','${b}');ACT.ownCab()`);
|
||||
const q = (sel) => ev(`(()=>{const e=document.querySelector('#modalCard ${sel}');return e?e.textContent:null;})()`);
|
||||
// a low-latency cable called off at once returns 75% of what it really cost, not of a standard cable
|
||||
open('lon', 'nyc');
|
||||
assert.equal(ev("document.querySelectorAll('#modalCard button.start[data-act=seaDesign]').length"), 3, 'each design is one tappable card');
|
||||
ev("document.querySelector('#modalCard [data-act=seaDesign][data-args*=express]').click()");
|
||||
assert.match(q('button.start.on'), /Low latency/);
|
||||
const c0 = ev('S.cash'); ev('ACT.orderCable()');
|
||||
const lon = JSON.parse(ev("JSON.stringify(S.links.at(-1))")), paid = c0 - ev('S.cash');
|
||||
assert.equal(lon.seaDesign, 'express'); assert.equal(lon.paid, paid);
|
||||
assert.equal(ev('cabBack(S.links.at(-1))'), Math.round(paid * 0.75));
|
||||
assert.equal(ev('UI.seaDesign'), 'standard', 'the next order starts from the standard design');
|
||||
// its latency is worked out once per route, and stays the same
|
||||
const ms = ev('linkLat(S.links.at(-1))'); assert.equal(ev('linkLat(S.links.at(-1))'), ms); assert.ok(ev('SEA_XF.size') >= 1);
|
||||
// New York to Sydney needs premium terminals: the screen says so and will not order without them
|
||||
open('nyc', 'syd');
|
||||
assert.match(q('.why'), /Add Premium submarine terminals/);
|
||||
assert.doesNotMatch(ev("document.getElementById('modalCard').textContent"), /A leased .* wave on this route/, 'no leased wave reaches that far, so no comparison with one');
|
||||
assert.equal(ev("document.querySelector('#modalCard [data-act=orderCable]').disabled"), true);
|
||||
const n = ev('S.links.length'); ev('ACT.orderCable()'); assert.equal(ev('S.links.length'), n, 'the order itself checks too');
|
||||
ev("document.querySelector('#modalCard [data-act=seaPackage][data-args*=terminal]').click()");
|
||||
assert.equal(q('.why'), null); assert.match(q('[data-act=seaPackage][data-args*=terminal]'), /\+30 days/);
|
||||
// leaving and coming back to another route starts fresh
|
||||
open('lon', 'nyc'); assert.equal(ev('!!UI.seaterminal'), false);
|
||||
open('nyc', 'syd'); ev("document.querySelector('#modalCard [data-act=seaPackage][data-args*=terminal]').click();ACT.orderCable()");
|
||||
const syd = JSON.parse(ev("JSON.stringify(S.links.at(-1))"));
|
||||
assert.equal(syd.b, 'syd'); assert.equal(syd.subterminal, syd.ready);
|
||||
ev('S.day=S.links.at(-1).ready'); assert.equal(ev("optG('tp16',S.links.at(-1))"), 400, 'lit across 18,387 km');
|
||||
// upgrades bought later count toward the price; sanitize keeps a sane price and drops junk
|
||||
ev("S.links.at(-1).subengineering=undefined;ACT.subUpgrade({id:S.links.at(-1).id,k:'engineering'})");
|
||||
assert.ok(ev('S.links.at(-1).paid') > syd.paid);
|
||||
ev("S.links.at(-1).paid='lots';S.links[0].paid=-5;S=sanitize(S)");
|
||||
assert.equal(ev('S.links.at(-1).paid'), undefined); assert.equal(ev('S.links[0].paid'), undefined);
|
||||
// advice about upgrades only on cables you own
|
||||
ev("S.links.push({id:'iru',a:'lon',b:'nyc',kind:'df',own:false,sub:true,km:30000,sys:'roadm',ch:[],ready:0,cut:0,mo:1})");
|
||||
assert.doesNotMatch(ev("chWhy(S.links.at(-1),'tp16')"), /submarine terminals/);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue