Skip to content

Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.

feat(view): roadmap chips match the Items tab; addresses hold [N26,N38]

Corey Olson29162b236a5b
diff --git a/src/cockpit.js b/src/cockpit.js
index 8d65f65c..c4d247de 100644
--- a/src/cockpit.js
+++ b/src/cockpit.js
@@ -29,12 +29,15 @@ function lifecycle() {
* Its styles are src/view.css, which it links with the session's secret as every request carries it;
* styles stay in that separate file so its policy can refuse inline styles. The serving host
* supplies the API base and credential headers; clients need no loopback-specific connection.
+ * The Roadmap tab has its own address (N38): /roadmap on a host that serves the page there too,
+ * which `paths` declares, and a #roadmap fragment anywhere else, such as a snapshot hosted under a
+ * folder, where a path the host does not serve would leave a reload with nothing.
*
* @param {string} [key] - The session's secret.
- * @param {{snapshot?: boolean, apiBase?: string, apiHeaders?: Record<string, string>, stylesheet?: string}} [options] - Served API connection and assets, or a static, read-only page with event replay.
+ * @param {{snapshot?: boolean, apiBase?: string, apiHeaders?: Record<string, string>, stylesheet?: string, paths?: boolean}} [options] - Served API connection and assets, whether the host also serves the page at /roadmap, or a static, read-only page with event replay.
* @returns {string}
*/
-export function cockpitPage(key = '', { snapshot = false, apiBase = '', apiHeaders = { 'x-pullboard-key': key }, stylesheet = null } = {}) {
+export function cockpitPage(key = '', { snapshot = false, apiBase = '', apiHeaders = { 'x-pullboard-key': key }, stylesheet = null, paths = false } = {}) {
const connection = JSON.stringify({ base: apiBase.replace(/\/$/, ''), headers: apiHeaders }).replace(/</g, '\\u003c');
const css = stylesheet ?? (snapshot ? 'view.css' : '/view.css?k=' + encodeURIComponent(key));
const cssAttribute = css.replace(/[&<>"']/g, (character) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[character]);
@@ -143,7 +146,20 @@ const snapshot = ${JSON.stringify(snapshot)};
const connection = ${connection};
const snapshotReplay = { final: null, events: [], index: 0, playing: false, timer: null };
const keep = (name, value) => { name = snapshot ? 'snapshot.' + name : name; try { if (value === undefined) return localStorage.getItem(name); localStorage.setItem(name, value); } catch { return null; } return value; };
-const view = { root: keep('pb.project'), tab: location.pathname === '/roadmap' ? 'roadmap' : (keep('pb.tab') || 'items'), seen: {}, code: {}, item: null, adding: false, state: 'active', rows: { spec: 'decide', doctrine: 'all' }, row: { spec: null, doctrine: null } };
+// Whether the host serves this page at /roadmap as well as at /, so the Roadmap's address is a path;
+// anywhere else it is a #roadmap fragment on the page's own address (N38).
+const routed = ${JSON.stringify(Boolean(paths) && !snapshot)};
+/** The tab the address names: the Roadmap at its own address, or null at the board's. */
+function addressTab() {
+ if (typeof location === 'undefined') return null;
+ return (routed ? location.pathname === '/roadmap' : location.hash === '#roadmap') ? 'roadmap' : null;
+}
+/** The tab the board's own address shows: the one last picked there, or Items. */
+function homeTab() {
+ const kept = keep('pb.tab');
+ return kept && kept !== 'roadmap' ? kept : 'items';
+}
+const view = { root: keep('pb.project'), tab: addressTab() || homeTab(), seen: {}, code: {}, item: null, adding: false, state: 'active', rows: { spec: 'decide', doctrine: 'all' }, row: { spec: null, doctrine: null } };
if (snapshot) view.state = 'all';
let data = null;
let seen = '';
@@ -455,6 +471,9 @@ function boardSummary(board, state) {
drafts: state.spec.filter((row) => row.status === 'draft').length,
holds: state.holds.length,
decisions: state.decisions.length,
+ // What each item's state reads from, so another repo's roadmap can show it as this board's
+ // Items tab does, sent back included, and open it here.
+ items: state.items.map((item) => ({ id: item.id, title: item.title, status: item.status, verdict: item.verdict && { decision: item.verdict.decision } })),
};
}
@@ -583,6 +602,8 @@ function replayProject(index) {
const added = log.find((event) => event.item_id === item.id && event.event_kind === 'add');
item.blockedBy = (JSON.parse(added.event_detail).after || []).filter((id) => statuses.get(id) !== 'verified');
}
+ // A milestone lists only this board's items added by now; another repo's stay as the export read them.
+ p.milestones = (p.milestones || []).map((milestone) => ({ ...milestone, items: milestone.items.filter((entry) => typeof entry.id !== 'number' || statuses.has(entry.id)) }));
const shouted = new Set(log.map((event) => JSON.parse(event.event_detail).shout).filter(Boolean));
p.shouts = p.shouts.filter((shout) => shouted.has(shout.shout_id));
p.decisions = p.decisions.filter((shout) => shouted.has(shout.shout_id));
@@ -745,6 +766,65 @@ function renderGroup(group) {
$('group-activity').innerHTML = events.length ? byDay(events, (event) => event.event_at, (event) => '<div><time>' + clock(event.event_at) + '</time><div class="act"><b class="repo-label">' + esc(event.repo.name) + '</b> <span>' + esc(event.event_by) + ' ' + esc(event.event_kind) + (event.item_id ? ' #' + event.item_id + (event.title ? ' ' + rich(event.title, new Map(), false) : '') : '') + '</span></div></div>') : '<div class="empty">No activity yet.</div>';
}
+/**
+ * A milestone's item as the Items tab reads it (N26). This board's own come from its items, and
+ * another repo's, written repo#id, from that repo's board when the view lists one by that name or
+ * folder, as the roadmap resolves it: the same state, sent back included, and it opens there. An
+ * item no listed board holds keeps the status the roadmap read for it, and opens nowhere.
+ */
+function milestoneItem(entry, p) {
+ const local = typeof entry.id === 'number';
+ const ref = local ? null : /^(.+)#([1-9]\\d*)$/.exec(String(entry.id));
+ const named = ref ? data.projects.filter((x) => x.name === ref[1] || String(x.root).split('/').pop() === ref[1]) : [];
+ const root = local ? view.root : named.length === 1 && named[0].ok ? named[0].root : null;
+ const id = local ? entry.id : ref ? Number(ref[2]) : null;
+ const item = (root === view.root ? p.items : root ? named[0].items : []).find((i) => i.id === id) || null;
+ // A status the lifecycle declares; the roadmap says unavailable or missing for an item it could not read.
+ const read = item || (FLOW.states.some((state) => state.id === entry.status) ? { status: entry.status, verdict: null } : null);
+ return {
+ label: local ? '#' + entry.id : String(entry.id),
+ title: item ? item.title : read ? entry.title : '',
+ state: read ? stateOf(read) : null,
+ word: entry.status,
+ open: item ? { root, id } : null,
+ // Why an item does not open, short enough to read beside its id on a phone.
+ why: item ? '' : local ? 'not on this board' : root ? 'not on that board' : snapshot ? 'not in this snapshot'
+ : named.length > 1 ? 'board name not unique' : named.length ? 'board unreadable' : 'no such board',
+ };
+}
+
+/**
+ * One item's row on the Roadmap, laid out as the Items list lays one out: the dot of its state, its
+ * id and title on one line that ends in an ellipsis when cut, and the Items tab's chip. The whole
+ * title is the row's tooltip. An item that opens is a button; one that cannot says why instead.
+ */
+function milestoneRow(row, titles) {
+ const title = row.title ? inline(String(row.title).replace(/\\s+/g, ' '), titles, false) : '<span class="muted">' + esc(row.why) + '</span>';
+ const inner = '<span class="dot' + (row.state ? ' ' + row.state : '') + '"></span><span class="t"><span class="id">' + esc(row.label) + '</span>' + title + '</span>' + (row.state ? chip(row.state) : '<span class="chip">' + esc(row.word) + '</span>');
+ if (!row.open) return '<li><div class="milestone-item" title="' + esc(row.title ? row.title + ' (' + row.why + ')' : row.why) + '">' + inner + '</div></li>';
+ return '<li><button class="milestone-item" data-go="item:' + row.open.id + '"' + (row.open.root === view.root ? '' : ' data-board="' + esc(row.open.root) + '"') + ' title="' + esc(row.title) + '" type="button">' + inner + '</button></li>';
+}
+
+/**
+ * The Roadmap (N26, N38): a card for each milestone in the board's order, with how many of its
+ * items are verified as a count and a bar, a row for each, and the note to the person in its own
+ * highlighted line. A milestone with no items says so, rather than draw an empty bar.
+ */
+function roadmapCards(p, titles) {
+ const milestones = p.milestones || [];
+ if (!milestones.length) return '<div class="card-panel empty">No milestones yet. The coordinator adds one with <code class="inline">pullboard milestone add</code>.</div>';
+ return milestones.map((milestone) => {
+ const rows = milestone.items.map((entry) => milestoneItem(entry, p));
+ const done = rows.filter((row) => row.state === 'verified').length;
+ const name = esc(milestone.name);
+ return '<article class="card-panel milestone"><header><h2>' + name + '</h2>' + (rows.length ? '<span class="milestone-count">' + done + '/' + rows.length + ' done</span>' : '') + '</header>'
+ + (rows.length
+ ? '<svg class="milestone-progress" viewBox="0 0 100 1" preserveAspectRatio="none" role="progressbar" aria-label="' + name + ': ' + done + ' of ' + rows.length + ' done" aria-valuemin="0" aria-valuemax="' + rows.length + '" aria-valuenow="' + done + '"><rect width="' + Math.round((100 * done) / rows.length) + '" height="1"/></svg><ul>' + rows.map((row) => milestoneRow(row, titles)).join('') + '</ul>'
+ : '<p class="milestone-empty">No items yet.</p>')
+ + (milestone.note ? '<p class="milestone-note">' + rich(milestone.note, titles, false) + '</p>' : '') + '</article>';
+ }).join('');
+}
+
/** Draw the board shown: the sidebar, then every tab's panes from the project's board. */
function render() {
const p = data.project;
@@ -773,16 +853,7 @@ function render() {
$('count-spec').textContent = p.spec.filter((r) => ['pending', 'draft'].includes(r.status)).length || '';
$('count-doctrine').textContent = p.practice.filter((r) => ['pending', 'draft'].includes(r.status)).length || '';
const titles = new Map(p.items.map((i) => [String(i.id), i.title]));
-
- $('roadmap').innerHTML = p.milestones.length ? p.milestones.map((milestone) => {
- const percent = milestone.total ? Math.round(100 * milestone.done / milestone.total) : 0;
- const statuses = { verified: 'Done', submitted: 'In review', claimed: 'Building', open: 'Queued' };
- const statusTones = { verified: 'ok', submitted: 'busy', claimed: 'warn' };
- return '<article class="card-panel milestone"><header><h2>' + esc(milestone.name) + '</h2><span class="milestone-count">' + milestone.done + '/' + milestone.total + ' done</span></header>'
- + '<svg class="milestone-progress" viewBox="0 0 100 1" preserveAspectRatio="none" role="progressbar" aria-label="' + esc(milestone.name) + ' progress" aria-valuemin="0" aria-valuemax="' + milestone.total + '" aria-valuenow="' + milestone.done + '"><rect width="' + percent + '" height="1"/></svg>'
- + '<ul>' + milestone.items.map((item) => '<li><button class="milestone-item" data-go="item:' + esc(item.id) + '" type="button"><code>#' + esc(item.id) + '</code><span>' + esc(item.title) + '</span><span class="chip ' + (statusTones[item.status] || '') + '" data-status="' + esc(item.status) + '">' + esc(statuses[item.status] || item.status) + '</span></button></li>').join('') + '</ul>'
- + (milestone.note ? '<p class="milestone-note">' + esc(milestone.note) + '</p>' : '') + '</article>';
- }).join('') : '<div class="card-panel empty">No milestones yet.</div>';
+ $('roadmap').innerHTML = roadmapCards(p, titles);
// What needs the person, first, and only the person's calls (B26): the decisions passed up to them,
// questions in the spec, held lanes, then draft rows. Work waiting for a verdict or sent back shows
@@ -818,7 +889,8 @@ function render() {
$('state-chips').innerHTML = Object.keys(names).map((s) => '<button data-state="' + s + '" class="' + (view.state === s ? 'on' : '') + '" type="button">' + names[s] + '<b>' + matching.filter(inState(s)).length + '</b></button>').join('');
const shown = matching.filter(inState(view.state)).sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));
// With nothing picked, the detail shows the first row, and keeps it when a refresh reorders the list.
- if (!view.adding && !p.items.some((i) => i.id === view.item)) view.item = shown.length ? shown[0].id : null;
+ // While another project loads, the item picked there waits for its own board.
+ if (data.root === view.root && !view.adding && !p.items.some((i) => i.id === view.item)) view.item = shown.length ? shown[0].id : null;
const heldLanes = new Map(p.holds.map((h) => [h.hold_lane, h]));
$('chain').innerHTML = shown.length ? shown.map((i) => {
const s = stateOf(i);
@@ -937,11 +1009,49 @@ function showTab() {
countUnseen();
}
-/** Keep the roadmap's standalone address in sync with the selected tab. */
-function tabAddress(tab) {
+/** The address that names a tab: the Roadmap's own, or the board's, keeping the rest as it is. */
+function tabHref(tab) {
+ const own = tab === 'roadmap';
+ return routed ? (own ? '/roadmap' : '/') + location.search : location.pathname + location.search + (own ? '#roadmap' : '');
+}
+
+/**
+ * Keep the address naming what the page shows (N38). Moving between the Roadmap and another tab
+ * changes it and adds a history entry, so Back and Forward return there; anything else, or push
+ * false, only updates the entry. Each entry carries its project and item too, so returning to one
+ * shows that board as it was. A host that refuses the change still shows the tab.
+ */
+function address(push = true) {
if (typeof history === 'undefined' || typeof location === 'undefined') return;
- const path = tab === 'roadmap' ? '/roadmap' : '/';
- if (location.pathname !== path) history.pushState(null, '', path + location.search);
+ const state = { tab: view.tab, root: view.root, item: view.item };
+ const href = tabHref(view.tab);
+ try {
+ if (push && href !== location.pathname + location.search + (routed ? '' : location.hash)) history.pushState(state, '', href);
+ else history.replaceState(state, '');
+ } catch { /* The tab shows all the same. */ }
+}
+
+/**
+ * Show what a history entry names, on Back, Forward or an edited #roadmap: the tab its address
+ * names, or at the board's address the tab the entry kept, and the project and item it kept.
+ */
+function fromAddress(event) {
+ const kept = (event && event.state) || {};
+ view.tab = addressTab() || (kept.tab && kept.tab !== 'roadmap' ? kept.tab : homeTab());
+ if (view.tab !== 'roadmap') keep('pb.tab', view.tab);
+ const item = typeof kept.item === 'number' ? kept.item : null;
+ if (kept.root && kept.root !== view.root && data && data.projects.some((x) => x.ok && x.root === kept.root)) return switchTo(kept.root, item, false);
+ if (item !== null && view.tab === 'items') view.item = item;
+ address(false);
+ if (data) render();
+ else showTab();
+}
+
+/** Pick a tab. The board's address keeps it for next time; the Roadmap has an address of its own. */
+function openTab(tab) {
+ view.tab = tab;
+ if (tab !== 'roadmap') keep('pb.tab', tab);
+ address();
}
/**
@@ -984,23 +1094,34 @@ function answer(id) {
if (ask) $('shout-text').focus();
}
-function go(target) {
+/**
+ * Follow a link in the page: an item, a spec row, a tab or a decision to answer. An item can live on
+ * another project's board, root, which the page then switches to.
+ */
+function go(target, root = view.root) {
const [kind, id] = target.split(':');
- if (kind === 'item') { view.tab = 'items'; view.state = 'all'; view.before = null; }
- else if (kind === 'spec') { view.tab = 'spec'; view.row.spec = id; view.rows.spec = 'all'; }
- else if (kind === 'tab') view.tab = id;
- else if (kind === 'decide') { view.tab = 'shouts'; answer(Number(id)); }
- keep('pb.tab', view.tab);
- tabAddress(view.tab);
- if (kind === 'item') pick(Number(id));
+ let tab = view.tab;
+ if (kind === 'item') { tab = 'items'; view.state = 'all'; view.before = null; }
+ else if (kind === 'spec') { tab = 'spec'; view.row.spec = id; view.rows.spec = 'all'; }
+ else if (kind === 'tab') tab = id;
+ else if (kind === 'decide') { tab = 'shouts'; answer(Number(id)); }
+ openTab(tab);
+ if (kind === 'item') pick(Number(id), root);
else render();
}
-/** Show an item's detail. Where the list and the detail stack (under 900px), bring the detail into view. */
-function pick(id) {
- view.item = id;
+/** Show an item's detail, on another project's board when root names one. */
+function pick(id, root = view.root) {
view.adding = false;
+ if (root !== view.root) return switchTo(root, id);
+ view.item = id;
+ address(false);
render();
+ reveal();
+}
+
+/** Where the list and the detail stack (under 900px), bring the detail into view. */
+function reveal() {
if (matchMedia('(max-width: 900px)').matches) $('detail').scrollIntoView({ block: 'start', behavior: 'smooth' });
}
@@ -1119,19 +1240,27 @@ function fold(open) {
$('proj-switch').setAttribute('aria-expanded', String(open));
}
-/** Show another project: mark it at once, dim the old one's panes until its board arrives. */
-function switchTo(root) {
+/**
+ * Show another project: mark it at once, dim the old one's panes until its board arrives. Given an
+ * item, its board opens on that item; with record false the history entry stays as it is, for a
+ * move that came from the entry.
+ */
+function switchTo(root, item = null, record = true) {
answer(null);
view.root = root;
- view.item = null;
+ view.item = item;
view.adding = false;
keep('pb.project', root);
+ if (record) address(false);
fold(false);
// The board that arrives is drawn even if it matches the last one seen, so the pick is made from it.
seen = '';
if (data) renderSide();
document.body.classList.add('switching');
- refresh().catch(() => { $('live').textContent = 'offline: is pullboard view still running?'; }).finally(() => document.body.classList.remove('switching'));
+ refresh().catch(() => { $('live').textContent = 'offline: is pullboard view still running?'; }).finally(() => {
+ document.body.classList.remove('switching');
+ if (item !== null && view.root === root && view.tab === 'items') reveal();
+ });
}
document.addEventListener('click', (event) => {
@@ -1141,15 +1270,15 @@ document.addEventListener('click', (event) => {
if (t.id === 'proj-switch') { fold(!$('side').classList.contains('open')); return; }
if (t.id === 'console') { t.hidden = true; return; }
if (t.dataset.root) switchTo(t.dataset.root);
- else if (t.dataset.tab) { view.tab = t.dataset.tab; keep('pb.tab', view.tab); tabAddress(view.tab); showTab(); }
- else if (t.dataset.go) go(t.dataset.go);
+ else if (t.dataset.tab) { openTab(t.dataset.tab); showTab(); }
+ else if (t.dataset.go) go(t.dataset.go, t.dataset.board);
else if (t.dataset.item) pick(Number(t.dataset.item));
else if (t.dataset.state) { view.state = t.dataset.state; render(); }
else if (t.dataset.rows) { const [kind, f] = t.dataset.rows.split(':'); view.rows[kind] = f; render(); }
else if (t.dataset.row) { const [kind, id] = t.dataset.row.split(':'); view.row[kind] = id; render(); }
else if (t.dataset.code) code(t.dataset.code, t.dataset.before || '');
else if (t.dataset.release) act('release', { lane: t.dataset.release }, t);
- else if (t.dataset.shout) { answer(null); $('shout-to').value = t.dataset.shout; $('shout-text').value = '#' + t.dataset.about + ': '; view.tab = 'shouts'; showTab(); $('shout-text').focus(); }
+ else if (t.dataset.shout) { answer(null); $('shout-to').value = t.dataset.shout; $('shout-text').value = '#' + t.dataset.about + ': '; openTab('shouts'); showTab(); $('shout-text').focus(); }
else if (t.dataset.new !== undefined) { view.adding = true; render(); $('add-title').focus(); }
});
// The form covers the picked item rather than dropping it, so Cancel brings it back.
@@ -1189,6 +1318,9 @@ $('hold-form').addEventListener('submit', async (event) => {
event.preventDefault();
if (await act('hold', { lane: $('hold-lane').value, reason: $('hold-reason').value }, event.currentTarget)) $('hold-reason').value = '';
});
+// The first entry keeps the tab it opened on; Back and Forward show what each entry names.
+address(false);
+globalThis.addEventListener?.('popstate', fromAddress);
showTab();
if (snapshot) {
$('replay-play').addEventListener('click', playReplay);
diff --git a/src/serve.js b/src/serve.js
index ece4f499..a1a7ee7b 100644
--- a/src/serve.js
+++ b/src/serve.js
@@ -315,7 +315,8 @@ export async function serveView({ port = 0, secret = randomBytes(18).toString('b
const isOwnHost = req.headers.host === `${LOOPBACK}:${bound}` || req.headers.host === `localhost:${bound}`;
if (!isOwnHost || given.length !== key.length || !timingSafeEqual(given, key)) return json(res, 403, { error: 'this view needs its own address and secret: open the link pullboard view printed' });
try {
- if (req.method === 'GET' && (url.pathname === '/' || url.pathname === '/roadmap')) return reply(res, 200, 'text/html; charset=utf-8', cockpitPage(secret));
+ // The board, and the Roadmap at its own address (N38), are the one page.
+ if (req.method === 'GET' && (url.pathname === '/' || url.pathname === '/roadmap')) return reply(res, 200, 'text/html; charset=utf-8', cockpitPage(secret, { paths: true }));
if (req.method === 'GET' && url.pathname === '/view.css') return reply(res, 200, 'text/css; charset=utf-8', VIEW_CSS);
return json(res, 404, { error: 'no such page' });
} catch (error) {
diff --git a/src/view.css b/src/view.css
index 9f89e39e..bffb146e 100644
--- a/src/view.css
+++ b/src/view.css
@@ -87,19 +87,22 @@ main { padding: 16px 18px 28px; }
.boardless .first { display: block; }
.loading .top, .loading [data-pane], .boardless .top, .boardless [data-pane] { display: none; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) clamp(300px, 42%, 600px); gap: 16px; align-items: start; }
-.roadmap { display: grid; gap: 12px; max-width: 900px; }
-.milestone { padding: 14px 16px; min-width: 0; }
+.roadmap { display: grid; gap: 12px; max-width: 900px; align-content: start; }
+.milestone { padding: 14px 16px 12px; }
.milestone header { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
-.milestone h2 { margin: 0; font-size: 17px; overflow-wrap: anywhere; }
+.milestone h2 { margin: 0; font-size: 17px; line-height: 1.3; overflow-wrap: anywhere; }
.milestone-count { color: var(--ink-muted); font: 12px var(--mono); white-space: nowrap; }
-.milestone-progress { display: block; width: 100%; height: 7px; margin: 10px 0; overflow: hidden; border-radius: 99px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
+.milestone-progress { display: block; width: 100%; height: 7px; margin: 10px 0 6px; overflow: hidden; border-radius: 99px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.milestone-progress rect { fill: var(--accent); }
-.milestone ul { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
-.milestone-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px; width: 100%; min-width: 0; padding: 7px 4px; border: 0; border-top: 1px solid var(--line); background: none; text-align: left; cursor: pointer; }
-.milestone-item:hover { background: var(--surface-2); }
-.milestone-item code { color: var(--accent-strong); font: 12px var(--mono); }
-.milestone-item > span:nth-child(2) { min-width: 0; overflow-wrap: anywhere; }
-.milestone-note { margin: 10px 0 0; padding: 8px 10px; border-radius: 7px; background: var(--accent-soft); color: var(--ink-muted); overflow-wrap: anywhere; }
+.milestone ul { display: grid; gap: 2px; margin: 0 -9px; padding: 0; list-style: none; }
+.milestone-item { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; gap: 10px; align-items: center; width: 100%; min-height: 44px; padding: 0 9px; border: 1px solid transparent; border-radius: 10px; background: none; text-align: left; }
+button.milestone-item { cursor: pointer; }
+button.milestone-item:hover { background: var(--surface-2); }
+.milestone-item .t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+.milestone-item .t code { white-space: nowrap; }
+.milestone-item .id { margin-right: 6px; color: var(--ink-faint); font: 500 12px var(--mono); }
+.milestone-empty { margin: 8px 0 0; color: var(--ink-faint); }
+.milestone-note { margin: 10px 0 2px; padding: 8px 10px; border-radius: 8px; background: var(--accent-soft); color: var(--ink-muted); overflow-wrap: anywhere; }
.two.narrow { grid-template-columns: minmax(0, 1fr) var(--agents-w); }
@media (max-width: 900px) {
.shell { display: block; }
@@ -122,7 +125,7 @@ main { padding: 16px 18px 28px; }
.group-need > b { grid-column: 1; }
.group-need > code { grid-column: 2; }
.group-need > span, .group-need > em { grid-column: 1 / -1; }
- .tabs { flex: 1; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 0; }
+ .tabs { flex: 1; display: grid; grid-auto-flow: column; grid-auto-columns: auto; gap: 0; }
.tab { display: grid; grid-template-rows: auto 13px; justify-items: center; align-content: center; padding: 7px 2px 5px; font-size: 13.5px; }
.tab b { margin: 0; line-height: 13px; }
}
diff --git a/test/cockpit.test.js b/test/cockpit.test.js
index afe18f4d..755530bc 100644
--- a/test/cockpit.test.js
+++ b/test/cockpit.test.js
@@ -570,7 +570,7 @@ test('the tabs fit one row on a phone [N26]', async () => {
const style = await styleOf(view);
const phone = /@media \(width < 480px\) \{\n([^@]*?)\n\}/.exec(style)?.[1] ?? '';
assert.doesNotMatch(style, /max-width: 480px/, 'at 480px itself the tabs keep their row');
- assert.match(phone, /\.tabs \{ flex: 1; display: grid; grid-auto-flow: column; grid-auto-columns: minmax\(0, 1fr\);/, 'under 480px the tabs share the bar in equal columns');
+ assert.match(phone, /\.tabs \{ flex: 1; display: grid; grid-auto-flow: column; grid-auto-columns: auto;/, 'under 480px the tabs share the bar: each as wide as its label, plus an even share of the room left');
assert.match(phone, /\.tab \{ display: grid; grid-template-rows: auto 13px; justify-items: center;/, 'each tab stacks its label over its count');
assert.match(phone, /\.tab b \{ margin: 0;/);
assert.match(style, /\n\.tabs \{ display: flex; flex-wrap: wrap; gap: 2px; \}\n/, 'wider, the tabs keep the row they have');
@@ -3123,61 +3123,363 @@ test('wait references stay on one line and link to every prerequisite at phone a
}
});
-test('roadmap has a direct responsive address and live milestone progress [N26,N38]', { timeout: 90_000 }, async (t) => {
+/** Click what a page expression finds, through Chrome's own mouse input, as a person would. */
+async function press(chrome, find) {
+ const point = JSON.parse(await chrome.evaluate(`(() => {
+ const element = ${find};
+ if (!element) throw new Error(${JSON.stringify(`nothing to press: ${find}`)});
+ element.scrollIntoView({ block: 'center' });
+ const rect = element.getBoundingClientRect();
+ return JSON.stringify({ x: rect.x + rect.width / 2, y: rect.y + rect.height / 2 });
+ })()`));
+ await chrome.send('Input.dispatchMouseEvent', { type: 'mouseMoved', ...point });
+ await chrome.send('Input.dispatchMouseEvent', { type: 'mousePressed', ...point, button: 'left', clickCount: 1 });
+ await chrome.send('Input.dispatchMouseEvent', { type: 'mouseReleased', ...point, button: 'left', clickCount: 1 });
+}
+
+/** Go back (-1) or forward (1) one entry in the tab's history, as the browser's own buttons do. */
+async function travel(chrome, step) {
+ const { currentIndex, entries } = await chrome.send('Page.getNavigationHistory');
+ await chrome.send('Page.navigateToHistoryEntry', { entryId: entries[currentIndex + step].id });
+}
+
+/** Wait for a page condition that may span a page load, when the page asked may still be loading. */
+async function settled(chrome, expression, timeoutMs = 15_000) {
+ const deadline = Date.now() + timeoutMs;
+ while (Date.now() < deadline) {
+ try { if (await chrome.evaluate(expression)) return; } catch { /* The next page is still loading. */ }
+ await browserPause(50);
+ }
+ throw new Error(`Browser condition did not arrive: ${expression}`);
+}
+
+/** A page expression for the Roadmap row showing an id, such as #3 or beacon#1. */
+function roadmapRow(id) {
+ return `[...document.querySelectorAll('#roadmap .milestone-item')].find((row) => row.querySelector('.id')?.textContent === ${JSON.stringify(id)})`;
+}
+
+/** A page expression that is true when only this pane shows, at this address. */
+function showing(pane, address) {
+ return `[...document.querySelectorAll('[data-pane]')].filter((each) => !each.hidden).map((each) => each.dataset.pane).join() === ${JSON.stringify(pane)} && location.pathname + location.hash === ${JSON.stringify(address)}`;
+}
+
+/**
+ * The Roadmap as Chrome draws it: the address and the pane shown, the page's width, and each card
+ * with its count, the share of its bar that is filled, its note and its rows. A row has the id and
+ * chip label the person reads, the chip's tone and colours, its dot's colour, its tooltip and title,
+ * and how many lines the title takes and whether it is cut with an ellipsis.
+ */
+async function readRoadmap(chrome) {
+ return JSON.parse(await chrome.evaluate(`JSON.stringify((() => {
+ const paint = (element) => getComputedStyle(element).color + ' on ' + getComputedStyle(element).backgroundColor;
+ return {
+ address: location.pathname + location.search + location.hash,
+ shown: [...document.querySelectorAll('[data-pane]')].filter((pane) => !pane.hidden).map((pane) => pane.dataset.pane),
+ tab: document.querySelector('.tab.on')?.dataset.tab,
+ client: document.documentElement.clientWidth, document: document.documentElement.scrollWidth, body: document.body.scrollWidth,
+ cards: [...document.querySelectorAll('#roadmap .milestone')].map((card) => {
+ const bar = card.querySelector('.milestone-progress');
+ return {
+ name: card.querySelector('h2').innerText,
+ count: card.querySelector('.milestone-count')?.innerText ?? null,
+ filled: bar ? Math.round(1000 * bar.querySelector('rect').getBoundingClientRect().width / bar.getBoundingClientRect().width) / 1000 : null,
+ progress: bar ? [Number(bar.getAttribute('aria-valuenow')), Number(bar.getAttribute('aria-valuemax'))] : null,
+ empty: card.querySelector('.milestone-empty')?.innerText ?? null,
+ note: card.querySelector('.milestone-note')?.innerText ?? null,
+ rows: [...card.querySelectorAll('.milestone-item')].map((row) => {
+ const chip = row.querySelector('.chip'), title = row.querySelector('.t'), style = getComputedStyle(title), box = chip.getBoundingClientRect();
+ return {
+ id: row.querySelector('.id').innerText, label: chip.innerText, tone: [...chip.classList].filter((name) => name !== 'chip').join(' '),
+ seen: box.width > 0 && box.height > 0 && getComputedStyle(chip).visibility === 'visible',
+ chip: paint(chip), dot: getComputedStyle(row.querySelector('.dot')).backgroundColor,
+ button: row.tagName === 'BUTTON', tip: row.title, title: [...title.childNodes].slice(1).map((node) => node.textContent).join(''),
+ lines: Math.round(title.getBoundingClientRect().height / parseFloat(style.lineHeight)),
+ cut: title.scrollWidth > title.clientWidth, ellipsis: style.textOverflow === 'ellipsis' && style.whiteSpace === 'nowrap' && style.overflow === 'hidden',
+ };
+ }),
+ };
+ }),
+ };
+ })())`));
+}
+
+/**
+ * How the tab bar lays out with each tab in turn picked, and so bold: each tab's box and its label's,
+ * and the bar's edges. The tab picked now is picked again afterwards.
+ */
+async function tabBar(chrome) {
+ return JSON.parse(await chrome.evaluate(`JSON.stringify((() => {
+ const bar = document.querySelector('#tabs'), tabs = [...bar.querySelectorAll('.tab')], picked = tabs.find((tab) => tab.classList.contains('on'));
+ const layouts = tabs.map((on) => {
+ tabs.forEach((tab) => tab.classList.toggle('on', tab === on));
+ return { on: on.dataset.tab, bar: [bar.getBoundingClientRect().left, bar.getBoundingClientRect().right], tabs: tabs.map((tab) => {
+ const range = document.createRange();
+ range.selectNodeContents(tab.firstChild);
+ const box = tab.getBoundingClientRect(), label = range.getBoundingClientRect();
+ return { tab: tab.dataset.tab, left: box.left, right: box.right, labelLeft: label.left, labelRight: label.right };
+ }) };
+ });
+ tabs.forEach((tab) => tab.classList.toggle('on', tab === picked));
+ return { client: document.documentElement.clientWidth, layouts };
+ })())`));
+}
+
+/** Serve a folder under a path prefix, as a static host does, recording each request and its status. */
+async function serveFolder(folder, prefix) {
+ const requests = [];
+ const server = createServer((request, response) => {
+ const path = new URL(request.url, 'http://127.0.0.1').pathname;
+ /** Record the request with its status, then answer it. */
+ const answer = (status, body, type) => { requests.push({ path, status }); response.writeHead(status, type ? { 'content-type': type, 'cache-control': 'no-store' } : {}).end(body); };
+ if (!path.startsWith(prefix) || request.method !== 'GET') return answer(404);
+ const file = resolve(folder, decodeURIComponent(path.slice(prefix.length)) || 'index.html');
+ if (!file.startsWith(`${resolve(folder)}/`)) return answer(404);
+ let body;
+ try { body = readFileSync(file); } catch { return answer(404); }
+ return answer(200, body, file.endsWith('.html') ? 'text/html; charset=utf-8' : file.endsWith('.css') ? 'text/css; charset=utf-8' : 'application/json; charset=utf-8');
+ });
+ await new Promise((done) => server.listen(0, '127.0.0.1', done));
+ return { base: `http://127.0.0.1:${server.address().port}`, requests, close: () => new Promise((done) => server.close(done)) };
+}
+
+/** Save the page, all of it, at a width and in a theme, when PULLBOARD_ROADMAP_PROOF names a folder. */
+async function proofShot(chrome, name, width) {
+ if (!process.env.PULLBOARD_ROADMAP_PROOF) return;
+ mkdirSync(process.env.PULLBOARD_ROADMAP_PROOF, { recursive: true });
+ for (const theme of ['light', 'dark']) {
+ await chrome.evaluate(`document.documentElement.dataset.theme = '${theme}'`);
+ const height = await chrome.evaluate('Math.ceil(document.documentElement.scrollHeight)');
+ await chrome.send('Emulation.setDeviceMetricsOverride', { width, height: Math.max(900, height), deviceScaleFactor: 2, mobile: false });
+ await browserPause(150);
+ const shot = await chrome.send('Page.captureScreenshot', { format: 'png' });
+ writeFileSync(join(process.env.PULLBOARD_ROADMAP_PROOF, `${name}-${width}-${theme}.png`), Buffer.from(shot.data, 'base64'));
+ }
+ await chrome.evaluate('delete document.documentElement.dataset.theme');
+ await chrome.send('Emulation.setDeviceMetricsOverride', { width, height: 900, deviceScaleFactor: 1, mobile: false });
+}
+
+test('the roadmap reads every item as the Items tab does, opens each one, another repo\'s too, and keeps its own address [N26,N38]', { timeout: 150_000 }, async (t) => {
const executable = chromeExecutable();
if (!executable) return t.skip('Install Chrome or set PULLBOARD_CHROME for roadmap browser checks.');
const box = machine();
const alpha = project(box, 'roadmap-demo');
- box.run(alpha.repo, 'add', 'web', 'Verified milestone item', '--specs', 'G1', '--criterion', 'verified item is linked');
- box.run(alpha.repo, 'add', 'web', 'Live milestone item', '--specs', 'G1', '--criterion', 'live item changes status');
- build(box, alpha, 1, 'verified.txt');
- box.git(alpha.repo, 'switch', '--detach', alpha.branch);
- box.run(alpha.repo, 'verify', '1', 'accept', '--as', 'coordinator', '--note', 'Verified the submitted item in the isolated test fixture.');
- box.git(alpha.repo, 'switch', 'main');
- box.run(alpha.repo, 'milestone', 'add', 'First milestone', '--note', 'A highlighted note for the person.', '--items', '1');
- box.run(alpha.repo, 'milestone', 'add', 'Second milestone', '--note', 'Keep this order.', '--items', '2');
+ const beacon = project(box, 'beacon');
+ const long = 'A deliberately long title that runs past the width of a phone and keeps going, far enough to be cut on a wide desktop card as well';
+ const titles = ['Merged greeting page', 'Verified farewell page', 'Session timeout banner', 'Upload progress bar', 'Live search results', long, 'Withdrawn experiment'];
+ for (const title of titles) box.run(alpha.repo, 'add', 'web', title, '--specs', 'G1', '--criterion', 'renders');
+ // One item in each state: verified and merged, verified, sent back, to verify, building, open, withdrawn.
+ build(box, alpha, 1, 'one.txt');
+ accept(box, alpha, 1);
+ box.run(alpha.repo, 'merged', '1', box.git(alpha.repo, 'rev-parse', alpha.branch));
+ build(box, alpha, 2, 'two.txt');
+ accept(box, alpha, 2);
+ build(box, alpha, 3, 'three.txt');
+ sendBack(box, alpha, 3, 'the banner does not time out yet');
+ build(box, alpha, 4, 'four.txt');
+ box.run(alpha.web, 'claim', '5');
+ box.run(alpha.repo, 'withdraw', '7', 'no longer needed');
+ // Another repo's item, sent back on its own board.
+ box.run(beacon.repo, 'add', 'web', 'Billing webhook retries', '--specs', 'G1', '--criterion', 'retries');
+ build(box, beacon, 1, 'retry.txt');
+ sendBack(box, beacon, 1, 'retry twice before failing');
+ box.run(alpha.repo, 'milestone', 'add', 'Launch', '--note', 'Ships when the review lands; your call on the name.', '--items', '1,2,3,4,beacon#1');
+ box.run(alpha.repo, 'milestone', 'add', 'Next', '--note', 'Queued behind Launch.', '--items', '5,6,7');
+ box.run(alpha.repo, 'milestone', 'add', 'Later', '--note', 'Ideas not filed yet.');
+ // What the person reads on each row: the Items tab's word for the item's state, and its colour's class.
+ const words = [
+ { id: '#1', label: 'verified', tone: 'ok' },
+ { id: '#2', label: 'verified', tone: 'ok' },
+ { id: '#3', label: 'sent back', tone: 'no' },
+ { id: '#4', label: 'to verify', tone: 'warn' },
+ { id: 'beacon#1', label: 'sent back', tone: 'no' },
+ { id: '#5', label: 'building', tone: 'busy' },
+ { id: '#6', label: 'open', tone: '' },
+ { id: '#7', label: 'withdrawn', tone: '' },
+ ];
const view = await startView(box);
+ const roadmap = `/roadmap${view.link.search}`;
const profile = mkdtempSync(join(tmpdir(), 'pullboard-roadmap-chrome-'));
- const direct = new URL('/roadmap' + view.link.search, view.link).href;
let chrome;
try {
- const response = await fetch(direct);
- assert.equal(response.status, 200, 'the direct /roadmap address serves the authenticated view');
- chrome = await openSnapshotChrome(executable, direct, profile);
- await chrome.waitFor("typeof data === 'object' && !!data?.project?.milestones?.length");
+ const direct = await fetch(new URL(roadmap, view.link));
+ assert.equal(direct.status, 200, 'the view serves its page at /roadmap, behind its secret');
+ assert.equal((await fetch(new URL('/roadmap', view.link))).status, 403, 'and nothing there without the secret');
+ chrome = await openSnapshotChrome(executable, new URL(roadmap, view.link).href, profile);
+ const consoleErrors = [];
+ chrome.socket.addEventListener('message', ({ data }) => {
+ const message = JSON.parse(String(data));
+ if (message.method === 'Runtime.consoleAPICalled' && message.params.type === 'error') consoleErrors.push(message.params.args.map((arg) => arg.value ?? arg.description ?? '').join(' '));
+ if (message.method === 'Log.entryAdded' && message.params.entry.level === 'error') consoleErrors.push(message.params.entry.text);
+ });
+ await chrome.send('Log.enable');
+ await settled(chrome, `!!data?.project && ${showing('roadmap', '/roadmap')} && document.querySelectorAll('#roadmap .milestone').length === 3`);
+
+ let seen;
for (const width of [375, 1280]) {
await chrome.send('Emulation.setDeviceMetricsOverride', { width, height: 900, deviceScaleFactor: 1, mobile: false });
- await chrome.waitFor(`innerWidth === ${width} && document.querySelector('[data-pane="roadmap"]:not([hidden])')`);
- const snapshot = JSON.parse(await chrome.evaluate(`JSON.stringify({
- width: innerWidth, client: document.documentElement.clientWidth, scroll: document.documentElement.scrollWidth,
- path: location.pathname, cards: [...document.querySelectorAll('.milestone')].map(card => ({
- name: card.querySelector('h2').textContent,
- note: card.querySelector('.milestone-note')?.textContent,
- value: Number(card.querySelector('[role=progressbar]').getAttribute('aria-valuenow')),
- total: Number(card.querySelector('[role=progressbar]').getAttribute('aria-valuemax')),
- bar: Number(card.querySelector('.milestone-progress rect').getAttribute('width')),
- items: [...card.querySelectorAll('[data-status]')].map(chip => ({ id: chip.closest('[data-go]').dataset.go, status: chip.dataset.status, label: chip.textContent.trim() }))
- }))
- })`));
- assert.equal(snapshot.path, '/roadmap', `${width}px direct address loads the Roadmap tab`);
- assert.ok(snapshot.scroll <= snapshot.client, `${width}px roadmap has no horizontal overflow: ${JSON.stringify(snapshot)}`);
- assert.deepEqual(snapshot.cards.map((card) => card.name), ['First milestone', 'Second milestone'], 'cards retain API milestone order');
- assert.equal(snapshot.cards[0].note, 'A highlighted note for the person.');
- assert.deepEqual(snapshot.cards.map((card) => [card.value, card.total, card.bar]), [[1, 1, 100], [0, 1, 0]], 'visible progress and accessible counts match the API completion counts');
- assert.deepEqual(snapshot.cards.flatMap((card) => card.items.map((item) => [item.id, item.status])), [['item:1', 'verified'], ['item:2', 'open']], 'each chip matches live API item state');
+ await chrome.waitFor(`innerWidth === ${width} && ${showing('roadmap', '/roadmap')}`);
+ seen = await readRoadmap(chrome);
+ assert.deepEqual([seen.address, seen.shown, seen.tab], [roadmap, ['roadmap'], 'roadmap'], `${width}: the direct address shows the Roadmap tab, and only it`);
+ assert.ok(seen.document <= seen.client && seen.body <= seen.client, `${width}: no sideways scroll: ${JSON.stringify(seen)}`);
+ assert.deepEqual(seen.cards.map((card) => card.name), ['Launch', 'Next', 'Later'], `${width}: a card for each milestone, in order`);
+ assert.deepEqual(seen.cards.map((card) => card.note), ['Ships when the review lands; your call on the name.', 'Queued behind Launch.', 'Ideas not filed yet.'], `${width}: each card's note`);
+ assert.deepEqual(seen.cards.map((card) => [card.count, card.progress, card.filled]), [['2/5 done', [2, 5], 0.4], ['0/3 done', [0, 3], 0], [null, null, null]], `${width}: counts and bars say how many items are verified`);
+ assert.deepEqual([seen.cards[2].empty, seen.cards[2].rows.length], ['No items yet.', 0], `${width}: an empty milestone says so, with no bar or count`);
+ const rows = seen.cards.flatMap((card) => card.rows);
+ assert.deepEqual(rows.map(({ id, label, tone }) => ({ id, label, tone })), words, `${width}: each chip shows the word and colour the Items tab gives its item's state`);
+ assert.ok(rows.every((row) => row.seen), `${width}: every chip is on screen`);
+ assert.deepEqual(rows.map((row) => row.title), [...titles.slice(0, 4), 'Billing webhook retries', ...titles.slice(4)], `${width}: each row names its item`);
+ assert.deepEqual(rows.map((row) => row.tip), rows.map((row) => row.title), `${width}: each row's tooltip is its whole title`);
+ assert.ok(rows.every((row) => row.lines === 1 && row.ellipsis), `${width}: every title holds one line, set to end in an ellipsis: ${JSON.stringify(rows)}`);
+ assert.ok(rows.find((row) => row.id === '#6').cut, `${width}: the long title is cut, so its ellipsis shows`);
+ assert.ok(rows.every((row) => row.button), `${width}: every item opens, another repo's included`);
+
+ const bar = await tabBar(chrome);
+ for (const layout of bar.layouts) {
+ const place = `${width} with ${layout.on} picked`;
+ assert.equal(layout.tabs.length, 6, `${place}: six tabs`);
+ for (const tab of layout.tabs) assert.ok(tab.labelLeft >= tab.left + 2 && tab.labelRight <= tab.right - 2, `${place}: ${tab.tab}'s label sits inside its highlight: ${JSON.stringify(tab)}`);
+ layout.tabs.forEach((tab, n) => { if (n) assert.ok(tab.left >= layout.tabs[n - 1].right - 0.5, `${place}: ${tab.tab} starts after the tab before it ends`); });
+ assert.ok(layout.tabs[0].left >= layout.bar[0] - 0.5 && layout.tabs.at(-1).right <= layout.bar[1] + 0.5 && layout.bar[1] <= bar.client, `${place}: the tab bar fits on screen: ${JSON.stringify(layout)}`);
+ }
+ await proofShot(chrome, 'roadmap', width);
+
+ // An item opens on the Items tab; Back shows the Roadmap at its address again, Forward the item.
+ await press(chrome, roadmapRow('#3'));
+ await chrome.waitFor(`${showing('items', '/')} && document.querySelector('#detail h2')?.innerText.includes('Session timeout banner')`);
+ assert.equal(await chrome.evaluate('location.search'), view.link.search, `${width}: the address keeps the rest of itself`);
+ await travel(chrome, -1);
+ await chrome.waitFor(`${showing('roadmap', '/roadmap')} && document.querySelector('.tab.on')?.dataset.tab === 'roadmap'`);
+ await travel(chrome, 1);
+ await chrome.waitFor(`${showing('items', '/')} && document.querySelector('.tab.on')?.dataset.tab === 'items' && document.querySelector('#detail h2')?.innerText.includes('Session timeout banner')`);
+ await press(chrome, `document.querySelector('[data-tab="roadmap"]')`);
+ await chrome.waitFor(`${showing('roadmap', '/roadmap')} && location.search === ${JSON.stringify(view.link.search)}`);
+ }
+
+ // Another repo's item opens on its own board, and Back and Forward move between the two boards.
+ await press(chrome, roadmapRow('beacon#1'));
+ await chrome.waitFor(`document.querySelector('#proj-name').textContent === 'beacon' && ${showing('items', '/')} && document.querySelector('#detail h2')?.innerText.includes('Billing webhook retries')`);
+ const there = JSON.parse(await chrome.evaluate(`JSON.stringify((() => { const chip = document.querySelector('#detail .meta .chip'); return {
+ id: document.querySelector('#detail h2 span').innerText, label: chip.innerText, chip: getComputedStyle(chip).color + ' on ' + getComputedStyle(chip).backgroundColor,
+ dot: getComputedStyle(document.querySelector('#chain [data-item="1"] .dot')).backgroundColor }; })())`));
+ const crossed = seen.cards[0].rows.find((row) => row.id === 'beacon#1');
+ assert.deepEqual(there, { id: '#1', label: crossed.label, chip: crossed.chip, dot: crossed.dot }, "the other repo's Items tab shows that item with the Roadmap's word and colours");
+ await travel(chrome, -1);
+ await chrome.waitFor(`document.querySelector('#proj-name').textContent === 'roadmap-demo' && ${showing('roadmap', '/roadmap')} && !!${roadmapRow('beacon#1')}`);
+ await travel(chrome, 1);
+ await chrome.waitFor(`document.querySelector('#proj-name').textContent === 'beacon' && ${showing('items', '/')} && document.querySelector('#detail h2')?.innerText.includes('Billing webhook retries')`);
+ await travel(chrome, -1);
+ await chrome.waitFor(`document.querySelector('#proj-name').textContent === 'roadmap-demo' && ${showing('roadmap', '/roadmap')} && !!${roadmapRow('#1')}`);
+
+ // Each of this board's rows opens its item on the Items tab, which gives it the same word and
+ // colours, its list dot included; a withdrawn item is left out of the list while browsing.
+ for (const row of seen.cards.flatMap((card) => card.rows).filter((each) => each.id.startsWith('#'))) {
+ await press(chrome, roadmapRow(row.id));
+ await chrome.waitFor(`${showing('items', '/')} && document.querySelector('#detail h2 span')?.innerText === ${JSON.stringify(row.id)}`);
+ const here = JSON.parse(await chrome.evaluate(`JSON.stringify((() => {
+ const chip = document.querySelector('#detail .meta .chip'), dot = document.querySelector('#chain [data-item="${row.id.slice(1)}"] .dot');
+ return { label: chip.innerText, chip: getComputedStyle(chip).color + ' on ' + getComputedStyle(chip).backgroundColor, dot: dot ? getComputedStyle(dot).backgroundColor : 'not listed' };
+ })())`));
+ assert.deepEqual(here, { label: row.label, chip: row.chip, dot: row.label === 'withdrawn' ? 'not listed' : row.dot }, `${row.id}: the Items tab shows it with the Roadmap's word and colours`);
+ await travel(chrome, -1);
+ await chrome.waitFor(`${showing('roadmap', '/roadmap')} && !!${roadmapRow(row.id)}`);
}
- await chrome.evaluate("document.querySelector('[data-go=\"item:1\"]').click()");
- await chrome.waitFor("document.querySelector('[data-pane=items]:not([hidden])') && document.querySelector('#detail').textContent.includes('Verified milestone item')");
- assert.equal(await chrome.evaluate('location.pathname'), '/', 'opening an item leaves the Roadmap address for the Items tab');
- await chrome.evaluate("document.querySelector('[data-tab=roadmap]').click()");
- await chrome.waitFor("location.pathname === '/roadmap'");
- box.run(alpha.web, 'claim', '2');
- await chrome.waitFor("data.project.items.find(item => item.id === 2)?.status === 'claimed' && document.querySelector('[data-go=\"item:2\"] [data-status]')?.dataset.status === 'claimed'", 15_000);
- assert.equal(await chrome.evaluate("document.querySelector('[data-go=\"item:2\"] [data-status]').textContent.trim()"), 'Building', 'the chip updates after a real item move');
+
+ // It updates live as items move, here and on the other repo's board.
+ accept(box, alpha, 4);
+ await chrome.waitFor(`${roadmapRow('#4')}?.querySelector('.chip').innerText === 'verified' && document.querySelector('#roadmap .milestone-count').innerText === '3/5 done'`, 15_000);
+ box.run(beacon.web, 'claim', '1');
+ await chrome.waitFor(`${roadmapRow('beacon#1')}?.querySelector('.chip').innerText === 'building'`, 15_000);
+
+ // A board with no milestones says how one starts; the address stays the Roadmap's.
+ await press(chrome, `document.querySelector('[data-root=${JSON.stringify(beacon.repo)}]')`);
+ await chrome.waitFor(`document.querySelector('#proj-name').textContent === 'beacon' && ${showing('roadmap', '/roadmap')} && document.querySelector('#roadmap').innerText.startsWith('No milestones yet.')`);
+ await press(chrome, `document.querySelector('[data-root=${JSON.stringify(alpha.repo)}]')`);
+ await chrome.waitFor(`document.querySelector('#proj-name').textContent === 'roadmap-demo' && !!${roadmapRow('#1')}`);
+
+ // A reload keeps the Roadmap. The board's own address shows the tab last picked there, never the
+ // Roadmap, even when the Roadmap was picked last.
+ await chrome.send('Page.reload');
+ await settled(chrome, `!!data?.project && ${showing('roadmap', '/roadmap')} && !!${roadmapRow('#1')}`);
+ await press(chrome, `document.querySelector('[data-tab="shouts"]')`);
+ await chrome.waitFor(showing('shouts', '/'));
+ await press(chrome, `document.querySelector('[data-tab="roadmap"]')`);
+ await chrome.waitFor(showing('roadmap', '/roadmap'));
+ await chrome.send('Page.navigate', { url: view.link.href });
+ await settled(chrome, `!!data?.project && ${showing('shouts', '/')} && document.querySelector('.tab.on')?.dataset.tab === 'shouts'`);
assert.deepEqual(chrome.exceptions, [], 'Chrome reports no uncaught page exceptions');
+ assert.deepEqual(consoleErrors, [], 'Chrome reports no console errors');
} finally {
if (chrome) await closeSnapshotChrome(chrome);
await view.stop();
rmSync(profile, { recursive: true, force: true });
}
});
+
+test('an exported roadmap has its own address under a folder, and Back and Forward return to it [N38,A10]', { timeout: 120_000 }, async (t) => {
+ const executable = chromeExecutable();
+ if (!executable) return t.skip('Install Chrome or set PULLBOARD_CHROME for exported roadmap checks.');
+ const box = machine();
+ const alpha = project(box, 'roadmap-snapshot');
+ const beacon = project(box, 'beacon');
+ box.run(alpha.repo, 'add', 'web', 'Verified page', '--specs', 'G1', '--criterion', 'renders');
+ box.run(alpha.repo, 'add', 'web', 'Open page', '--specs', 'G1', '--criterion', 'renders');
+ build(box, alpha, 1, 'one.txt');
+ accept(box, alpha, 1);
+ box.run(beacon.repo, 'add', 'web', 'Billing webhook retries', '--specs', 'G1', '--criterion', 'retries');
+ box.run(alpha.repo, 'milestone', 'add', 'Launch', '--note', 'Ships with the snapshot.', '--items', '1,2,beacon#1');
+ box.run(alpha.repo, 'milestone', 'add', 'Later');
+ const folder = join(box.dir, 'roadmap-export');
+ box.run(alpha.repo, 'view', '--export', folder);
+ const host = await serveFolder(folder, '/demo/');
+ const profile = mkdtempSync(join(tmpdir(), 'pullboard-roadmap-export-chrome-'));
+ const ready = "document.body.classList.contains('snapshot') && !!data?.project && snapshotReplay.index === snapshotReplay.events.length";
+ let chrome;
+ try {
+ chrome = await openSnapshotChrome(executable, `${host.base}/demo/`, profile);
+ await settled(chrome, `${ready} && ${showing('items', '/demo/')}`);
+ await press(chrome, `document.querySelector('[data-tab="roadmap"]')`);
+ await chrome.waitFor(showing('roadmap', '/demo/#roadmap'));
+ const seen = await readRoadmap(chrome);
+ assert.deepEqual(seen.cards[0].rows.map(({ id, label, tone, button }) => ({ id, label, tone, button })), [
+ { id: '#1', label: 'verified', tone: 'ok', button: true },
+ { id: '#2', label: 'open', tone: '', button: true },
+ { id: 'beacon#1', label: 'open', tone: '', button: false },
+ ], "the snapshot's rows read as its Items tab does; another repo's item, not in the snapshot, opens nothing");
+ assert.equal(seen.cards[0].rows[2].tip, 'Billing webhook retries (not in this snapshot)', 'and says why');
+ assert.deepEqual([seen.cards[1].name, seen.cards[1].empty], ['Later', 'No items yet.']);
+
+ // The address survives a reload on a static host, and Back and Forward show the tab it names.
+ await chrome.send('Page.reload');
+ await settled(chrome, `${ready} && ${showing('roadmap', '/demo/#roadmap')} && !!${roadmapRow('#1')}`);
+ await travel(chrome, -1);
+ await chrome.waitFor(showing('items', '/demo/'));
+ await travel(chrome, 1);
+ await chrome.waitFor(showing('roadmap', '/demo/#roadmap'));
+ await press(chrome, roadmapRow('#2'));
+ await chrome.waitFor(`${showing('items', '/demo/')} && document.querySelector('#detail h2')?.innerText.includes('Open page')`);
+ await travel(chrome, -1);
+ await chrome.waitFor(showing('roadmap', '/demo/#roadmap'));
+
+ // Opened afresh, the folder shows the board's tab, and its #roadmap address the Roadmap.
+ for (const [address, pane] of [['/demo/', 'items'], ['/demo/#roadmap', 'roadmap']]) {
+ await chrome.send('Page.navigate', { url: 'about:blank' });
+ await settled(chrome, "location.href === 'about:blank'");
+ await chrome.send('Page.navigate', { url: `${host.base}${address}` });
+ await settled(chrome, `${ready} && ${showing(pane, address)}`);
+ }
+ for (const width of [375, 1280]) {
+ await chrome.send('Emulation.setDeviceMetricsOverride', { width, height: 900, deviceScaleFactor: 1, mobile: false });
+ await chrome.waitFor(`innerWidth === ${width}`);
+ const layout = await readRoadmap(chrome);
+ assert.ok(layout.document <= layout.client && layout.body <= layout.client, `${width}: no sideways scroll in the snapshot: ${JSON.stringify(layout)}`);
+ await proofShot(chrome, 'snapshot-roadmap', width);
+ }
+ assert.deepEqual(host.requests.filter((request) => !request.path.startsWith('/demo/') || request.status !== 200), [], 'every request stays in the folder and finds its file');
+ assert.deepEqual(chrome.exceptions, [], 'Chrome reports no uncaught page exceptions');
+ } finally {
+ if (chrome) await closeSnapshotChrome(chrome);
+ await host.close();
+ rmSync(profile, { recursive: true, force: true });
+ }
+});