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.
JavaScript agentic-codingai-agentsai-governanceautonomous-agentsclaude-codeclicode-reviewcodexcoding-agentsdeveloper-toolsgit-hooksllmlocal-firstmulti-agentsoftware-factoryspec-driven-developmentverificationvibe-coding
test: stabilize linked line height checks [N26]
Corey Olsone06770c31749
diff --git a/test/cockpit.test.js b/test/cockpit.test.jsindex 00fd7cca..a4eea464 100644--- a/test/cockpit.test.js+++ b/test/cockpit.test.js@@ -2843,9 +2843,14 @@ test('real Chrome styles shout code and item text without growing linked lines [box.run(alpha.web, 'claim', '1');const sourceHead = box.git(alpha.repo, 'rev-parse', 'HEAD');const sample = 'Inline `code <b>safe</b>`; pullboard shout --decision; --flag; src/cockpit.js; 0123456789abcdef0123456789abcdef01234567.\nPreview SPEC.md:1-2@' + sourceHead + '. Invalid prefix:SPEC.md:1-2@' + sourceHead + '.\n```js\n<script>alert(1)</script>\n```\n$ pullboard claim 1\n<script>alert(1)</script>';+ const wrappedLinkedText = 'This deliberately long linked sample wraps across lines so text length does not define line height. '.repeat(3) + '#1';box.run(alpha.repo, 'shout', 'person', sample, '--decision');box.run(alpha.web, 'shout', 'coordinator', 'A linked line #1');box.run(alpha.web, 'shout', 'coordinator', 'A plain line here');+ box.run(alpha.web, 'shout', 'coordinator', 'Go #1');+ box.run(alpha.web, 'shout', 'coordinator', 'Go');+ box.run(alpha.web, 'shout', 'coordinator', wrappedLinkedText);+ box.run(alpha.web, 'shout', 'coordinator', 'OK');box.run(alpha.web, 'shout', 'coordinator', '<script>alert(2)</script> outside code');const view = await startView(box);const profile = mkdtempSync(join(tmpdir(), 'pullboard-shout-code-chrome-'));@@ -2869,15 +2874,27 @@ test('real Chrome styles shout code and item text without growing linked lines [const outside = [...document.querySelectorAll('#feed > div:not(.day)')].find((row) => row.textContent.includes('alert(2)'));const itemDetail = document.querySelector('#detail');const agentItem = document.querySelector('#agents .agent button[data-go="item:1"]');- /** Measure the visible feed text line box for a shout containing the supplied phrase. */- const lineHeight = (needle) => {- const row = [...document.querySelectorAll('#feed > div:not(.day)')].find((entry) => entry.textContent.includes(needle));- return row.children[1].getBoundingClientRect().height;+ /** Measure a shout's text-box height and the distinct rendered text lines it occupies. */+ const lineMetrics = (message) => {+ const row = [...document.querySelectorAll('#feed > div:not(.day)')].find((entry) => entry.children[1]?.textContent.includes(message));+ const text = row.children[1];+ const messageText = [...text.childNodes].find((node) => node.nodeType === Node.TEXT_NODE && node.textContent.trim());+ const range = document.createRange();+ range.selectNodeContents(messageText);+ const rects = [...range.getClientRects()];+ const tops = rects.map(rect => rect.top).sort((a, b) => a - b).filter((top, index, all) => index === 0 || top - all[index - 1] > 2);+ const link = text.querySelector('button.ref');+ const style = link && getComputedStyle(link);+ return { height: range.getBoundingClientRect().height, lineHeight: getComputedStyle(text).lineHeight, lines: tops.length,+ padding: style?.padding, borderWidth: style?.borderTopWidth };};return {shoutHtml: shout.innerHTML, shoutScripts: shout.querySelectorAll('script').length,askHtml: ask.innerHTML, titleHtml: titleNode.innerHTML,- linkedHeight: lineHeight('A linked line'), plainHeight: lineHeight('A plain line'),+ linkedHeight: lineMetrics('Go #1').height, linkedLines: lineMetrics('Go #1').lines,+ linkedMetrics: lineMetrics('Go #1'), plainMetrics: lineMetrics('Go'),+ plainHeight: lineMetrics('Go').height, plainLines: lineMetrics('Go').lines,+ wrapLinked: lineMetrics(${JSON.stringify(wrappedLinkedText)}), wrapPlain: lineMetrics('OK'),linkedButtons: [...document.querySelectorAll('#feed > div:not(.day)')].find((entry) => entry.textContent.includes('A linked line'))?.querySelectorAll('button.ref').length,previewLinks: shout.querySelectorAll('button[data-code^="SPEC.md:1-2@"]').length,outsideHtml: outside.innerHTML, askNestedButtons: ask.querySelector('p').querySelectorAll('button').length,@@ -2911,15 +2928,67 @@ test('real Chrome styles shout code and item text without growing linked lines [assert.match(rendered.criterionHtml, /<code class="inline">value<\/code>/, 'criterion text uses the renderer');assert.match(rendered.briefHtml, /<code class="inline"><safe><\/code>/, 'brief text uses the renderer without interpreting markup');assert.equal(rendered.linkedButtons, 1, 'the compared row contains a rendered item link');- assert.ok(Math.abs(rendered.linkedHeight - rendered.plainHeight) < 1, `an item link keeps its desktop line height (${rendered.linkedHeight} vs ${rendered.plainHeight})`);+ assert.equal(rendered.linkedLines, 1, 'the short linked sample fits one desktop line');+ assert.equal(rendered.plainLines, 1, 'the short plain sample fits one desktop line');+ assert.ok(Math.abs(rendered.linkedMetrics.height - rendered.plainMetrics.height) < 1, 'the one-line desktop text boxes match');+ assert.ok(Math.abs(parseFloat(rendered.linkedMetrics.lineHeight) - parseFloat(rendered.plainMetrics.lineHeight)) < 1, 'an item link keeps its desktop computed line height');await chrome.send('Emulation.setDeviceMetricsOverride', { width: 375, height: 900, deviceScaleFactor: 1, mobile: false });await chrome.waitFor('innerWidth === 375 && document.querySelector("#feed > div:not(.day)")?.getBoundingClientRect().width > 0');- const phoneHeights = JSON.parse(await chrome.evaluate(`JSON.stringify((() => {- /** Measure one shout's text height at the current viewport width. */- const height = (needle) => [...document.querySelectorAll('#feed > div:not(.day)')].find((row) => row.textContent.includes(needle)).children[1].getBoundingClientRect().height;- return { linked: height('A linked line'), plain: height('A plain line') };+ const phoneMetrics = JSON.parse(await chrome.evaluate(`JSON.stringify((() => {+ /** Measure a shout's text-box height and distinct wrapped text lines. */+ const lineMetrics = (message) => {+ const row = [...document.querySelectorAll('#feed > div:not(.day)')].find((entry) => entry.children[1]?.textContent.includes(message));+ const text = row.children[1];+ const messageText = [...text.childNodes].find((node) => node.nodeType === Node.TEXT_NODE && node.textContent.trim());+ const range = document.createRange();+ range.selectNodeContents(messageText);+ const rects = [...range.getClientRects()];+ const tops = rects.map(rect => rect.top).sort((a, b) => a - b).filter((top, index, all) => index === 0 || top - all[index - 1] > 2);+ const link = text.querySelector('button.ref');+ const style = link && getComputedStyle(link);+ return { height: range.getBoundingClientRect().height, lineHeight: getComputedStyle(text).lineHeight, lines: tops.length,+ padding: style?.padding, borderWidth: style?.borderTopWidth };+ };+ return { linked: lineMetrics('Go #1'), plain: lineMetrics('Go'), wrapLinked: lineMetrics(${JSON.stringify(wrappedLinkedText)}), wrapPlain: lineMetrics('OK') };+ })())`));+ assert.equal(phoneMetrics.linked.lines, 1, 'the short linked sample fits one phone line');+ assert.equal(phoneMetrics.plain.lines, 1, 'the short plain sample fits one phone line');+ assert.ok(Math.abs(phoneMetrics.linked.height - phoneMetrics.plain.height) < 1, 'the one-line phone text boxes match');+ assert.ok(Math.abs(parseFloat(phoneMetrics.linked.lineHeight) - parseFloat(phoneMetrics.plain.lineHeight)) < 1, 'an item link keeps its phone computed line height');+ assert.ok(phoneMetrics.wrapLinked.lines > 1, 'the long linked probe actually wraps at 375px');+ assert.equal(phoneMetrics.wrapPlain.lines, 1, 'the short plain wrap probe remains on one line');+ assert.ok(Math.abs(phoneMetrics.wrapLinked.height / phoneMetrics.wrapLinked.lines - parseFloat(phoneMetrics.wrapPlain.lineHeight)) < 1,+ 'normalizing the forced wrap by its rendered line count proves the same per-line height');+ assert.ok(Math.abs(phoneMetrics.wrapLinked.height - phoneMetrics.wrapPlain.height) >= 1,+ 'the old whole-text-box comparison would fail on the deliberately wrapped sample');+ assert.equal(rendered.linkedMetrics.padding, '0px', 'linked sample keeps zero padding');+ assert.equal(rendered.linkedMetrics.borderWidth, '0px', 'linked sample keeps zero border');++ const mutantHeights = JSON.parse(await chrome.evaluate(`JSON.stringify((() => {+ /** Measure the linked and plain samples while one test-only CSS mutation is active. */+ const measure = (message) => {+ const row = [...document.querySelectorAll('#feed > div:not(.day)')].find((entry) => entry.children[1]?.textContent.includes(message));+ const style = getComputedStyle(row.children[1].querySelector('button.ref'));+ return { padding: style.padding, borderWidth: style.borderTopWidth };+ };+ const sheet = [...document.styleSheets].find(value => value.href && new URL(value.href).pathname === '/view.css');+ const at = sheet.cssRules.length;+ const result = {};+ for (const [name, declaration] of [['padding', 'padding: 1px 0 !important'], ['border', 'border: 1px solid transparent !important']]) {+ sheet.insertRule('.feed button.ref {' + declaration + '}', at);+ result[name] = measure('Go #1');+ sheet.deleteRule(at);+ }+ return result;})())`));- assert.ok(Math.abs(phoneHeights.linked - phoneHeights.plain) < 1, `an item link keeps its phone line height (${phoneHeights.linked} vs ${phoneHeights.plain})`);+ const assertUnpaddedUnbordered = (style) => {+ assert.equal(style.padding, '0px', 'item links have no padding');+ assert.equal(style.borderWidth, '0px', 'item links have no border');+ };+ assert.doesNotThrow(() => assertUnpaddedUnbordered(rendered.linkedMetrics));+ for (const [name, style] of Object.entries(mutantHeights)) {+ assert.throws(() => assertUnpaddedUnbordered(style), { name: 'AssertionError' }, `the ${name} mutation trips the focused guard`);+ }assert.deepEqual(consoleErrors, []);} finally {if (chrome) await closeSnapshotChrome(chrome);