test(site-builder): parity harness neutralises documented editor-only differences (empty drop zone, empty-image placeholder)

Container marks the applied drop zone with data-wsb-dropzone.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
shadowdaoandClaude Sonnet 5.5 committed 2026-11-01 09:18:29 -08:00
1 parent d75f9d90ca
commit ae02eb7d0d
3 files changed
+22

No files matched your search

+13
View File
@@ -8,6 +8,10 @@
* same page's published HTML rendered in a plain page whose viewport equals
* the canvas content width.
*
* Stored state is loaded VERBATIM (blank style values included). Allowed editor-only
* differences (empty-container drop zone, empty-image placeholder) are neutralised in the
* canvas before measuring; see the ALLOWED block in run().
*
* Compared per matched element: bounding box (x/y/w/h, within 1px) and the
* computed font-size / line-height / margin / padding / colour / font-family
* / font-weight / display. Editor-only chrome (the dashed header/footer zone
@@ -240,6 +244,15 @@ async function run(name, launcher, exe) {
await ed.waitForSelector('.canvas-device-frame [data-craft-container]', { timeout: 20000 });
await ed.waitForTimeout(1500); // header/footer zone previews + layout settle
const canvasW = await ed.evaluate(() => document.querySelector('.canvas-device-frame').clientWidth);
// ALLOWED editor-only differences (deliberate UX with no published counterpart), neutralised
// before measuring so they don't mask real diffs:
// - the 40px drop zone on EMPTY containers (Container sets data-wsb-dropzone only then)
// - the placeholder <img> shown for an image node with no src (toHtml emits nothing)
await ed.evaluate(() => {
const f = document.querySelector('.canvas-device-frame');
f.querySelectorAll('[data-wsb-dropzone]').forEach((el) => el.style.setProperty('min-height', '0', 'important'));
f.querySelectorAll('img[src^="data:image/svg"]').forEach((el) => el.style.setProperty('display', 'none', 'important'));
});
const canvas = await ed.evaluate(measure, { rootSel: '.canvas-device-frame', isCanvas: true, skipNav: idx > 0 });
if (shotDir) await ed.screenshot({ path: path.join(shotDir, `${label.replace('/', '_')}.${name}.canvas.png`) });
if (process.env.CANVAS_CHROME_DUMP && idx === 0 && spec === specs[0]) {