diff --git a/craft/scripts/e2e-canvas-parity.mjs b/craft/scripts/e2e-canvas-parity.mjs index 9cb7194..b67ab4e 100644 --- a/craft/scripts/e2e-canvas-parity.mjs +++ b/craft/scripts/e2e-canvas-parity.mjs @@ -82,28 +82,9 @@ for (const p of specPaths) { specs.push({ name: s.name, project, published }); } -// A stored `style` often carries a shorthand plus BLANK longhands -// ({padding:'20px', paddingTop:''}). The editor renders those through React, which -// assigns '' to the longhand and thereby wipes the shorthand in the canvas (the -// export drops blanks, so published keeps it). That is a SEPARATE bug from the -// base-reset parity this test guards (same class as fix/bg-shorthand-longhand), so by -// default the blanks are stripped from the loaded state to isolate the reset. -// CANVAS_RAW=1 keeps the stored state verbatim (shows that bug's residue). -function stripBlankStyles(project) { - if (process.env.CANVAS_RAW) return project; - const clean = (json) => { - const nodes = JSON.parse(json); - for (const n of Object.values(nodes)) { - const st = n && n.props && n.props.style; - if (st && typeof st === 'object') for (const k of Object.keys(st)) if (st[k] === '') delete st[k]; - } - return JSON.stringify(nodes); - }; - const out = { ...project }; - for (const k of ['craft_state', 'header_craft_state', 'footer_craft_state']) if (typeof out[k] === 'string' && out[k]) out[k] = clean(out[k]); - out.pages_craft_state = (project.pages_craft_state || []).map((pg) => ({ ...pg, craftState: typeof pg.craftState === 'string' ? clean(pg.craftState) : pg.craftState })); - return out; -} +// NOTE: stored state is loaded VERBATIM, blank style values included (e.g. +// {padding:'20px', paddingTop:''} left by the style panel). The harness must test what +// the editor really renders; an earlier version stripped blanks and thereby hid a wipe bug. // ---------------------------------------------------------------- build + serve the real editor const buildDir = fs.mkdtempSync(path.join(os.tmpdir(), 'wsb-canvas-')); @@ -248,7 +229,7 @@ async function run(name, launcher, exe) { if (!pubHtml) continue; const label = `${spec.name}/${pg.slug}`; // The editor opens pages_craft_state[0]; rotate so page `idx` is first. - currentProject = stripBlankStyles({ ...spec.project, pages_craft_state: [pg, ...pages.filter((_, j) => j !== idx)] }); + currentProject = { ...spec.project, pages_craft_state: [pg, ...pages.filter((_, j) => j !== idx)] }; const ctx = await browser.newContext({ viewport: { width: EDITOR_W, height: VIEW_H } }); await ctx.route(/^https?:\/\/(?!127\.0\.0\.1)/, offline); // no web fonts / icon CDN: identical fallbacks both sides