NOC tab and Pie Control tidied for phones: Pie Control in the NOC top row, traceroute in Routing & DDoS, government money in the bank
- NOC tab: Pie Control is a button in the top row next to "Open NOC dashboard" (only once the rocket
company is unlocked) and replaces the Pie in the Sky card; a spat waiting for an answer keeps its card.
The Connections button is gone (it lives in the NOC dashboard), and the traceroute moved into the
Routing & DDoS modal as an entry that opens the unchanged traceroute modal.
- Government money (Rural Digital Pie Fund, Pitcairn grant, Ex-Im Pie Bank) is a section of the bank,
shown with a rocket company or anything of the fund's to show. pieGovOpen, the action the toasts use,
opens the bank there; pieTab({t:'gov'}) does too.
- Pie Control has four tabs (Traffic, Company, Launch, Dishes) in one segmented control that fits 360 px,
styled like the HUD's speed buttons. The Founder's posts and the orbit books moved into the Company tab,
newest three posts shown and the rest folded. A stale UI.pieTab of 'gov', 'book' or 'founder' falls back.
- Agent docs for pieGovOpen, pieTab, routingOpen and connOpen; the route fuzzer drops connOpen from the
NOC tab on both pages to stay in lockstep with main.
- Tests: tests/noc-panel-layout.test.js, and the pie tests follow the moves.
This commit is contained in:
parent
176a6995b1
commit
9d74873edb
22 changed files with 207 additions and 68 deletions
101
tests/noc-panel-layout.test.js
Normal file
101
tests/noc-panel-layout.test.js
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
// The NOC tab's top row (Pie Control next to the NOC dashboard), the traceroute inside Routing & DDoS, government money
|
||||
// in the bank, and Pie Control's four tabs as one segmented control. Seeded; state is set directly.
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const { load } = require('./harness');
|
||||
|
||||
const sandbox = "ACT.modeSet({m:'sandbox'});ACT.start({});if(UI.pendGame)ACT.pitchSkip();S.nextFail=1e9;S.nextEvent=1e9";
|
||||
const noc = "UI.started=true;UI.left='noc';UI.leftOpen=true;UI.sel=null;renderLeft()";
|
||||
const acts = (root) => [...root.querySelectorAll('[data-act]')].map((b) => b.dataset.act);
|
||||
|
||||
test('the NOC tab: Pie Control in the top row once unlocked, no Connections or Traceroute buttons', () => {
|
||||
const { dom, ev, errors } = load();
|
||||
const doc = dom.window.document;
|
||||
ev("window.innerWidth=360;ACT.start({});if(UI.pendGame)ACT.pitchSkip();ACT.launchBB({city:'fra'});" + noc);
|
||||
const top = () => acts(doc.querySelector('#leftBody .btns'));
|
||||
assert.deepEqual(top(), ['dash', 'routingOpen'], 'no rocket company yet: no Pie Control');
|
||||
assert.ok(!acts(doc.getElementById('leftBody')).includes('connOpen'), 'Connections lives in the NOC dashboard');
|
||||
assert.ok(!acts(doc.getElementById('leftBody')).includes('trace'), 'the traceroute moved into Routing & DDoS');
|
||||
ev(sandbox + ';ACT.pieFound();' + noc);
|
||||
assert.deepEqual(top(), ['dash', 'pieOpen', 'routingOpen'], 'Pie Control sits next to the NOC dashboard');
|
||||
assert.equal(doc.querySelectorAll('#leftBody [data-act=pieOpen]').length, 1, 'and the old card is gone');
|
||||
assert.equal(doc.querySelector('#leftBody .pie-card'), null);
|
||||
doc.querySelector('#leftBody .btns [data-act=pieOpen]').click();
|
||||
assert.equal(ev("$('modal').className"), 'pie');
|
||||
ev('closeModal()');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('Routing & DDoS opens the traceroute', () => {
|
||||
const { dom, ev, errors } = load();
|
||||
const doc = dom.window.document;
|
||||
ev("window.innerWidth=360;ACT.start({});if(UI.pendGame)ACT.pitchSkip();ACT.launchBB({city:'fra'});ACT.buyTransit({city:'fra',net:'cog',tier:1});ACT.routingOpen()");
|
||||
const b = doc.querySelector('#modalCard [data-act=trace]');
|
||||
assert.ok(b, 'a traceroute entry in the modal');
|
||||
assert.match(doc.querySelector('#modalCard .rt-trace').textContent, /Traceroute/);
|
||||
b.click();
|
||||
assert.equal(doc.querySelector('#modalCard [data-routing]'), null, 'the traceroute modal took over');
|
||||
assert.ok(doc.getElementById('trFrom'), 'with its source picker');
|
||||
ev('closeModal()');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('the bank shows Government money only with a rocket company, and pieGovOpen opens it there', () => {
|
||||
const { dom, ev, errors } = load();
|
||||
const doc = dom.window.document;
|
||||
ev(sandbox + ";window.innerWidth=360;ACT.bank()");
|
||||
assert.equal(doc.getElementById('bankGov'), null, 'nothing to show before the company');
|
||||
ev('ACT.bankClose();ACT.pieFound();ACT.pieOpen();ACT.pieGovOpen()');
|
||||
assert.equal(ev("$('modal').hidden"), true, 'Pie Control steps aside');
|
||||
assert.equal(ev("$('bankBox').hidden"), false);
|
||||
const card = doc.getElementById('bankCard');
|
||||
assert.ok(doc.getElementById('bankGov'));
|
||||
for (const re of [/Government money/, /Rural Digital Pie Fund/, /Pitcairn/, /Ex-Im Pie Bank/]) assert.match(card.textContent, re);
|
||||
ev('ACT.bankClose()');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('Pie Control: four tabs in one segmented control; old Gov and Founder tabs fall back', () => {
|
||||
const { dom, ev, errors } = load();
|
||||
const doc = dom.window.document;
|
||||
ev(sandbox + ";window.innerWidth=360;ACT.pieFound();UI.pieTab=null;ACT.pieOpen()");
|
||||
const seg = doc.querySelector('#modalCard .segc.pie-tabs');
|
||||
assert.ok(seg, 'one segmented control');
|
||||
assert.deepEqual([...seg.querySelectorAll('button')].map((b) => JSON.parse(b.dataset.args).t), ['traffic', 'co', 'fly', 'dish']);
|
||||
assert.equal(seg.querySelectorAll('button.on').length, 1);
|
||||
assert.equal(seg.querySelector('button.on').getAttribute('aria-pressed'), 'true');
|
||||
assert.deepEqual(JSON.parse(ev('JSON.stringify(PIE_TABS)')), ['traffic', 'co', 'fly', 'dish']);
|
||||
// A tab name left over from before: Founder lands on Company, Gov on traffic (or the bank, when asked for by name).
|
||||
ev("UI.pieTab='founder';ACT.pieOpen()");
|
||||
assert.equal(ev('UI.pieTab'), 'co');
|
||||
ev("UI.pieTab='book';ACT.pieOpen()");
|
||||
assert.equal(ev('UI.pieTab'), 'co');
|
||||
ev("UI.pieTab='gov';ACT.pieOpen()");
|
||||
assert.equal(ev('UI.pieTab'), 'traffic');
|
||||
ev("UI.pieTab='nonsense';ACT.pieOpen()");
|
||||
assert.equal(ev('UI.pieTab'), 'traffic');
|
||||
ev("ACT.pieTab({t:'gov'})");
|
||||
assert.equal(ev("$('bankBox').hidden"), false, 'the old Gov tab name opens the bank');
|
||||
ev("ACT.bankClose();ACT.pieTab({t:'book'})");
|
||||
assert.equal(ev('UI.pieTab'), 'co');
|
||||
ev('closeModal()'); // an open globe keeps its animation loop, and this process, alive
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('the Company tab ends with the Founder\'s posts, the newest three and the rest folded', () => {
|
||||
const { dom, ev, errors } = load();
|
||||
const doc = dom.window.document;
|
||||
ev(sandbox + ";window.innerWidth=360;ACT.pieFound();for(let i=0;i<5;i++)pieFounder(N_('pie.fp_rename'));ACT.pieTab({t:'co'})");
|
||||
const feed = doc.querySelector('#modalCard .pie-feed');
|
||||
assert.ok(feed, 'the feed is on the Company tab');
|
||||
assert.equal(feed, [...doc.querySelectorAll('#modalCard > *')].pop(), 'at the bottom');
|
||||
assert.match(feed.textContent, /The Founder posts/);
|
||||
assert.match(feed.textContent, /Promises/);
|
||||
const n = ev('S.pie.founder.posts.length');
|
||||
assert.equal(feed.querySelectorAll(':scope > .ops-rep').length, 3);
|
||||
assert.equal(feed.querySelectorAll('details .ops-rep').length, n - 3);
|
||||
assert.match(feed.querySelector('summary').textContent, new RegExp(`${n - 3} older posts`));
|
||||
assert.match(doc.getElementById('modalCard').textContent, /Spent so far/, 'the books moved here too');
|
||||
ev('closeModal()');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
|
@ -177,8 +177,9 @@ test('Ex-Im Pie Bank: a cheap loan sized to the constellation, with space covena
|
|||
assert.match(bank, /Launch \d+ pies by .* \(20 so far\)/);
|
||||
assert.match(bank, /Keep a pie dish in/);
|
||||
ev("$('bankBox').hidden=true;ACT.pieGovOpen()");
|
||||
assert.match(dom.window.document.querySelector('#modal').textContent, /Ex-Im Pie Bank/);
|
||||
ev('closeModal()');
|
||||
assert.equal(ev("$('bankBox').hidden"), false, 'the toast button opens the bank');
|
||||
assert.match(dom.window.document.querySelector('#bankGov').parentNode.textContent, /Ex-Im Pie Bank/);
|
||||
ev('ACT.bankClose()');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
|
|
@ -209,20 +210,21 @@ test('a broken space covenant: the bank penalty, tighter terms and a spat in the
|
|||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('the Gov tab fits a phone and lists the auction, the awards, Pitcairn and the bank', () => {
|
||||
test('the bank\'s Government money section fits a phone and lists the auction, the awards, Pitcairn and the bank', () => {
|
||||
const { dom, ev, errors } = load();
|
||||
pitcairn(ev);
|
||||
ev("window.innerWidth=360;pieRdfOpen('pcn');S.pie.gov.aw.push({id:'w1',city:'akl',mo:5e6,start:S.day,due:S.day+90,end:S.day+1800,s:0,n:0,paid:0});UI.pieTab=null;ACT.pieGovOpen()");
|
||||
const m = dom.window.document.querySelector('#modal');
|
||||
assert.equal(ev("$('modal').hidden"), false);
|
||||
const m = dom.window.document.querySelector('#bankCard');
|
||||
assert.equal(ev("$('bankBox').hidden"), false);
|
||||
assert.ok(m.querySelector('#bankGov'), 'opened at its section');
|
||||
assert.equal(m.querySelectorAll('[data-act=pieBid]').length, 3, 'three asks');
|
||||
assert.match(m.textContent, /Rural Digital Pie Fund/);
|
||||
assert.match(m.textContent, /Auckland/);
|
||||
assert.match(m.textContent, /Pitcairn/);
|
||||
assert.match(m.textContent, /satellite grant/);
|
||||
assert.doesNotMatch(m.textContent, /pie_gov\.|banks\.|undefined|NaN/);
|
||||
assert.doesNotMatch(m.querySelector('.bank-gov').textContent, /pie_gov\.|banks\.|undefined|NaN/);
|
||||
ev("ACT.pieBid({id:S.pie.gov.auc[0].id,f:0.7})");
|
||||
assert.ok(dom.window.document.querySelector('#modal [data-act=pieBid].pink'), 'your bid is marked');
|
||||
assert.ok(dom.window.document.querySelector('#bankCard [data-act=pieBid].pink'), 'your bid is marked, in the open bank');
|
||||
ev('closeModal()');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ test('unlocks once, on the Tier 1 win, in a save of this version', () => {
|
|||
assert.equal(ev('S.pie.born'), born, 'only once');
|
||||
// reachable from the NOC tab
|
||||
ev("UI.started=true;UI.left='noc';UI.leftOpen=true;renderLeft()");
|
||||
assert.ok(ev("!!document.querySelector('[data-act=pieOpen]')"), 'the NOC tab has the Pie Control card');
|
||||
assert.ok(ev("!!document.querySelector('[data-act=pieOpen]')"), 'the NOC tab has the Pie Control button');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
|
|
@ -264,7 +264,7 @@ test('saves without a rocket company pay nothing', () => {
|
|||
assert.equal(ev("pieDay(S.day)"), undefined);
|
||||
assert.equal(ev('pieDishes().length+pieHubs().length'), 0);
|
||||
assert.deepEqual(JSON.parse(ev('JSON.stringify(pieGlobeData())')), { crusts: [], dishes: [], pads: [], launches: [] });
|
||||
assert.equal(ev("pieCard()"), '', 'no card while locked');
|
||||
assert.equal(ev("pieNocBtn()"), '', 'no Pie Control button while locked');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
|
|
@ -273,7 +273,7 @@ test('Pie Control renders every tab on a phone', () => {
|
|||
ev('window.innerWidth=360');
|
||||
won(ev);
|
||||
company(ev);
|
||||
for (const t of ['co', 'fly', 'dish', 'gov', 'book']) {
|
||||
for (const t of ['traffic', 'co', 'fly', 'dish']) {
|
||||
ev(`ACT.pieTab({t:'${t}'})`);
|
||||
assert.equal(ev("$('modal').hidden"), false);
|
||||
assert.ok(dom.window.document.querySelectorAll('#modalCard [data-act]').length > 2, t);
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ test('the Traffic tab is first, fits 360 px and lists a terminal and a sky circu
|
|||
term(ev, 'pz', 'pcn');
|
||||
ev('UI.pieTab=null;ACT.pieOpen()');
|
||||
const d = doc(dom);
|
||||
assert.equal(d.querySelector('#modalCard .seg [aria-pressed="true"]').textContent, ev("tr('pie_traffic.tab')"), 'Traffic is the default tab');
|
||||
assert.equal(d.querySelector('#modalCard .pie-tabs [aria-pressed="true"]').textContent, ev("tr('pie_traffic.tab')"), 'Traffic is the default tab');
|
||||
const txt = d.querySelector('#modalCard').textContent;
|
||||
assert.match(txt, /In orbit now: .* of .* sellable · .*\/mo · 2 customers/);
|
||||
assert.match(txt, /Who's riding/);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue