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.

fix(view): the export asks the API for the full board [N26,A2]

Corey Olsonf6250163d6d6
diff --git a/src/serve.js b/src/serve.js
index 2f74adc8..5385cdc4 100644
--- a/src/serve.js
+++ b/src/serve.js
@@ -94,7 +94,8 @@ export async function exportView(root, directory) {
throw new Refused('NO_BOARD', 'no readable board to export; run pullboard init in this repo');
}
const path = '/api/v1/boards/' + encodeURIComponent(board.id);
- state = await read(path + '/state');
+ // Ask for every item's thread, verdicts and criterion: the snapshot has no API to fetch them from later.
+ state = await read(path + '/state?detail=full');
events = await read(path + '/events');
const last = state.state.events[0]?.event_id ?? 0;
events.events = events.events.filter((event) => event.event_id <= last);
diff --git a/test/cockpit/snapshot.test.js b/test/cockpit/snapshot.test.js
index 3080399c..28ced906 100644
--- a/test/cockpit/snapshot.test.js
+++ b/test/cockpit/snapshot.test.js
@@ -5,7 +5,7 @@ import { createServer, request } from 'node:http';
import { tmpdir } from 'node:os';
import { join, resolve } from 'node:path';
import { test } from 'node:test';
-import { portableSnapshot } from '../../src/serve.js';
+import { exportView, portableSnapshot } from '../../src/serve.js';
import { machine, project, build, sendBack, fetchLive, startView, accept, boardId, boardOf, assertObservationsEqual, chromeExecutable, browserPause, openSnapshotChrome, closeSnapshotChrome, press, travel, settled, roadmapRow, showing, readRoadmap, openRoadmapParts, serveFolder, proofShot } from './fixture.js';
@@ -671,3 +671,67 @@ test('an exported roadmap has its own address under a folder, and Back and Forwa
rmSync(profile, { recursive: true, force: true });
}
});
+
+test('the export asks for the full board [N26,A2]', { timeout: 90_000 }, // budget: hang-only ceiling for one export and one Chrome open of its item.
+ async () => {
+ const executable = chromeExecutable();
+ assert.ok(executable, 'Chrome is required to open the exported item offline');
+ const box = machine();
+ const alpha = project(box, 'full-board');
+ const criterion = 'The greeting renders from the snapshot alone.';
+ box.run(alpha.repo, 'add', 'web', 'Offline greeting', '--specs', 'G1', '--criterion', criterion);
+ build(box, alpha, 1, 'greeting.html');
+ sendBack(box, alpha, 1, 'the first greeting needs a correction');
+ box.run(alpha.web, 'fact', '1', 'measurement', 'The corrected greeting renders offline.');
+ build(box, alpha, 1, 'greeting-fix.html');
+ accept(box, alpha, 1);
+
+ // The export reads the board through the local API. Record each address it asks for, never its key.
+ const asked = [];
+ const nativeFetch = globalThis.fetch;
+ /** Note the address of each API read, then make the read unchanged. */
+ globalThis.fetch = (input, init) => {
+ asked.push(new URL(input instanceof Request ? input.url : String(input)));
+ return nativeFetch(input, init);
+ };
+ const folder = join(box.dir, 'full-board-export');
+ try { await exportView(alpha.repo, folder); }
+ finally { globalThis.fetch = nativeFetch; }
+ const stateReads = asked.filter((url) => url.pathname.endsWith('/state'));
+ assert.deepEqual(stateReads.map((url) => url.searchParams.get('detail')), ['full'],
+ `the export reads the state once, asking for detail=full; it asked for ${asked.map((url) => url.pathname + url.search).join(', ')}`);
+
+ // With no API left to ask, the exported page still opens the item's criterion, verdicts and thread.
+ const host = await serveFolder(folder, '/demo/');
+ let chrome;
+ try {
+ chrome = await openSnapshotChrome(executable, `${host.base}/demo/#items/1`, join(box.dir, 'full-board-chrome'));
+ await settled(chrome, "document.body.classList.contains('snapshot') && !!data?.project && snapshotReplay.index === snapshotReplay.events.length && view.item === 1 && !!document.querySelector('#detail .tl')");
+ const opened = await chrome.stable(`(() => {
+ const detail = document.querySelector('#detail');
+ const part = (name) => [...detail.querySelectorAll('h3')].find((heading) => heading.textContent === name)?.parentElement;
+ return {
+ title: detail.querySelector('h2').innerText,
+ criterion: part('Criterion')?.querySelector('.text').innerText ?? null,
+ verdicts: [...(part('Verdicts')?.querySelectorAll('.verdict') ?? [])].map((verdict) => [verdict.classList.contains('yes') ? 'ACCEPT' : 'REJECT', verdict.querySelector('.note').innerText]),
+ moves: [...detail.querySelectorAll('.tl > li:not(.tl-fact) b')].map((move) => move.textContent),
+ facts: [...detail.querySelectorAll('.tl > .tl-fact .tl-body')].map((fact) => fact.textContent),
+ };
+ })()`);
+ assert.ok(opened.title.includes('Offline greeting'), `the address opens item #1: ${opened.title}`);
+ assert.equal(opened.criterion, criterion, 'the exported item shows its criterion');
+ assert.deepEqual(opened.verdicts, [['REJECT', 'the first greeting needs a correction'], ['ACCEPT', 'the page shows it']],
+ 'the exported item shows both verdicts with their notes');
+ assert.deepEqual(opened.moves, ['add', 'claim', 'submit', 'reject', 'claim', 'submit', 'accept'], 'the exported thread shows every move');
+ assert.deepEqual(opened.facts, ['The corrected greeting renders offline.'], 'the exported thread shows its fact');
+ assert.ok(host.requests.some((request) => request.path.endsWith('/state.json')), 'the page reads the exported state file');
+ assert.deepEqual(host.requests.filter((request) => !request.path.startsWith('/demo/') || request.status !== 200), [],
+ 'every request stays in the exported folder and finds its file');
+ assert.deepEqual(chrome.requests.map((request) => request.url).filter((url) => !url.startsWith(`${host.base}/demo/`) && !url.startsWith('data:')), [],
+ 'the page asks nothing outside the exported folder');
+ assert.deepEqual(chrome.exceptions, [], 'the exported page opens the item without browser exceptions');
+ } finally {
+ if (chrome) await closeSnapshotChrome(chrome);
+ await host.close();
+ }
+ });