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): show the item pipeline [N26,N38]

Corey Olsonb3fac0fe6272
diff --git a/src/cockpit.js b/src/cockpit.js
index 1cbeada3..57e5f943 100644
--- a/src/cockpit.js
+++ b/src/cockpit.js
@@ -106,8 +106,10 @@ export function cockpitPage(key = '', { snapshot = false, readOnly = false, requ
<section data-pane="items" class="two">
<div class="primary">
<section class="card-panel proof-stats" id="proof-stats" aria-label="Board proof stats" hidden></section>
+ <div class="items-view-switch seg" id="items-view-switch" role="group" aria-label="Items view"></div>
<div class="card-panel toolbar"><div class="seg" id="state-chips" role="group" aria-label="Show"></div><select class="lane-pick" id="lane-pick" aria-label="Lane"></select><button class="go" id="new-item" type="button">New item</button></div>
- <div class="card-panel list-card"><ol class="needs" id="needs" aria-label="What needs you" hidden></ol><ol class="chain" id="chain" aria-label="Items"></ol></div>
+ <div class="card-panel list-card" id="item-list"><ol class="needs" id="needs" aria-label="What needs you" hidden></ol><ol class="chain" id="chain" aria-label="Items"></ol></div>
+ <ol class="pipeline" id="pipeline" aria-label="Item pipeline" hidden></ol>
</div>
<aside class="card-panel detail" aria-label="Item detail">
<div id="detail"></div>
@@ -174,6 +176,7 @@ 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;
+ if (location.hash === '#items/pipeline') return 'items';
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. */
@@ -181,7 +184,7 @@ 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, declining: null, state: 'active', rows: { spec: 'decide', doctrine: 'all' }, row: { spec: null, doctrine: null }, agent: null, allAgents: false, agentsHidden: keep('pb.agents') === 'hidden', open: {} };
+const view = { root: keep('pb.project'), tab: addressTab() || homeTab(), itemsView: typeof location !== 'undefined' && location.hash === '#items/pipeline' ? 'pipeline' : 'list', seen: {}, code: {}, item: null, adding: false, declining: null, state: 'active', rows: { spec: 'decide', doctrine: 'all' }, row: { spec: null, doctrine: null }, agent: null, allAgents: false, agentsHidden: keep('pb.agents') === 'hidden', open: {} };
if (snapshot) view.state = 'all';
let data = null;
let seen = '';
@@ -428,6 +431,36 @@ function replay(item) {
return steps;
}
+/** A recorded merge, rather than an accept, is the end of the shipping pipeline. */
+function pipelineStage(item) {
+ if (item.merged) return 'merged';
+ return item.status === 'verified' ? 'accepted' : item.status;
+}
+
+/** The last arrival in this stage; edits, review reservations and renewals do not restart its age. */
+function pipelineSince(item) {
+ if (item.merged) return item.history.findLast((event) => event.kind === 'merged')?.at || item.updatedAt;
+ const arrival = replay(item).findLast((step) => step.move && step.from !== step.move.to);
+ // Lapses are inferred, but the native claim receipt records the deadline that caused them.
+ if (arrival?.move?.verb === 'lapse') {
+ const claim = item.thread?.findLast((entry) => entry.type === 'move' && ['claim', 'renew'].includes(entry.kind));
+ if (claim?.detail?.leaseUntil) return claim.detail.leaseUntil;
+ }
+ return arrival ? arrival.at || item.updatedAt : item.history.find((event) => event.kind === 'add')?.at || item.updatedAt;
+}
+
+/** Render the same board's items in lifecycle order, retaining every item as a detail link. */
+function pipelineCard(items) {
+ const stages = [['open', 'Not started'], ['claimed', 'Building'], ['submitted', 'Waiting for review'], ['accepted', 'Accepted, waiting to merge'], ['merged', 'Merged']];
+ return stages.map(([stage, label]) => {
+ const rows = items.filter((item) => pipelineStage(item) === stage).sort((a, b) => pipelineSince(a).localeCompare(pipelineSince(b)) || a.id - b.id);
+ const oldest = rows[0];
+ return '<li class="card-panel pipeline-stage" data-pipeline-stage="' + stage + '"><header><h2>' + label + '</h2><b data-stage-count="' + stage + '">' + rows.length + '</b></header>'
+ + (oldest ? '<p class="pipeline-oldest">Oldest <button class="ref" type="button" data-item="' + oldest.id + '">#' + oldest.id + '</button> · ' + age(pipelineSince(oldest)) + ' in this stage</p>' : '<p class="pipeline-oldest">No items</p>')
+ + '<ul>' + rows.map((item) => '<li><button class="pipeline-item' + (view.item === item.id ? ' on' : '') + '" type="button" data-item="' + item.id + '"><span>#' + item.id + '</span><span>' + esc(item.title) + '</span></button></li>').join('') + '</ul></li>';
+ }).join('');
+}
+
/** How often each move was made on this board, keyed from>to:verb, from every item's replay. */
function moveCounts(items) {
const counts = new Map();
@@ -1329,6 +1362,11 @@ function render() {
const approved = p.spec.filter((r) => r.status === 'approved');
$('add-specs').placeholder = (approved.length ? approved : p.spec).slice(0, 2).map((r) => r.id).join(',') || 'none yet';
const q = $('q').value.trim().toLowerCase();
+ const pipeline = view.itemsView === 'pipeline';
+ $('items-view-switch').innerHTML = ['list', 'pipeline'].map((mode) => '<button type="button" data-items-view="' + mode + '" aria-pressed="' + (view.itemsView === mode) + '" class="' + (view.itemsView === mode ? 'on' : '') + '">' + (mode === 'list' ? 'List' : 'Pipeline') + '</button>').join('');
+ $('state-chips').hidden = pipeline;
+ $('item-list').hidden = pipeline;
+ $('pipeline').hidden = !pipeline;
// Each chip counts what it would show under the lane and the search. A search looks through every
// state, withdrawn items included; browsing leaves those out.
const matching = (q ? p.items : items)
@@ -1345,7 +1383,7 @@ function render() {
const inLane = (lane) => (i) => !lane || i.lane === lane;
if (view.lane && !matching.some(inLane(view.lane))) view.lane = null;
$('state-chips').innerHTML = Object.keys(names).map((s) => '<button data-state="' + s + '" class="' + (view.state === s ? 'on' : '') + '" type="button">' + names[s] + '<b>' + matching.filter(inLane(view.lane)).filter(inState(s)).length + '</b></button>').join('');
- const inView = matching.filter(inState(view.state));
+ const inView = pipeline ? matching.filter((item) => item.status !== 'withdrawn') : matching.filter(inState(view.state));
const laneCounts = [...inView.reduce((m, i) => m.set(i.lane, (m.get(i.lane) || 0) + 1), new Map())].sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]));
if (view.lane && !laneCounts.some(([lane]) => lane === view.lane)) laneCounts.push([view.lane, 0]);
const pick = $('lane-pick'), options = [['', 'All lanes'], ...laneCounts.map(([lane, n]) => [lane, lane + ' · ' + n])].map(([lane, label]) => '<option value="' + esc(lane) + '">' + esc(label) + '</option>').join('');
@@ -1354,6 +1392,7 @@ function render() {
pick.value = view.lane || '';
pick.hidden = laneCounts.length < 2 && !view.lane;
const shown = inView.filter(inLane(view.lane)).sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));
+ $('pipeline').innerHTML = pipeline ? pipelineCard(shown) : '';
// With nothing picked, the detail shows the first row, and keeps it when a refresh reorders the list.
// 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;
@@ -1616,6 +1655,7 @@ function showTab() {
/** 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';
+ if (tab === 'items' && view.itemsView === 'pipeline') return (routed ? '/' : location.pathname) + location.search + '#items/pipeline';
return routed ? (own ? '/roadmap' : '/') + location.search : location.pathname + location.search + (own ? '#roadmap' : '');
}
@@ -1627,10 +1667,10 @@ function tabHref(tab) {
*/
function address(push = true) {
if (typeof history === 'undefined' || typeof location === 'undefined') return;
- const state = { tab: view.tab, root: view.root, item: view.item };
+ const state = { tab: view.tab, root: view.root, item: view.item, itemsView: view.itemsView };
const href = tabHref(view.tab);
try {
- if (push && href !== location.pathname + location.search + (routed ? '' : location.hash)) history.pushState(state, '', href);
+ if (push && href !== location.pathname + location.search + (location.hash || '')) history.pushState(state, '', href);
else history.replaceState(state, '');
} catch { /* The tab shows all the same. */ }
}
@@ -1641,6 +1681,7 @@ function address(push = true) {
*/
function fromAddress(event) {
const kept = (event && event.state) || {};
+ view.itemsView = location.hash === '#items/pipeline' ? 'pipeline' : kept.itemsView === 'pipeline' && kept.tab !== 'items' ? 'pipeline' : 'list';
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;
@@ -2131,12 +2172,13 @@ $('shouts-pane').addEventListener('click', (event) => {
// Enter shouts; Shift+Enter starts a new line.
$('shout-text').addEventListener('keydown', (event) => { if (event.key === 'Enter' && !event.shiftKey && !event.isComposing) { event.preventDefault(); $('shout-form').requestSubmit(); } });
document.addEventListener('click', (event) => {
- const t = event.target.closest('[data-status],[data-roadmap-all],[data-root],[data-tab],[data-go],[data-item],[data-state],[data-rows],[data-row],[data-row-decision],[data-section-approve],[data-release],[data-shout],[data-new],[data-code],[data-code-all],[data-code-less],#proj-switch,#console');
+ const t = event.target.closest('[data-status],[data-roadmap-all],[data-root],[data-tab],[data-go],[data-item],[data-items-view],[data-state],[data-rows],[data-row],[data-row-decision],[data-section-approve],[data-release],[data-shout],[data-new],[data-code],[data-code-all],[data-code-less],#proj-switch,#console');
if (!event.target.closest('.side')) fold(false);
if (!t) return;
if (t.id === 'proj-switch') { fold(!$('side').classList.contains('open')); return; }
if (t.id === 'console') { t.hidden = true; return; }
if (t.dataset.status) { statusGo(t.dataset.status); return; }
+ if (t.dataset.itemsView) { view.itemsView = t.dataset.itemsView; address(); render(); return; }
if ('roadmapAll' in t.dataset) { view.roadmapOnly = null; render(); return; }
if (t.dataset.root) switchTo(t.dataset.root, t.dataset.go || '');
else if (t.dataset.tab) { view.unread = null; view.roadmapOnly = null; openTab(t.dataset.tab); showTab(); }
diff --git a/src/view.css b/src/view.css
index 6da48af1..e0d34764 100644
--- a/src/view.css
+++ b/src/view.css
@@ -177,6 +177,19 @@ main { padding: 16px 18px 56px; }
.tab { display: grid; justify-items: center; align-content: center; padding: 7px 2px; font-size: clamp(11px, 3.6vw, 13.5px); }
}
.primary { display: grid; gap: 12px; min-width: 0; }
+.items-view-switch { justify-self: start; }
+.pipeline { display: grid; gap: 24px; list-style: none; margin: 0; padding: 0; min-width: 0; }
+.pipeline-stage { position: relative; min-width: 0; padding: 14px; }
+.pipeline-stage + .pipeline-stage::before { content: '↓'; position: absolute; top: -25px; left: 22px; color: var(--ink-faint); }
+.pipeline-stage header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
+.pipeline-stage h2 { margin: 0; font-size: 15px; overflow-wrap: anywhere; }
+.pipeline-stage header > b { font: 600 16px var(--mono); }
+.pipeline-oldest { margin: 6px 0 10px; color: var(--ink-muted); font-size: 12px; }
+.pipeline-stage ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; }
+.pipeline-item { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px; width: 100%; min-height: var(--tap); padding: 6px 8px; text-align: left; border: 0; border-radius: 6px; background: none; cursor: pointer; }
+.pipeline-item:hover, .pipeline-item.on { background: var(--surface-2); }
+.pipeline-item > span:first-child { color: var(--ink-faint); font-family: var(--mono); }
+.pipeline-item > span:last-child { overflow-wrap: anywhere; }
.card-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); min-width: 0; }
/* The Items toolbar is one row: the states, the lane picker, and New item at its end. */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px; }
diff --git a/test/cockpit/item-waits.test.js b/test/cockpit/item-waits.test.js
new file mode 100644
index 00000000..3b9bb689
--- /dev/null
+++ b/test/cockpit/item-waits.test.js
@@ -0,0 +1,132 @@
+/** Cockpit items checks, using the shared real-board fixtures [N26]. */
+import assert from 'node:assert/strict';
+import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
+import { request } from 'node:http';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+import { test } from 'node:test';
+import { addItem, closeBoard, completeCheckBaseline, openBoard } from '../../src/board.js';
+import { tapTarget, SPEC, machine, project, build, sendBack, startView, element, target, openPage, agentEntries, accept, itemRow, boardOf, chromeExecutable, openSnapshotChrome, closeSnapshotChrome, settled } from './fixture.js';
+
+
+test('wait references stay on one line and link to every prerequisite at phone and desktop widths [N26]', { timeout: 90_000 }, async (t) => {
+ const executable = chromeExecutable();
+ if (!executable) return t.skip('Install Chrome or set PULLBOARD_CHROME for prerequisite layout checks.');
+ const box = machine();
+ const demo = project(box, 'waits-demo');
+ box.run(demo.repo, 'add', 'web', 'Prerequisite one', '--specs', 'G1', '--criterion', 'finish first');
+ box.run(demo.repo, 'add', 'web', 'Prerequisite two', '--specs', 'G1', '--criterion', 'finish second');
+ box.run(demo.repo, 'add', 'web', 'Blocked item', '--specs', 'G1', '--criterion', 'wait on both', '--after', '1,2');
+ const view = await startView(box);
+ let chrome;
+ try {
+ chrome = await openSnapshotChrome(executable, view.link.href, join(box.dir, 'waits-chrome'));
+ /** Pick a visible click target only after scrolling and its hit-test position have settled. */
+ const click = async (selector) => {
+ const point = JSON.parse(await chrome.evaluate(`(async () => {
+ const element=document.querySelector(${JSON.stringify(selector)});
+ if (!element) throw Error('missing '+${JSON.stringify(selector)});
+ const visible=()=>{const style=getComputedStyle(element),rect=element.getBoundingClientRect();return style.display!=='none'&&style.visibility!=='hidden'&&rect.width>0&&rect.height>0&&!element.closest('[hidden]');};
+ if(!visible())throw Error('target is not visible: '+${JSON.stringify(selector)});
+ element.scrollIntoView({block:'center'});
+ const point=()=>{const currentElement=document.querySelector(${JSON.stringify(selector)});if(!currentElement)return null;const style=getComputedStyle(currentElement),rect=currentElement.getBoundingClientRect();if(style.display==='none'||style.visibility==='hidden'||rect.width<=0||rect.height<=0||currentElement.closest('[hidden]'))return null;const x=rect.x+rect.width/2,y=rect.y+rect.height/2,hit=document.elementFromPoint(x,y);return {x,y,scrollX,scrollY,rect:{x:rect.x,y:rect.y,width:rect.width,height:rect.height},hit:!!hit&&(hit===currentElement||currentElement.contains(hit))};};
+ const targets=[window,document,...(()=>{const nodes=[];for(let node=element.parentElement;node;node=node.parentElement)if(node.scrollHeight>node.clientHeight||node.scrollWidth>node.clientWidth)nodes.push(node);return nodes;})()];
+ let scrolled=false,scrollEnded=false;
+ const onScroll=()=>{scrolled=true;};
+ const onScrollEnd=()=>{scrollEnded=true;};
+ targets.forEach(target=>{target.addEventListener('scroll',onScroll,{passive:true});target.addEventListener('scrollend',onScrollEnd);});
+ try {
+ return JSON.stringify(await new Promise((resolve,reject)=>{
+ let previous=null,stable=0,frameId=0,finished=false;
+ const timeout=setTimeout(()=>{finished=true;cancelAnimationFrame(frameId);reject(Error('scroll did not settle for '+${JSON.stringify(selector)}+': '+JSON.stringify(previous)));},5000);
+ const frame=()=>{
+ if(finished)return;
+ const current=point();
+ if(!current){previous=null;stable=0;frameId=requestAnimationFrame(frame);return;}
+ const same=previous&&Math.abs(current.scrollX-previous.scrollX)<=.1&&Math.abs(current.scrollY-previous.scrollY)<=.1&&Math.abs(current.rect.x-previous.rect.x)<=.1&&Math.abs(current.rect.y-previous.rect.y)<=.1&&Math.abs(current.rect.width-previous.rect.width)<=.1&&Math.abs(current.rect.height-previous.rect.height)<=.1;
+ stable=same?stable+1:0;previous=current;
+ if(stable>=3&&current.hit&&(!scrolled||scrollEnded||stable>=12)){finished=true;clearTimeout(timeout);resolve(current);return;}
+ frameId=requestAnimationFrame(frame);
+ };
+ frameId=requestAnimationFrame(frame);
+ }));
+ } finally { targets.forEach(target=>{target.removeEventListener('scroll',onScroll);target.removeEventListener('scrollend',onScrollEnd);}); }
+ })()`));
+ const deadline = Date.now() + 5000;
+ let ready;
+ let settled = false;
+ while (Date.now() < deadline) {
+ ready = JSON.parse(await chrome.evaluate(`(async()=>{
+ const sample=()=>{const element=document.querySelector(${JSON.stringify(selector)});if(!element)return null;const style=getComputedStyle(element),rect=element.getBoundingClientRect();if(style.display==='none'||style.visibility==='hidden'||rect.width<=0||rect.height<=0||element.closest('[hidden]'))return null;const x=rect.x+rect.width/2,y=rect.y+rect.height/2,hit=document.elementFromPoint(x,y);return {x,y,scrollX,scrollY,rect:{x:rect.x,y:rect.y,width:rect.width,height:rect.height},hit:!!hit&&(hit===element||element.contains(hit))};};
+ let previous=null,stable=0,current=null,frameId=0,finished=false;
+ await new Promise((resolve,reject)=>{const timeout=setTimeout(()=>{finished=true;cancelAnimationFrame(frameId);reject(Error('pointer target did not stabilize for '+${JSON.stringify(selector)}));},1500);const frame=()=>{if(finished)return;current=sample();const same=current&&previous&&Math.abs(current.scrollX-previous.scrollX)<=.1&&Math.abs(current.scrollY-previous.scrollY)<=.1&&Math.abs(current.rect.x-previous.rect.x)<=.1&&Math.abs(current.rect.y-previous.rect.y)<=.1&&Math.abs(current.rect.width-previous.rect.width)<=.1&&Math.abs(current.rect.height-previous.rect.height)<=.1;stable=same?stable+1:0;previous=current;if(stable>=2&&current.hit){finished=true;clearTimeout(timeout);resolve();}else frameId=requestAnimationFrame(frame);};frameId=requestAnimationFrame(frame);});
+ return JSON.stringify(current);
+ })()`));
+ await chrome.send('Input.dispatchMouseEvent', { type: 'mouseMoved', x: ready.x, y: ready.y });
+ const underPointer = JSON.parse(await chrome.evaluate(`(async()=>{
+ const sample=()=>{const element=document.querySelector(${JSON.stringify(selector)});if(!element)return null;const rect=element.getBoundingClientRect(),hit=document.elementFromPoint(${ready.x},${ready.y});return {scrollX,scrollY,rect:{x:rect.x,y:rect.y,width:rect.width,height:rect.height},hit:!!hit&&(hit===element||element.contains(hit))};};
+ let previous=null,stable=0,current=null,frameId=0,finished=false;
+ await new Promise((resolve,reject)=>{const timeout=setTimeout(()=>{finished=true;cancelAnimationFrame(frameId);reject(Error('pointer target did not stabilize for '+${JSON.stringify(selector)}));},1000);const frame=()=>{if(finished)return;current=sample();const same=current&&previous&&Math.abs(current.scrollX-previous.scrollX)<=.1&&Math.abs(current.scrollY-previous.scrollY)<=.1&&Math.abs(current.rect.x-previous.rect.x)<=.1&&Math.abs(current.rect.y-previous.rect.y)<=.1&&Math.abs(current.rect.width-previous.rect.width)<=.1&&Math.abs(current.rect.height-previous.rect.height)<=.1;stable=same?stable+1:0;previous=current;if(stable>=2&&current.hit){finished=true;clearTimeout(timeout);resolve();}else frameId=requestAnimationFrame(frame);};frameId=requestAnimationFrame(frame);});return JSON.stringify({current,stable});
+ })()`));
+ if (underPointer?.current?.hit && underPointer.stable >= 2 && Math.abs(underPointer.current.scrollX-ready.scrollX)<=.1 && Math.abs(underPointer.current.scrollY-ready.scrollY)<=.1 && Math.abs(underPointer.current.rect.x-ready.rect.x)<=.1 && Math.abs(underPointer.current.rect.y-ready.rect.y)<=.1 && Math.abs(underPointer.current.rect.width-ready.rect.width)<=.1 && Math.abs(underPointer.current.rect.height-ready.rect.height)<=.1) {
+ point.x = ready.x;
+ point.y = ready.y;
+ point.scrollX = ready.scrollX;
+ point.scrollY = ready.scrollY;
+ point.rect = ready.rect;
+ settled = true;
+ break;
+ }
+ }
+ assert.ok(settled && ready && point.x === ready.x && point.y === ready.y,
+ `${selector}: scroll and target geometry settle under the pointer before press: ${JSON.stringify({ point, ready })}`);
+ await chrome.send('Input.dispatchMouseEvent', { type: 'mousePressed', x: point.x, y: point.y, button: 'left', clickCount: 1 });
+ await chrome.send('Input.dispatchMouseEvent', { type: 'mouseReleased', x: point.x, y: point.y, button: 'left', clickCount: 1 });
+ };
+ 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('#chain [data-item="3"] .meta .gate')?.getBoundingClientRect().width > 0`);
+ await click('#chain [data-item="1"] .t');
+ await chrome.waitFor("document.querySelector('#detail h2')?.textContent.includes('Prerequisite one')");
+ const itemIds = await chrome.evaluate('data.project.items.map(item => item.id + ":" + item.title + ":" + item.blockedBy.join(","))');
+ assert.ok(await chrome.evaluate('!!document.querySelector(\'#chain [data-item="3"]\')'), `${width}: blocked item appears among ${itemIds.join('; ')}`);
+ const list = JSON.parse(await chrome.evaluate(`JSON.stringify((() => {
+ const gate=document.querySelector('#chain [data-item="3"] .meta .gate');
+ const lineHeight=e=>parseFloat(getComputedStyle(e).lineHeight);
+ const neighbors=[...gate.parentElement.children].filter(e=>e!==gate).map(lineHeight).filter(Number.isFinite);
+ const units=[...gate.querySelectorAll('.wait-unit')];
+ return {height:gate.getBoundingClientRect().height,neighborHeight:Math.max(...neighbors),unitWhiteSpaces:units.map(unit=>getComputedStyle(unit).whiteSpace),unitY:units.map(unit=>unit.getBoundingClientRect().y),links:[...gate.querySelectorAll('button.ref')].map(link=>link.dataset.go)};
+ })())`));
+ t.diagnostic(`${width}px list wait marker: ${list.height}px tall, neighboring metadata line ${list.neighborHeight}px`);
+ assert.ok(list.height <= list.neighborHeight + 1, `${width}: list reference matches neighboring metadata height: ${JSON.stringify(list)}`);
+ assert.deepEqual(list.unitWhiteSpaces, ['nowrap', 'nowrap'], `${width}: each list prerequisite stays intact`);
+ assert.equal(new Set(list.unitY).size, 1, `${width}: both list prerequisites fit on one line: ${JSON.stringify(list)}`);
+ assert.deepEqual(list.links, ['item:1', 'item:2'], `${width}: every prerequisite is a link`);
+
+ await click('#chain [data-item="3"] .t');
+ await chrome.waitFor("!!document.querySelector('#detail .kv dd.waits-on')");
+ const detail = JSON.parse(await chrome.evaluate(`JSON.stringify((() => {
+ const waits=document.querySelector('#detail .kv dd.waits-on');
+ const units=[...waits.querySelectorAll('.wait-unit')];
+ return {height:waits.getBoundingClientRect().height,lineHeight:parseFloat(getComputedStyle(waits).lineHeight),unitWhiteSpaces:units.map(unit=>getComputedStyle(unit).whiteSpace),unitY:units.map(unit=>unit.getBoundingClientRect().y),
+ links:[...waits.querySelectorAll('button.ref')].map(link=>link.dataset.go)};
+ })())`));
+ t.diagnostic(`${width}px detail wait marker: ${detail.height}px tall, neighboring metadata line ${detail.lineHeight}px`);
+ assert.ok(detail.height <= detail.lineHeight + 1, `${width}: detail prerequisite line matches its metadata: ${JSON.stringify(detail)}`);
+ assert.deepEqual(detail.unitWhiteSpaces, ['nowrap', 'nowrap'], `${width}: each detail prerequisite stays intact`);
+ assert.deepEqual(detail.links, ['item:1', 'item:2'], `${width}: detail links every prerequisite`);
+ assert.equal(new Set(detail.unitY).size, 1, `${width}: detail links share one line: ${JSON.stringify(detail)}`);
+ t.diagnostic(`${width}px detail wait links share y=${detail.unitY[0]}`);
+ for (const [id, title] of [['1', 'Prerequisite one'], ['2', 'Prerequisite two']]) {
+ await click('#chain [data-item="3"] .t');
+ await chrome.waitFor("!!document.querySelector('#detail .kv dd.waits-on')");
+ await click(`#detail .waits-on [data-go="item:${id}"]`);
+ await chrome.waitFor(`document.querySelector('#detail h2').textContent.includes(${JSON.stringify(title)})`);
+ }
+ }
+ assert.deepEqual(chrome.exceptions, [], 'Chrome reports no uncaught page exceptions');
+ } finally {
+ if (chrome) await closeSnapshotChrome(chrome);
+ await view.stop();
+ }
+});
diff --git a/test/cockpit/items.test.js b/test/cockpit/items.test.js
index fda646d4..1931083d 100644
--- a/test/cockpit/items.test.js
+++ b/test/cockpit/items.test.js
@@ -1,12 +1,13 @@
/** Cockpit items checks, using the shared real-board fixtures [N26]. */
import assert from 'node:assert/strict';
-import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
+import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
import { request } from 'node:http';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { test } from 'node:test';
+import * as store from '../../src/board.js';
import { addItem, closeBoard, completeCheckBaseline, openBoard } from '../../src/board.js';
-import { tapTarget, SPEC, machine, project, build, sendBack, startView, element, target, openPage, agentEntries, accept, itemRow, boardOf, chromeExecutable, openSnapshotChrome, closeSnapshotChrome, settled } from './fixture.js';
+import { tapTarget, SPEC, machine, project, build, sendBack, startView, element, target, openPage, agentEntries, accept, itemRow, boardOf, chromeExecutable, openSnapshotChrome, closeSnapshotChrome, settled, earlier, press, travel } from './fixture.js';
test('an added item confirmation names its returned id [A3,N27]', async () => {
@@ -854,124 +855,122 @@ test('list rows hold their shape: one-line titles end in an ellipsis, every row
}
});
-test('wait references stay on one line and link to every prerequisite at phone and desktop widths [N26]', { timeout: 90_000 }, async (t) => {
+/** Native lifecycle writers on a private clock give each pipeline stage a known arrival. */
+function pipelineBoard(box, alpha) {
+ const base = Date.now() - 60 * 60_000, commit = box.git(alpha.repo, 'rev-parse', 'HEAD'), tree = box.git(alpha.repo, 'rev-parse', 'HEAD^{tree}'), digest = 'a'.repeat(64);
+ const at = (minute, move) => earlier(alpha.repo, base + minute * 60_000, move);
+ at(0, board => store.register(board, { lane: 'tests', path: join(box.dir, 'pipeline-reviewer') }));
+ for (const [id, minute] of [[1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 2]]) at(minute, board => store.addItem(board, { by: 'coordinator', lane: 'web', title: 'Pipeline item ' + id + (id === 6 ? ' ' + 'Averylongword'.repeat(35) : ''), specIds: ['G1'], criterion: 'Shows the stage' }));
+ const claim = (id, minute) => at(minute, board => store.claim(board, id, { agentId: 'web-1', lane: 'web', leaseMs: 24 * 60 * 60_000, head: commit, freeze: () => ({ text: '{}', digest }) }));
+ const submit = (id, minute) => at(minute, board => store.submit(board, id, { agentId: 'web-1', commit, tree }));
+ const acceptAt = (id, minute) => at(minute, board => store.verify(board, id, { agentId: 'tests-1', decision: 'ACCEPT', note: 'Private pipeline fixture', head: commit, digest, policy: 'any' }));
+ claim(1, 3); submit(1, 4); acceptAt(1, 5);
+ at(6, board => store.merged(board, 1, { agentId: 'coordinator', commit }));
+ claim(2, 7); submit(2, 8); acceptAt(2, 9);
+ claim(3, 10); submit(3, 11); claim(4, 12); claim(4, 20);
+ at(20, board => store.editItem(board, 5, { agentId: 'coordinator', brief: 'Edited after the newer open item was added' }));
+ return { base, arrivals: { open: [5, 0], claimed: [4, 12], submitted: [3, 11], accepted: [2, 9], merged: [1, 6] } };
+}
+
+test('Pipeline view shows every stage, status counts, stage ages, detail links and its phone address [N26,N38]', { timeout: 120_000 }, async () => {
const executable = chromeExecutable();
- if (!executable) return t.skip('Install Chrome or set PULLBOARD_CHROME for prerequisite layout checks.');
- const box = machine();
- const demo = project(box, 'waits-demo');
- box.run(demo.repo, 'add', 'web', 'Prerequisite one', '--specs', 'G1', '--criterion', 'finish first');
- box.run(demo.repo, 'add', 'web', 'Prerequisite two', '--specs', 'G1', '--criterion', 'finish second');
- box.run(demo.repo, 'add', 'web', 'Blocked item', '--specs', 'G1', '--criterion', 'wait on both', '--after', '1,2');
- const view = await startView(box);
+ assert.ok(executable, 'Chrome is required for the Pipeline view criterion');
+ const box = machine(), alpha = project(box, 'pipeline-board');
+ const { base, arrivals } = pipelineBoard(box, alpha);
+ const status = JSON.parse(box.run(alpha.repo, 'status', '--json')).stats.items;
+ assert.deepEqual(status, { open: 2, claimed: 1, submitted: 1, verified: 2, withdrawn: 0 });
+ const view = await startView(box), profile = mkdtempSync(join(tmpdir(), 'pullboard-pipeline-chrome-'));
let chrome;
try {
- chrome = await openSnapshotChrome(executable, view.link.href, join(box.dir, 'waits-chrome'));
- /** Pick a visible click target only after scrolling and its hit-test position have settled. */
- const click = async (selector) => {
- const point = JSON.parse(await chrome.evaluate(`(async () => {
- const element=document.querySelector(${JSON.stringify(selector)});
- if (!element) throw Error('missing '+${JSON.stringify(selector)});
- const visible=()=>{const style=getComputedStyle(element),rect=element.getBoundingClientRect();return style.display!=='none'&&style.visibility!=='hidden'&&rect.width>0&&rect.height>0&&!element.closest('[hidden]');};
- if(!visible())throw Error('target is not visible: '+${JSON.stringify(selector)});
- element.scrollIntoView({block:'center'});
- const point=()=>{const currentElement=document.querySelector(${JSON.stringify(selector)});if(!currentElement)return null;const style=getComputedStyle(currentElement),rect=currentElement.getBoundingClientRect();if(style.display==='none'||style.visibility==='hidden'||rect.width<=0||rect.height<=0||currentElement.closest('[hidden]'))return null;const x=rect.x+rect.width/2,y=rect.y+rect.height/2,hit=document.elementFromPoint(x,y);return {x,y,scrollX,scrollY,rect:{x:rect.x,y:rect.y,width:rect.width,height:rect.height},hit:!!hit&&(hit===currentElement||currentElement.contains(hit))};};
- const targets=[window,document,...(()=>{const nodes=[];for(let node=element.parentElement;node;node=node.parentElement)if(node.scrollHeight>node.clientHeight||node.scrollWidth>node.clientWidth)nodes.push(node);return nodes;})()];
- let scrolled=false,scrollEnded=false;
- const onScroll=()=>{scrolled=true;};
- const onScrollEnd=()=>{scrollEnded=true;};
- targets.forEach(target=>{target.addEventListener('scroll',onScroll,{passive:true});target.addEventListener('scrollend',onScrollEnd);});
- try {
- return JSON.stringify(await new Promise((resolve,reject)=>{
- let previous=null,stable=0,frameId=0,finished=false;
- const timeout=setTimeout(()=>{finished=true;cancelAnimationFrame(frameId);reject(Error('scroll did not settle for '+${JSON.stringify(selector)}+': '+JSON.stringify(previous)));},5000);
- const frame=()=>{
- if(finished)return;
- const current=point();
- if(!current){previous=null;stable=0;frameId=requestAnimationFrame(frame);return;}
- const same=previous&&Math.abs(current.scrollX-previous.scrollX)<=.1&&Math.abs(current.scrollY-previous.scrollY)<=.1&&Math.abs(current.rect.x-previous.rect.x)<=.1&&Math.abs(current.rect.y-previous.rect.y)<=.1&&Math.abs(current.rect.width-previous.rect.width)<=.1&&Math.abs(current.rect.height-previous.rect.height)<=.1;
- stable=same?stable+1:0;previous=current;
- if(stable>=3&&current.hit&&(!scrolled||scrollEnded||stable>=12)){finished=true;clearTimeout(timeout);resolve(current);return;}
- frameId=requestAnimationFrame(frame);
- };
- frameId=requestAnimationFrame(frame);
- }));
- } finally { targets.forEach(target=>{target.removeEventListener('scroll',onScroll);target.removeEventListener('scrollend',onScrollEnd);}); }
- })()`));
- const deadline = Date.now() + 5000;
- let ready;
- let settled = false;
- while (Date.now() < deadline) {
- ready = JSON.parse(await chrome.evaluate(`(async()=>{
- const sample=()=>{const element=document.querySelector(${JSON.stringify(selector)});if(!element)return null;const style=getComputedStyle(element),rect=element.getBoundingClientRect();if(style.display==='none'||style.visibility==='hidden'||rect.width<=0||rect.height<=0||element.closest('[hidden]'))return null;const x=rect.x+rect.width/2,y=rect.y+rect.height/2,hit=document.elementFromPoint(x,y);return {x,y,scrollX,scrollY,rect:{x:rect.x,y:rect.y,width:rect.width,height:rect.height},hit:!!hit&&(hit===element||element.contains(hit))};};
- let previous=null,stable=0,current=null,frameId=0,finished=false;
- await new Promise((resolve,reject)=>{const timeout=setTimeout(()=>{finished=true;cancelAnimationFrame(frameId);reject(Error('pointer target did not stabilize for '+${JSON.stringify(selector)}));},1500);const frame=()=>{if(finished)return;current=sample();const same=current&&previous&&Math.abs(current.scrollX-previous.scrollX)<=.1&&Math.abs(current.scrollY-previous.scrollY)<=.1&&Math.abs(current.rect.x-previous.rect.x)<=.1&&Math.abs(current.rect.y-previous.rect.y)<=.1&&Math.abs(current.rect.width-previous.rect.width)<=.1&&Math.abs(current.rect.height-previous.rect.height)<=.1;stable=same?stable+1:0;previous=current;if(stable>=2&&current.hit){finished=true;clearTimeout(timeout);resolve();}else frameId=requestAnimationFrame(frame);};frameId=requestAnimationFrame(frame);});
- return JSON.stringify(current);
- })()`));
- await chrome.send('Input.dispatchMouseEvent', { type: 'mouseMoved', x: ready.x, y: ready.y });
- const underPointer = JSON.parse(await chrome.evaluate(`(async()=>{
- const sample=()=>{const element=document.querySelector(${JSON.stringify(selector)});if(!element)return null;const rect=element.getBoundingClientRect(),hit=document.elementFromPoint(${ready.x},${ready.y});return {scrollX,scrollY,rect:{x:rect.x,y:rect.y,width:rect.width,height:rect.height},hit:!!hit&&(hit===element||element.contains(hit))};};
- let previous=null,stable=0,current=null,frameId=0,finished=false;
- await new Promise((resolve,reject)=>{const timeout=setTimeout(()=>{finished=true;cancelAnimationFrame(frameId);reject(Error('pointer target did not stabilize for '+${JSON.stringify(selector)}));},1000);const frame=()=>{if(finished)return;current=sample();const same=current&&previous&&Math.abs(current.scrollX-previous.scrollX)<=.1&&Math.abs(current.scrollY-previous.scrollY)<=.1&&Math.abs(current.rect.x-previous.rect.x)<=.1&&Math.abs(current.rect.y-previous.rect.y)<=.1&&Math.abs(current.rect.width-previous.rect.width)<=.1&&Math.abs(current.rect.height-previous.rect.height)<=.1;stable=same?stable+1:0;previous=current;if(stable>=2&&current.hit){finished=true;clearTimeout(timeout);resolve();}else frameId=requestAnimationFrame(frame);};frameId=requestAnimationFrame(frame);});return JSON.stringify({current,stable});
- })()`));
- if (underPointer?.current?.hit && underPointer.stable >= 2 && Math.abs(underPointer.current.scrollX-ready.scrollX)<=.1 && Math.abs(underPointer.current.scrollY-ready.scrollY)<=.1 && Math.abs(underPointer.current.rect.x-ready.rect.x)<=.1 && Math.abs(underPointer.current.rect.y-ready.rect.y)<=.1 && Math.abs(underPointer.current.rect.width-ready.rect.width)<=.1 && Math.abs(underPointer.current.rect.height-ready.rect.height)<=.1) {
- point.x = ready.x;
- point.y = ready.y;
- point.scrollX = ready.scrollX;
- point.scrollY = ready.scrollY;
- point.rect = ready.rect;
- settled = true;
- break;
- }
- }
- assert.ok(settled && ready && point.x === ready.x && point.y === ready.y,
- `${selector}: scroll and target geometry settle under the pointer before press: ${JSON.stringify({ point, ready })}`);
- await chrome.send('Input.dispatchMouseEvent', { type: 'mousePressed', x: point.x, y: point.y, button: 'left', clickCount: 1 });
- await chrome.send('Input.dispatchMouseEvent', { type: 'mouseReleased', x: point.x, y: point.y, button: 'left', clickCount: 1 });
- };
+ chrome = await openSnapshotChrome(executable, view.link.href, profile);
+ await chrome.waitFor(`data?.project?.root === ${JSON.stringify(alpha.repo)} && document.querySelector('#chain [data-item="5"]')`);
+ const listRead = "JSON.stringify([...document.querySelectorAll('#chain > li[data-item]')].map(row => ({id:Number(row.dataset.item),title:row.title,meta:row.querySelector('.meta').textContent,tag:row.lastElementChild.textContent})))";
+ const listBefore = await chrome.evaluate(listRead);
+ await press(chrome, "document.querySelector('[data-items-view=\"pipeline\"]')");
+ assert.equal(await chrome.evaluate('location.hash'), '#items/pipeline', 'Pipeline has its own shareable address');
+ await chrome.waitFor("location.hash === '#items/pipeline' && !document.querySelector('#pipeline').hidden");
+ const expectedCounts = [status.open, status.claimed, status.submitted, 1, 1];
+ const read = JSON.parse(await chrome.evaluate(`JSON.stringify([...document.querySelectorAll('[data-pipeline-stage]')].map(stage => ({ stage:stage.dataset.pipelineStage, label:stage.querySelector('h2').textContent, count:Number(stage.querySelector('[data-stage-count]').textContent), oldest:Number(stage.querySelector('.pipeline-oldest [data-item]')?.dataset.item || 0), since:stage.querySelector('.pipeline-oldest time')?.dataset.ago || null, age:stage.querySelector('.pipeline-oldest time')?.textContent || '', ids:[...stage.querySelectorAll('.pipeline-item')].map(item => Number(item.dataset.item)) })))`));
+ assert.deepEqual(read.map(stage => stage.label), ['Not started', 'Building', 'Waiting for review', 'Accepted, waiting to merge', 'Merged']);
+ assert.deepEqual(read.map(stage => stage.count), expectedCounts, 'open/claimed/submitted match status; accepted plus merged equals verified');
+ assert.equal(read[3].count + read[4].count, status.verified);
+ assert.deepEqual(read.map(stage => stage.ids), [[5, 6], [4], [3], [2], [1]], 'an accept without a merge remains waiting to merge');
+ const observedAt = await chrome.evaluate('Date.now()');
+ for (const stage of read) {
+ const [id, minute] = arrivals[stage.stage], since = new Date(base + minute * 60_000).toISOString();
+ assert.equal(stage.oldest, id, stage.stage + ': oldest item');
+ assert.equal(stage.since, since, stage.stage + ': stage arrival survives edit or lease renewal');
+ assert.ok(stage.age.length > 0, stage.stage + ': visible elapsed age');
+ assert.match(stage.age, /^\d+(m|h)$/, stage.stage + ': a visible elapsed time');
+ const elapsed = parseInt(stage.age, 10) * (stage.age.endsWith('h') ? 60 : 1);
+ assert.ok(Math.abs(elapsed - (observedAt - Date.parse(since)) / 60_000) <= 1, stage.stage + ': elapsed time matches native fixture arrival');
+ }
+ assert.equal(await chrome.evaluate("document.querySelector('#item-list').hidden"), true);
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('#chain [data-item="3"] .meta .gate')?.getBoundingClientRect().width > 0`);
- await click('#chain [data-item="1"] .t');
- await chrome.waitFor("document.querySelector('#detail h2')?.textContent.includes('Prerequisite one')");
- const itemIds = await chrome.evaluate('data.project.items.map(item => item.id + ":" + item.title + ":" + item.blockedBy.join(","))');
- assert.ok(await chrome.evaluate('!!document.querySelector(\'#chain [data-item="3"]\')'), `${width}: blocked item appears among ${itemIds.join('; ')}`);
- const list = JSON.parse(await chrome.evaluate(`JSON.stringify((() => {
- const gate=document.querySelector('#chain [data-item="3"] .meta .gate');
- const lineHeight=e=>parseFloat(getComputedStyle(e).lineHeight);
- const neighbors=[...gate.parentElement.children].filter(e=>e!==gate).map(lineHeight).filter(Number.isFinite);
- const units=[...gate.querySelectorAll('.wait-unit')];
- return {height:gate.getBoundingClientRect().height,neighborHeight:Math.max(...neighbors),unitWhiteSpaces:units.map(unit=>getComputedStyle(unit).whiteSpace),unitY:units.map(unit=>unit.getBoundingClientRect().y),links:[...gate.querySelectorAll('button.ref')].map(link=>link.dataset.go)};
- })())`));
- t.diagnostic(`${width}px list wait marker: ${list.height}px tall, neighboring metadata line ${list.neighborHeight}px`);
- assert.ok(list.height <= list.neighborHeight + 1, `${width}: list reference matches neighboring metadata height: ${JSON.stringify(list)}`);
- assert.deepEqual(list.unitWhiteSpaces, ['nowrap', 'nowrap'], `${width}: each list prerequisite stays intact`);
- assert.equal(new Set(list.unitY).size, 1, `${width}: both list prerequisites fit on one line: ${JSON.stringify(list)}`);
- assert.deepEqual(list.links, ['item:1', 'item:2'], `${width}: every prerequisite is a link`);
-
- await click('#chain [data-item="3"] .t');
- await chrome.waitFor("!!document.querySelector('#detail .kv dd.waits-on')");
- const detail = JSON.parse(await chrome.evaluate(`JSON.stringify((() => {
- const waits=document.querySelector('#detail .kv dd.waits-on');
- const units=[...waits.querySelectorAll('.wait-unit')];
- return {height:waits.getBoundingClientRect().height,lineHeight:parseFloat(getComputedStyle(waits).lineHeight),unitWhiteSpaces:units.map(unit=>getComputedStyle(unit).whiteSpace),unitY:units.map(unit=>unit.getBoundingClientRect().y),
- links:[...waits.querySelectorAll('button.ref')].map(link=>link.dataset.go)};
- })())`));
- t.diagnostic(`${width}px detail wait marker: ${detail.height}px tall, neighboring metadata line ${detail.lineHeight}px`);
- assert.ok(detail.height <= detail.lineHeight + 1, `${width}: detail prerequisite line matches its metadata: ${JSON.stringify(detail)}`);
- assert.deepEqual(detail.unitWhiteSpaces, ['nowrap', 'nowrap'], `${width}: each detail prerequisite stays intact`);
- assert.deepEqual(detail.links, ['item:1', 'item:2'], `${width}: detail links every prerequisite`);
- assert.equal(new Set(detail.unitY).size, 1, `${width}: detail links share one line: ${JSON.stringify(detail)}`);
- t.diagnostic(`${width}px detail wait links share y=${detail.unitY[0]}`);
- for (const [id, title] of [['1', 'Prerequisite one'], ['2', 'Prerequisite two']]) {
- await click('#chain [data-item="3"] .t');
- await chrome.waitFor("!!document.querySelector('#detail .kv dd.waits-on')");
- await click(`#detail .waits-on [data-go="item:${id}"]`);
- await chrome.waitFor(`document.querySelector('#detail h2').textContent.includes(${JSON.stringify(title)})`);
+ await chrome.waitFor(`innerWidth === ${width}`);
+ for (const scheme of ['light', 'dark']) {
+ await chrome.send('Emulation.setEmulatedMedia', { features: [{name:'prefers-color-scheme',value:scheme}] });
+ await chrome.evaluate('(async()=>{await new Promise(requestAnimationFrame);await new Promise(requestAnimationFrame)})()');
+ assert.equal(await chrome.evaluate('document.documentElement.dataset.scheme'), scheme);
+ for (const id of [1, 2, 3, 4, 5, 6]) {
+ await press(chrome, `document.querySelector('#pipeline .pipeline-item[data-item="${id}"]')`);
+ assert.equal(await chrome.evaluate('view.item'), id, `${width}: every item opens its detail`);
+ await chrome.waitFor(`document.querySelector('#detail h2')?.textContent.includes('#${id}')`);
+ }
+ const geometry = JSON.parse(await chrome.evaluate("JSON.stringify({ width:innerWidth, body:document.documentElement.scrollWidth, stages:[...document.querySelectorAll('.pipeline-stage')].map(node => ({left:node.getBoundingClientRect().left,right:node.getBoundingClientRect().right})) })"));
+ assert.ok(geometry.body <= width, `${width}: no sideways scroll: ${JSON.stringify(geometry)}`);
+ assert.ok(geometry.stages.every(stage => stage.left >= 0 && stage.right <= width), `${width}: the flow fits the screen`);
+ if (process.env.PULLBOARD_PIPELINE_SHOTS) {
+ mkdirSync(process.env.PULLBOARD_PIPELINE_SHOTS, {recursive:true});
+ await chrome.evaluate('scrollTo(0,0)');
+ const shot = await chrome.send('Page.captureScreenshot', {format:'png',captureBeyondViewport:true});
+ writeFileSync(join(process.env.PULLBOARD_PIPELINE_SHOTS, `pipeline-${width}-${scheme}.png`), Buffer.from(shot.data,'base64'));
+ }
}
}
- assert.deepEqual(chrome.exceptions, [], 'Chrome reports no uncaught page exceptions');
+ box.run(alpha.repo, 'merged', '2', box.git(alpha.repo, 'rev-parse', 'HEAD'));
+ await chrome.waitFor("document.querySelector('[data-stage-count=accepted]').textContent === '0' && document.querySelector('[data-stage-count=merged]').textContent === '2'");
+ assert.equal(await chrome.evaluate("document.querySelector('[data-pipeline-stage=accepted] .pipeline-oldest').textContent"), 'No items', 'a recorded merge advances only the accepted item and leaves an honest empty stage');
+ await press(chrome, "document.querySelector('[data-items-view=\"list\"]')");
+ await chrome.waitFor("!location.hash && !document.querySelector('#item-list').hidden && document.querySelector('#pipeline').hidden");
+ assert.equal(await chrome.evaluate(listRead), listBefore, 'returning to List preserves its Active rows, metadata and ordering');
+ assert.deepEqual(JSON.parse(listBefore).map(row => row.id).sort((a,b)=>a-b), [3,4,5,6]);
+ await travel(chrome, -1);
+ await settled(chrome, "location.hash === '#items/pipeline' && !document.querySelector('#pipeline').hidden");
+ await chrome.send('Page.reload', {});
+ await settled(chrome, "location.hash === '#items/pipeline' && data?.project && !document.querySelector('#pipeline').hidden");
+ assert.equal(await chrome.evaluate("document.querySelector('.tab.on').dataset.tab"), 'items', 'the Pipeline address reloads within Items');
+ await travel(chrome, 1);
+ await settled(chrome, "!location.hash && !document.querySelector('#item-list').hidden");
+ assert.deepEqual(chrome.exceptions, [], 'the pipeline has no uncaught page errors');
} finally {
if (chrome) await closeSnapshotChrome(chrome);
await view.stop();
+ rmSync(profile, { recursive: true, force: true });
}
});
+
+test('Pipeline view dates an expired claim from its recorded deadline [N26,N38]', async () => {
+ const box = machine(), alpha = project(box, 'pipeline-lapse');
+ const base = Date.now() - 60 * 60_000, commit = box.git(alpha.repo, 'rev-parse', 'HEAD');
+ const at = (minute, write) => earlier(alpha.repo, base + minute * 60_000, write);
+ at(0, board => store.addItem(board, { by:'coordinator', lane:'web', title:'Expired claim', specIds:['G1'] }));
+ at(10, board => store.claim(board, 1, { agentId:'web-1', lane:'web', leaseMs:30*60_000, head:commit, freeze:()=>({text:'{}',digest:'a'.repeat(64)}) }));
+ at(35, board => store.addItem(board, { by:'coordinator', lane:'web', title:'Older open item', specIds:['G1'] }));
+ const status = JSON.parse(box.run(alpha.repo, 'status', '--json')).stats.items;
+ assert.equal(status.open, 2);
+ assert.equal(status.claimed, 0);
+ const view = await startView(box);
+ try {
+ const page = await openPage(view);
+ await page.click({itemsView:'pipeline'});
+ const open = () => page.show('pipeline').split('data-pipeline-stage="open"')[1].split('</header>')[1].split('</p>')[0];
+ assert.match(open(), /data-item="2"/, 'an open item from minute35 is older than a claim that lapses at minute40');
+ assert.match(open(), new RegExp(new Date(base+35*60_000).toISOString()), 'the oldest open timestamp is the arrival');
+ box.run(alpha.repo, 'withdraw', '2', 'Private fixture now isolates the lapse age');
+ await page.run('refresh()');
+ assert.match(open(), /data-item="1"/);
+ assert.match(open(), new RegExp(new Date(base+40*60_000).toISOString()), 'expired claim age starts at its native lease deadline');
+ } finally { await view.stop(); }
+});