CtrlK
BlogDocsLog inGet started
Tessl Logo
PluginPublic

adobe/stardust

Redesign an existing website to make it better. Built on top of impeccable.

Quality

88%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide
SecuritybySnyk

Low

Low-risk findings worth noting

Overview
Quality
Evals
Security
Files

chrome-compare.test.mjsskills/diff/scripts/test/

#!/usr/bin/env node
// skills/diff/scripts/test/chrome-compare.test.mjs — the header-parity verdict from two chrome-explore records (no browser):
// pairing by name then family, a hover menu rebuilt as click-only, missing panel links, keyboard and close paths,
// motion and scroll states under `replica` only, search typeahead, and site-owner decisions (agents cannot sign).
// Run: node plugins/stardust/skills/diff/scripts/test/chrome-compare.test.mjs
import assert from 'node:assert/strict';
import { spawnSync } from 'node:child_process';
import { cpSync, mkdtempSync, rmSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { applyDecisions, compareDocs, findingKey, pairControls } from '../chrome-compare.mjs';

const HERE = dirname(fileURLToPath(import.meta.url));
let failed = 0;
const check = (name, fn) => { try { fn(); console.log(`✓ ${name}`); } catch (e) { failed += 1; console.log(`✗ ${name}\n  ${e.message.split('\n').join('\n  ')}`); } };

const st = (links, extra = {}) => ({ opened: true, panel: { links: links.map((t) => ({ text: t, href: `/${t.toLowerCase().replace(/ /g, '-')}` })), headings: extra.headings || [], images: 0, inputs: [], buttons: [], options: 0, rect: [0, 72, 600, 300] }, expanded: extra.expanded ?? null, focus: 'panel', scrollLock: !!extra.lock, motion: extra.motion || [], tabReachesPanel: extra.tab, shot: null });
const ctl = (name, kind, actions, more = {}) => ({ name, key: name.toLowerCase(), role: 'toggle', kind, actions, ...more });
const doc = (controls, scroll = []) => ({ url: 'https://example.com/', widths: { 1440: { root: 'header', controls, scroll } } });

const shopLinks = ['Men', 'Women', 'Kids', 'Sale'];
const source = doc([
  ctl('Shop', 'menu', { hover: st(shopLinks, { motion: [{ prop: 'opacity', ms: 200 }], headings: ['Shop'] }), click: null, key: st(shopLinks, { expanded: 'true', tab: true }) },
    { close: { escape: true, focusReturn: true, outside: true, leave: true }, children: [ctl('Women', 'menu', { hover: st(['Dresses', 'Shoes']) })] }),
  { name: 'Search the site', key: 'search the site', role: 'input', kind: 'search', actions: {}, search: { probe: 'shoes', typeahead: { links: 3, options: 3 }, submit: 'https://example.com/search?q={q}' } },
], [{ at: 'top', top: 0, height: 96, position: 'sticky', inView: true }, { at: 'down', top: -96, height: 96, position: 'sticky', inView: false }]);

check('pairControls: by name first, then by family in order', () => {
  const p = pairControls([ctl('Bag', 'cart', {}), ctl('About', 'menu', {})], [ctl('About', 'menu', {}), ctl('Cart', 'cart', {})]);
  assert.deepEqual(p.map(([s, b]) => [s.name, b && b.name]), [['Bag', 'Cart'], ['About', 'About']]);
});
check('an identical build has no finding', () => {
  assert.deepEqual(compareDocs(source, structuredClone(source)).findings, []);
});
check('a stock header (click-only, fewer links, no motion, no Escape, no typeahead) fails on each', () => {
  const build = doc([
    ctl('Shop', 'menu', { hover: null, click: st(['Men', 'Women'], { expanded: 'true' }), key: st(['Men', 'Women'], { tab: false }) }, { close: { escape: false, focusReturn: false, outside: true, toggle: true } }),
    { name: 'Search', key: 'search', role: 'input', kind: 'search', actions: {}, search: { probe: 'shoes', typeahead: { links: 0, options: 0 }, submit: 'https://example.com/search?q={q}' } },
  ], [{ at: 'top', top: 0, height: 96, position: 'sticky', inView: true }, { at: 'down', top: 0, height: 96, position: 'sticky', inView: true }]);
  const ids = compareDocs(source, build).findings.map((f) => `${f.id}${f.action ? `[${f.action}]` : ''}:${f.path}`);
  for (const want of ['state-missing[hover]:Shop', 'keyboard[key]:Shop', 'close-path:Shop', 'keyboard:Shop', 'state-missing[type]:search', 'scroll-state[down]:(header)']) assert.ok(ids.includes(want), `missing ${want} in ${ids.join(' | ')}`);
  const content = compareDocs(source, build).findings.find((f) => f.id === 'panel-content');
  assert.match(content.detail, /2 of 4 links missing \(Kids, Sale\)/);
  assert.ok(ids.includes('control-missing:Shop > Women'), 'a level inside an open panel (the Women tab) is compared too');
});
check('functional profile: behaviour and content gate, motion and crops do not, scroll states only warn', () => {
  const build = structuredClone(source);
  build.widths[1440].controls[0].actions.hover.motion = [];
  build.widths[1440].scroll[1].inView = true;
  assert.deepEqual(compareDocs(source, build, { profile: 'functional' }).findings.map((f) => [f.id, f.severity]), [['scroll-state', 'warn']]);
  assert.deepEqual(compareDocs(source, build).findings.map((f) => [f.id, f.severity]), [['motion', 'error'], ['scroll-state', 'error']]);
});
check('motion: within max(80 ms, 25 %) passes, beyond fails', () => {
  const at = (ms) => { const b = structuredClone(source); b.widths[1440].controls[0].actions.hover.motion = [{ prop: 'opacity', ms }]; return compareDocs(source, b).findings.length; };
  assert.equal(at(260), 0); assert.equal(at(320), 1);
});
check('a control the build lacks; a width it was not explored at', () => {
  const f = compareDocs(source, { url: 'x', widths: { 1440: { root: 'header', controls: [], scroll: [] } } }).findings.map((x) => x.id);
  assert.deepEqual(f.slice(0, 2), ['control-missing', 'control-missing']);
  assert.equal(compareDocs({ widths: { 390: { root: 'header', controls: [] } } }, { widths: {} }).findings[0].id, 'width-missing');
});
check('a source control not reached before the build request budget is a warning', () => {
  const build = doc([]);
  build.widths[1440].truncated = 'request-budget';
  const missing = compareDocs(doc([ctl('Shop', 'menu', { click: st(shopLinks) })]), build).findings.find((f) => f.id === 'control-missing');
  assert.equal(missing.severity, 'warn');
  assert.match(missing.detail, /not observed: the build record stopped at the request budget \(run the build side with --max-requests 0\)$/);
  const budget = compareDocs(source, build).findings.find((f) => f.id === 'budget-truncated');
  assert.match(budget.detail, /--max-requests 0/);
  build.widths[1440].root = null;
  assert.match(compareDocs(source, build).findings.find((f) => f.id === 'budget-truncated').detail, /--max-requests 0/);
});
check('an action absent from a partial build control is a warning', () => {
  const src = doc([ctl('Shop', 'menu', { click: st(shopLinks) })]);
  const build = doc([ctl('Shop', 'menu', {}, { partial: 'request-budget' })]);
  const missing = compareDocs(src, build).findings.find((f) => f.id === 'state-missing');
  assert.deepEqual([missing.action, missing.severity], ['click', 'warn']);
  assert.match(missing.detail, /not observed: the build record stopped at the request budget/);
});
check('an observed build action that fails remains an error', () => {
  const src = doc([ctl('Shop', 'menu', { click: st(shopLinks) })]);
  const build = doc([ctl('Shop', 'menu', { click: { opened: false } })]);
  const missing = compareDocs(src, build).findings.find((f) => f.id === 'state-missing');
  assert.deepEqual([missing.action, missing.severity], ['click', 'error']);
  assert.doesNotMatch(missing.detail, /not observed/);
});
check('a nested child absent below a partial build control is a warning', () => {
  const parent = (children, more = {}) => ctl('Shop', 'menu', { click: st(shopLinks) }, { close: {}, children, ...more });
  const src = doc([parent([ctl('Women', 'menu', { click: st(['Dresses']) })])]);
  const build = doc([parent([], { partial: 'request-budget' })]);
  const missing = compareDocs(src, build).findings.find((f) => f.path === 'Shop > Women');
  assert.deepEqual([missing.id, missing.severity], ['control-missing', 'warn']);
  assert.match(missing.detail, /not observed: the build record stopped at the request budget/);
});
check('a build search input skipped past the typeahead cap warns without throwing', () => {
  const build = structuredClone(source);
  const input = build.widths[1440].controls[1];
  input.search = null;
  input.skipped = 'typeahead-cap';
  const typeahead = compareDocs(source, build).findings.find((f) => f.id === 'state-missing' && f.action === 'type');
  assert.equal(typeahead.severity, 'warn');
});
check('a source search input skipped past the typeahead cap produces no finding', () => {
  const skipped = structuredClone(source);
  skipped.widths[1440].controls[1].search = null;
  skipped.widths[1440].controls[1].skipped = 'typeahead-cap';
  assert.deepEqual(compareDocs(skipped, source).findings, []);
});
check('decisions: a site-owner entry clears its finding (exact or prefix*); an agent-signed or unsigned one is ignored and reported', () => {
  const f = [{ id: 'state-missing', width: 1440, path: 'Cart', action: 'click', severity: 'error' }, { id: 'motion', width: 390, path: 'Open menu', severity: 'error' }];
  assert.equal(findingKey(f[0]), 'state-missing@1440 Cart [click]');
  const out = applyDecisions(structuredClone(f), [
    { finding: 'state-missing@1440 Cart*', decision: 'decided-out', reason: 'cart moves to the shop subdomain', by: 'Site owner (marketing lead)', at: '2026-10-09' },
    { finding: 'motion@390 Open menu', decision: 'accepted', by: 'agent', at: '2026-10-09' },
    { finding: 'motion@390 Open menu', decision: 'accepted' },
  ]);
  assert.equal(out[0].decided.decision, 'decided-out'); assert.equal(out[1].decided, undefined);
  assert.equal(out.filter((x) => x.id === 'decision-invalid').length, 2);
});
const copyWithoutMaster = () => {
  const root = mkdtempSync(join(tmpdir(), 'diff-nomaster-'));
  const copy = join(root, 'a', 'b');
  cpSync(join(HERE, '..'), copy, { recursive: true, filter: (src) => !src.endsWith('/test') });
  return { root, copy };
};
check('a copy without the master scripts answers --help, no stack trace', () => {
  const { root, copy } = copyWithoutMaster();
  try {
    const r = spawnSync(process.execPath, [join(copy, 'chrome-compare.mjs'), '--help'], { encoding: 'utf8', timeout: 15000 });
    assert.equal(r.status, 0, r.stderr);
    assert.ok(!r.stderr.includes('    at '), r.stderr);
  } finally { rmSync(root, { recursive: true, force: true }); }
});

process.exit(failed ? 1 : 0);

skills

README.md

tile.json