Fit the left tabs on small screens; move routing settings into a modal
The left panel's four tabs overflowed its 272px width on tablets and small laptops: Goals wrapped its count, Networks ran off the edge. Counts now sit on the tab's corner, labels stay on one line and shrink last. Backbone, Auto-TE and DDoS settings sat below every notification in the NOC tab. A Routing & DDoS button at the top opens them in a modal that redraws in place after each action, with a red dot when Auto-TE is paused.
This commit is contained in:
parent
4a66bbf998
commit
3048c18b14
19 changed files with 110 additions and 17 deletions
|
|
@ -160,7 +160,7 @@ test('the backbone panel and the router panels, on a phone too', () => {
|
|||
for (const w of [1280, 360]) {
|
||||
const { ev, dom, errors } = load();
|
||||
ev("ACT.start({});if(UI.pendGame)ACT.pitchSkip()");
|
||||
ev(`window.innerWidth=${w};` + start.replace('ACT.start({});', '') + `;ACT.buildPop({city:'ams'});S.pops.fra.rgen=${g('Disco 8K')};ACT.coreUp();ACT.coreUp();ACT.leftTab({t:'noc'});renderAll()`);
|
||||
ev(`window.innerWidth=${w};` + start.replace('ACT.start({});', '') + `;ACT.buildPop({city:'ams'});S.pops.fra.rgen=${g('Disco 8K')};ACT.coreUp();ACT.coreUp();ACT.leftTab({t:'noc'});ACT.routingOpen();renderAll()`);
|
||||
const txt = dom.window.document.body.textContent;
|
||||
assert.match(txt, /RSVP-TE\/MPLS/, `${w}px`);
|
||||
assert.match(txt, /outside the backbone/, 'Amsterdam is left out');
|
||||
|
|
|
|||
|
|
@ -170,12 +170,12 @@ test('saves before 2.2 load: an attack on a city finds its target, and an IX bla
|
|||
|
||||
test('the NOC card fits a phone and the sandbox can send a test flood', () => {
|
||||
const { ev, errors, dom } = load();
|
||||
ev("beginGame('T','fra',{mode:'sandbox',preset:'sandbox'});if(UI.pendGame)ACT.pitchSkip();ACT.launchBB({city:'fra'});ACT.buyTransit({city:'fra',net:'cog',tier:1});UI.left='noc';renderLeft()");
|
||||
const b = dom.window.document.querySelector('[data-act=ddosTest]');
|
||||
ev("beginGame('T','fra',{mode:'sandbox',preset:'sandbox'});if(UI.pendGame)ACT.pitchSkip();ACT.launchBB({city:'fra'});ACT.buyTransit({city:'fra',net:'cog',tier:1});UI.left='noc';renderLeft();ACT.routingOpen()");
|
||||
const b = dom.window.document.querySelector('#modal [data-act=ddosTest]');
|
||||
assert.ok(b, 'a test flood button in Sandbox');
|
||||
b.click();
|
||||
assert.equal(ev('ddosAll().length'), 1);
|
||||
ev("UI.left='noc';renderLeft()");
|
||||
ev("closeModal();UI.left='noc';renderLeft()");
|
||||
const card = dom.window.document.querySelector('#left .inc.ddos');
|
||||
assert.ok(card, 'the card is shown');
|
||||
assert.ok(card.querySelectorAll('.btns').length <= 2, 'one suggestion, the rest behind More');
|
||||
|
|
|
|||
|
|
@ -290,7 +290,8 @@ test('notifications: the NOC keeps the last ten minutes, folds repeats and opens
|
|||
ev("UI.left='noc';UI.leftOpen=true;UI.sel=null;renderLeft();renderHUD()");
|
||||
const body = doc.getElementById('leftBody').textContent;
|
||||
assert.match(body, /Notifications\s*last 10 minutes/);
|
||||
assert.ok(body.indexOf('Notifications') < body.indexOf('DDoS scrubbing'), 'near the top, not at the bottom');
|
||||
assert.ok(body.indexOf('Notifications') < body.indexOf('Incidents so far'), 'near the top, not at the bottom');
|
||||
assert.doesNotMatch(body, /DDoS scrubbing/, 'the settings moved to Routing & DDoS');
|
||||
assert.match(body, /×5/); assert.match(body, /just now/);
|
||||
assert.equal(doc.querySelectorAll('#leftBody [data-act=logOpen]').length, 2, 'Open only where it leads somewhere (2 of the 5 shown)');
|
||||
assert.equal(ev("logUnread()"), 0);
|
||||
|
|
|
|||
|
|
@ -992,7 +992,7 @@ test('#63 incidents you can fix with one click sit above hot ports in the NOC',
|
|||
assert.ok(fix >= 0 && hot >= 0 && free >= 0, 'all three are shown');
|
||||
assert.ok(fix < hot, 'the paid fix comes before the hot ports');
|
||||
assert.ok(fix < free, 'and before incidents without a fix');
|
||||
assert.ok(t.indexOf('DDoS scrubbing') > fix, 'status lines come after the incidents');
|
||||
assert.ok(t.indexOf('Incidents so far') > fix, 'status lines come after the incidents');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
|
|
|
|||
45
tests/routing-modal.test.js
Normal file
45
tests/routing-modal.test.js
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const { load } = require('./harness');
|
||||
|
||||
const start = "ACT.start({});if(UI.pendGame)ACT.pitchSkip();S.cash=1e8;S.lvl=4;S.nextFail=1e9;S.nextEvent=1e9;ACT.launchBB({city:'fra'})";
|
||||
|
||||
test('the backbone, Auto-TE and DDoS settings open from a button at the top of the NOC tab', () => {
|
||||
const { ev, dom, errors } = load();
|
||||
const doc = dom.window.document;
|
||||
ev(start + ";UI.left='noc';UI.leftOpen=true;UI.sel=null;renderLeft()");
|
||||
const left = doc.getElementById('leftBody');
|
||||
const b = left.querySelector('[data-act=routingOpen]');
|
||||
assert.ok(b, 'the button is there');
|
||||
assert.ok(left.querySelector('.btns').contains(b), 'in the first row of buttons, above the notifications');
|
||||
assert.doesNotMatch(left.textContent, /Auto-RTBH|Install Auto-TE/, 'the settings no longer sit in the tab');
|
||||
b.click();
|
||||
assert.equal(ev("$('modal').hidden"), false);
|
||||
const m = () => doc.getElementById('modalCard').textContent;
|
||||
assert.match(m(), /Routing & DDoS/);
|
||||
assert.match(m(), /Backbone/); assert.match(m(), /Auto-TE/); assert.match(m(), /Auto-RTBH: off/);
|
||||
// An action inside redraws the modal in place.
|
||||
doc.querySelector('#modalCard [data-act=ddosAuto]').click();
|
||||
assert.equal(ev('S.ddosAuto.rtbh'), true);
|
||||
assert.match(m(), /Auto-RTBH: on/);
|
||||
doc.querySelector('#modalCard [data-act=coreUp]').click();
|
||||
assert.equal(ev('S.core.lv'), 1);
|
||||
assert.equal(ev("$('modal').hidden"), false, 'still open after buying');
|
||||
assert.ok(doc.querySelector('#modalCard [data-act=coreSet]'), 'with the new level to pick');
|
||||
// Other modals are left alone.
|
||||
ev("closeModal();ACT.opsOpen()");
|
||||
assert.doesNotMatch(m(), /Auto-RTBH/);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('a paused Auto-TE shows on the button, and the modal works on a phone', () => {
|
||||
const { ev, dom, errors } = load();
|
||||
ev("window.innerWidth=360;" + start + ";S.te={on:true,day:S.day};S.core.run=0;UI.left='noc';UI.leftOpen=true;renderLeft()");
|
||||
const b = dom.window.document.querySelector('#leftBody [data-act=routingOpen]');
|
||||
assert.ok(b.querySelector('.cnt.dot'), 'a red dot when Auto-TE is paused');
|
||||
ev('ACT.routingOpen()');
|
||||
assert.match(dom.window.document.getElementById('modalCard').textContent, /Auto-TE is paused/);
|
||||
ev("closeModal();S.core.run=S.core.lv=2;renderLeft()");
|
||||
assert.equal(dom.window.document.querySelector('#leftBody [data-act=routingOpen] .cnt'), null);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue