From 5c636dca2f1b2122f23e65985b01eda9d2217728 Mon Sep 17 00:00:00 2001 From: MendixMau Date: Mon, 16 Nov 2026 10:20:45 +0800 Subject: [PATCH 1/3] E2E-R1: rendered verb, a pluggable widget drawn and not only in the DOM On FSM 11.12.7 with Ultimate Scheduler 1.4.0 the scheduler page opened and every guard held, but the widget was a header over a 0 px rows area. The new check fails that: size, drawn content, the client's "Could not render widget" text, per-widget parts from playbooks/widget-render.tsv, and client errors from the widget's own script. A PASS needs a still widget (two looks alike, nothing loading). Pre-fix build FAIL 3/3, the 3.8.0 build PASS 3/3 (rows 8/8, events 4/4); through run_journeys: pre 0/1 PASS, fixed 1/1 PASS. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01HXpQSjPfSUmbjM87Luyq27 --- upgrade-toolkit/bin/journey-verbs.js | 18 +- upgrade-toolkit/bin/run_journeys.py | 19 ++- upgrade-toolkit/bin/widgetrender.js | 176 ++++++++++++++++++++ upgrade-toolkit/playbooks/widget-render.tsv | 11 ++ upgrade-toolkit/steps/journeys.md | 6 + 5 files changed, 228 insertions(+), 2 deletions(-) create mode 100644 upgrade-toolkit/bin/widgetrender.js create mode 100644 upgrade-toolkit/playbooks/widget-render.tsv diff --git a/upgrade-toolkit/bin/journey-verbs.js b/upgrade-toolkit/bin/journey-verbs.js index 5a0160c..1856995 100644 --- a/upgrade-toolkit/bin/journey-verbs.js +++ b/upgrade-toolkit/bin/journey-verbs.js @@ -36,6 +36,11 @@ // side bar and top bar items of a layout. // {"do": "menu", "widget": "pop_upMenu5"} PR-F35: open a Pop-up menu so its items render; no-op // when open, error when it never opens. +// {"do": "rendered", "widget": "scheduler1", "data": true} E2E-R1: the widget is drawn, not only in the DOM +// (widgetrender.js: size, drawn content, no error text, no +// client error from a widget script, the playbook's parts; +// "data": true after a DB check that the records exist). +// FAIL = error with the first broken rule. // {"do": "confirm", "optional": true} D97: no error when no dialog is open (the app raises it only sometimes) // {"do": "confirm"} or {"do": "confirm", "label": "Proceed"} // the topmost open dialog: its primary button, or the @@ -56,6 +61,7 @@ // snippet earlier in the DOM; the guard checked only that one and every park walk of leg 3 FAILed "never appeared"). const SETTLE = require('./settle.js'); +const R = require('./widgetrender.js'); const DIALOG = '.modal-dialog, .mx-dialog, .mx-window'; @@ -695,4 +701,14 @@ function dateAs(ph, v) { return { value: out, note: `date typed as "${ph}" (the picker's placeholder): ${out}` }; } -module.exports = { openDialog, dateAs, field, fields, upload, SEED_FILE, DIALOG, ROWS, ANY_ROW, topmost, ack, cover, pageWidget, toggle, select, combo, row, tab, item, menuitem, menu, confirm, reached }; +// E2E-R1: a pluggable widget drawn, or an error naming the first broken rule; returns the measurement line +async function rendered(page, a) { + const r = await R.check(page, a); + const m = r.m || {}; + const said = m.found ? `${m.box[2]} x ${m.box[3]} px, ` + (m.parts.map(p => `${p.sel} ${p.drawn}/${p.n}`).join(', ') || `${m.drawn} drawn`) : r.reason; + if (!r.ok) throw new Error(`.mx-name-${a.widget} not drawn: ${r.reason}`); + for (const e of r.notes) console.log(' rendered: note ' + e.split('\n')[0].slice(0, 160)); + return said; +} + +module.exports = { openDialog, dateAs, field, fields, upload, SEED_FILE, DIALOG, ROWS, ANY_ROW, topmost, ack, cover, pageWidget, toggle, select, combo, row, tab, item, menuitem, menu, confirm, reached, rendered, watch: R.watch }; diff --git a/upgrade-toolkit/bin/run_journeys.py b/upgrade-toolkit/bin/run_journeys.py index 34306f0..121af0e 100644 --- a/upgrade-toolkit/bin/run_journeys.py +++ b/upgrade-toolkit/bin/run_journeys.py @@ -252,6 +252,22 @@ " const got = await V.upload(page, a, String(subst(a.file ?? '', vars)));\n" " note('ui', `upload: ${got} into ${a.widget}`, 'PASS', got); break;\n }\n" " case 'dismissModal': await H.dismissModal(page); break;"), + # E2E-R1: a pluggable widget is drawn, not only in the DOM (FSM 11.12: the scheduler page opened, every check + # PASSed and the scheduler was a header over a 0 px rows area); client errors are recorded from the first page on + ("act: rendered, a pluggable widget drawn (E2E-R1)", + " case 'dismissModal': await H.dismissModal(page); break;", + " case 'rendered': {\n" + " const got = await V.rendered(page, a);\n" + " note('ui', `rendered: ${a.widget} is drawn`, 'PASS', got); break;\n }\n" + " case 'dismissModal': await H.dismissModal(page); break;"), + ("describe: rendered reads as a sentence (E2E-R1)", + " case 'wait': return { verb: 'Wait'", + " case 'rendered': return { verb: 'Check', target: `${a.label || a.widget} is drawn${a.data ? ' with its records' : ''}`, selector: `.mx-name-${a.widget}` };\n" + " case 'wait': return { verb: 'Wait'"), + ("browser: record client errors from the first page, for the rendered verb (E2E-R1)", + " await seedStorage(context);\n const page = await context.newPage();", + " await seedStorage(context);\n const page = await context.newPage();\n require(__dirname + '/widgetrender.js').watch(page);", + "helpers.js"), ("describe: upload reads as a sentence (PR-F44)", " case 'wait': return { verb: 'Wait'", " case 'upload': return { verb: 'Upload', target: `${v(a.file || V.SEED_FILE)} into ${a.label || a.widget}`, selector: `.mx-name-${a.widget}` };\n" @@ -354,8 +370,9 @@ def copy_engine(eng): eng.mkdir(parents=True, exist_ok=True) for f in ENGINE: shutil.copy2(TOOLKIT_E2E / f, eng / f) - for f in ("settle.js", "journey-verbs.js", "pgdata.js", "pgmap.py"): + for f in ("settle.js", "journey-verbs.js", "widgetrender.js", "pgdata.js", "pgmap.py"): shutil.copy2(HERE / f, eng / f) + shutil.copy2(HERE.parent / "playbooks" / "widget-render.tsv", eng / "widget-render.tsv") texts = {} report = [] for name, old, new, *where in PATCHES: diff --git a/upgrade-toolkit/bin/widgetrender.js b/upgrade-toolkit/bin/widgetrender.js new file mode 100644 index 0000000..7ce23ac --- /dev/null +++ b/upgrade-toolkit/bin/widgetrender.js @@ -0,0 +1,176 @@ +#!/usr/bin/env node +// widgetrender.js: is a pluggable widget drawn, not only present in the DOM? (E2E-R1) +// Why: FSM 9.24 -> 11.12.7. The Scheduler page opened, the smoke walk and the journeys PASSed, and the scheduler itself +// was blank: Ultimate Scheduler 1.4.0 under the React client drew its toolbar and time header, the resource rows area +// was 0 px tall, no row and no appointment. The client threw "Cannot read properties of undefined (reading +// 'setTimeSpan')" from the widget's own script and React #520. The journey guards skip anything inside a pluggable +// widget (steps/journeys.md, T1-25) and the page guard only asks that the page is there, so nothing looked inside. +// The fix (Ultimate Scheduler 3.8.0) was found by a person looking at a screenshot. +// +// Generic rules, every widget (FAIL names the first that broke): +// found a shown .mx-name- (the one in the topmost open dialog first); "Could not render widget '...'" +// in its place is said as such (the scheduler that threw long enough was replaced by it) +// size its box is wider and taller than 0 +// drawn it has a drawn descendant (box above 2 x 2 px, not hidden) with text, an image, a canvas or an svg +// no error no "Could not render widget" / .alert-danger text inside it +// no client error from a widget script: a pageerror or console error since the last check whose text or stack names +// /widgets/ (resource 404s and errors from other scripts are listed as notes, not FAILs; "strict": true +// FAILs on every client error) +// Per widget, playbooks/widget-render.tsv rows whose root class (one of a comma list) the widget has: "h>0" (every match drawn with a height) +// and "min=N" (at least N drawn matches); rows marked data apply only with "data": true (the step's DB check showed +// the records exist: an empty scheduler on an empty table is not a defect). Inline "expect": [{"sel", "min"|"h"}] too. +// It polls up to timeoutMs (default 15000) until every rule holds on a still widget (nothing loading, two looks one +// second apart alike), so a widget still fetching gets its time; the verdict is the last state seen. +// +// journey step: {"do": "rendered", "widget": "bizzomateUltimateScheduler1", "data": true} +// module: const R = require('./widgetrender.js'); R.watch(page) once after newPage; await R.check(page, a) +// CLI: node widgetrender.js --url http://localhost:8080 --user Role=name:pass --open Scheduler \ +// --widget bizzomateUltimateScheduler1 [--data] [--strict] [--shot f.png] [--out r.json] +// exit 0 PASS, 1 FAIL, 2 could not judge (login failed, menu item not found). +const fs = require('fs'); +const path = require('path'); +const os = require('os'); + +// the toolkit's playbook; run_journeys.py copies it next to this file in the engine copy +const PLAYBOOK = [path.join(__dirname, 'widget-render.tsv'), path.join(__dirname, '..', 'playbooks', 'widget-render.tsv')].find(f => fs.existsSync(f)) || ''; +const IGNORE = [/favicon/i, /Failed to load resource/i]; +const LOGS = new WeakMap(); + +function rules(file = PLAYBOOK) { + if (!file || !fs.existsSync(file)) return []; + const rows = fs.readFileSync(file, 'utf8').split('\n').filter(l => l.trim() && !l.startsWith('#')); + const head = rows.shift().split('\t'); + return rows.map(l => Object.fromEntries(l.split('\t').map((v, i) => [head[i], v]))); +} + +// Record client errors from the moment the page exists; check() reads the ones since its previous call. +function watch(page) { + if (LOGS.has(page)) return; + const log = { errs: [], seen: 0 }; LOGS.set(page, log); + page.on('pageerror', e => log.errs.push('pageerror: ' + String(e.stack || e.message).slice(0, 600))); + page.on('console', m => { + if (m.type() !== 'error') return; + const loc = m.location && m.location(); + log.errs.push('console: ' + m.text().slice(0, 600) + (loc && loc.url ? ' @ ' + loc.url : '')); + }); +} + +// One look at the widget: geometry and the playbook/inline parts, measured in the page. +function measure(page, name, parts) { + return page.evaluate(([name, parts]) => { + const shown = e => { const r = e.getBoundingClientRect(); const cs = getComputedStyle(e); + return r.width > 2 && r.height > 2 && cs.visibility !== 'hidden' && cs.display !== 'none' && cs.opacity !== '0'; }; + const all = [...document.querySelectorAll('.mx-name-' + CSS.escape(name))]; + const dlg = [...document.querySelectorAll('.modal-dialog, .mx-dialog, .mx-window')].filter(shown).pop(); + const el = (dlg && all.find(e => dlg.contains(e) && shown(e))) || all.find(shown) || all[0]; + // a widget that threw while mounting is replaced by the client's own message, without the mx-name class + const crash = (document.body.innerText.match(new RegExp("Could not render widget '[^']*\\." + name + "'")) || [])[0]; + if (!el) return { found: false, crash }; + const r = el.getBoundingClientRect(); + const kids = [...el.querySelectorAll('*')].filter(shown); + const drawn = kids.filter(k => k.matches('img, canvas, svg') || [...k.childNodes].some(n => n.nodeType === 3 && n.textContent.trim())).length; + const errText = [...el.querySelectorAll('.alert-danger, .mx-widget-error')].filter(shown).map(e => e.textContent.trim().slice(0, 160)); + if (/Could not render widget/i.test(el.textContent)) errText.push('Could not render widget'); + const got = parts.map(p => { + const m = [...el.querySelectorAll(p.sel)]; + return { ...p, n: m.length, drawn: m.filter(shown).length, + flat: m.filter(e => { const b = e.getBoundingClientRect(); return b.width > 0 && b.height < 1; }).length }; + }); + return { found: true, cls: el.className, box: [r.x, r.y, r.width, r.height].map(Math.round), kids: kids.length, drawn, + errText, busy: !!el.querySelector('[class*="is-fetching"], [class*="is-loading"], .mx-progress'), parts: got }; + }, [name, parts]); +} + +function verdict(m, name) { + if (!m.found) return m.crash ? 'not rendered: the client shows "' + m.crash + '"' : 'not found: no .mx-name-' + name + ' on the screen'; + if (!(m.box[2] > 0 && m.box[3] > 0)) return `zero size: drawn ${m.box[2]} x ${m.box[3]} px`; + if (!m.drawn) return `nothing drawn: ${m.kids} shown descendants, none with text, an image, a canvas or an svg`; + if (m.errText.length) return 'error text in the widget: ' + m.errText[0]; + for (const p of m.parts) { + if (p.h && (!p.n || p.flat)) return `${p.sel}: ${p.flat} of ${p.n} drawn 0 px tall (${p.why})`; + if (p.min && p.drawn < p.min) return `${p.sel}: ${p.drawn} drawn, at least ${p.min} expected (${p.why})`; + } + return null; +} + +// a: {widget, data, strict, expect, timeoutMs, rules}. Returns {ok, reason, m, errors, notes}; never throws on a FAIL. +async function check(page, a) { + watch(page); + const all = a.rules || rules(); + const ms = a.timeoutMs || 15000, until = Date.now() + ms; + let m, bad, parts = [], last = ''; + for (;;) { + // the root's classes pick the playbook rows; read each round, the widget may mount after the page opened + const cls = String(await page.evaluate(n => { const e = document.querySelector('.mx-name-' + CSS.escape(n)); return e ? e.className : ''; }, a.widget).catch(() => '')).split(/\s+/); + parts = all.filter(r => r.root.split(',').some(c => cls.includes(c)) && (r.when !== 'data' || a.data)) + .map(r => ({ sel: r.selector, h: r.rule === 'h>0', min: (r.rule.match(/^min=(\d+)$/) || [])[1] | 0, why: r.reason })) + .concat((a.expect || []).map(x => ({ sel: x.sel, h: !!x.h, min: x.min | 0, why: 'step expect' }))); + m = await measure(page, a.widget, parts).catch(e => ({ found: false, err: String(e.message) })); + bad = verdict(m, a.widget); + // a PASS needs a still widget: nothing loading and the same box, descendants and parts as one second before + // (the fixed scheduler PASSed half-mounted, 18 descendants and none of its playbook classes yet) + const sig = JSON.stringify([m.cls, m.box, m.kids, m.parts]); + if ((!bad && !m.busy && sig === last) || Date.now() > until) break; + last = sig; + await page.waitForTimeout(bad ? 500 : 1000); + } + const log = LOGS.get(page); const errs = log.errs.slice(log.seen); log.seen = log.errs.length; + const mine = errs.filter(e => !IGNORE.some(re => re.test(e)) && (a.strict || /\/widgets\//.test(e))); + const notes = errs.filter(e => !mine.includes(e)); + if (mine.length) bad = (bad ? bad + '; ' : '') + 'client error from a widget script: ' + mine[0].split('\n')[0].slice(0, 200); + if (bad && m.busy) bad += ` (still loading after ${ms} ms)`; + return { ok: !bad, reason: bad || '', m, errors: mine, notes }; +} + +module.exports = { watch, check, rules, measure }; + +if (require.main === module) (async () => { + const o = { users: [] }; + const av = process.argv.slice(2); + for (let i = 0; i < av.length; i++) { + const k = av[i]; + if (k === '--data' || k === '--strict') o[k.slice(2)] = true; + else if (k === '--user') o.users.push(av[++i]); + else o[k.slice(2)] = av[++i]; + } + if (!o.url || !o.widget || !o.users.length) { console.error('usage: widgetrender.js --url U --user Role=name:pass --widget W [--open MenuCaption] [--data] [--strict] [--shot f.png] [--out r.json]'); process.exit(2); } + const dirs = [process.env.PLAYWRIGHT_DIR, path.join(os.homedir(), 'mendix-playwright/node_modules/playwright'), 'playwright'].filter(Boolean); + let pw; for (const d of dirs) { try { pw = require(d); break; } catch (e) { /* next */ } } + if (!pw) { console.error('widgetrender: playwright not found (set PLAYWRIGHT_DIR)'); process.exit(2); } + // no keychain prompt on macOS: Playwright's own profile, a mock keychain and a plain password store + const browser = await pw.chromium.launch({ args: ['--use-mock-keychain', '--password-store=basic'] }); + let code = 0; const out = []; + for (const u of o.users) { + const role = u.slice(0, u.indexOf('=')), cred = u.slice(u.indexOf('=') + 1); + const user = cred.slice(0, cred.indexOf(':')), pass = cred.slice(cred.indexOf(':') + 1); + const ctx = await browser.newContext({ viewport: { width: 1440, height: 900 } }); const page = await ctx.newPage(); + watch(page); + const r = { role, widget: o.widget }; + try { + await page.goto(o.url.replace(/\/$/, '') + '/login.html', { waitUntil: 'domcontentloaded' }); + await page.fill('#usernameInput', user); await page.fill('#passwordInput', pass); await page.click('#loginButton'); + await page.waitForSelector('.mx-page', { timeout: 30000 }); + if (o.open) { + const exact = new RegExp('^\\s*' + o.open.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + '\\s*$'); + const item = page.locator('.mx-navigationtree a, .mx-navbar a, .mx-menubar a').filter({ hasText: exact }).first(); + await item.waitFor({ timeout: 15000 }).catch(() => {}); + if (!await item.count()) throw new Error('menu item "' + o.open + '" not found'); + await item.click(); + } + Object.assign(r, await check(page, { widget: o.widget, data: o.data, strict: o.strict })); + r.verdict = r.ok ? 'PASS' : 'FAIL'; + } catch (e) { r.verdict = 'INVALID'; r.reason = String(e.message).split('\n')[0]; } + if (o.shot) await page.screenshot({ path: o.users.length > 1 ? o.shot.replace(/\.png$/, '-' + role + '.png') : o.shot }).catch(() => {}); + await ctx.close(); + code = Math.max(code, r.verdict === 'PASS' ? 0 : r.verdict === 'FAIL' ? 1 : 2); + out.push(r); + const m = r.m || {}; + console.log(`${r.verdict.padEnd(7)} ${role} .mx-name-${o.widget}${r.reason ? ': ' + r.reason : ''}`); + if (m.found) console.log(` box ${m.box.join(',')}, ${m.drawn} drawn of ${m.kids} shown descendants; ` + m.parts.map(p => `${p.sel} ${p.drawn}/${p.n} drawn${p.flat ? ', ' + p.flat + ' at 0 px' : ''}`).join('; ')); + for (const e of r.errors || []) console.log(' error: ' + e.split('\n')[0].slice(0, 160)); + for (const e of r.notes || []) console.log(' note: ' + e.split('\n')[0].slice(0, 160)); + } + await browser.close(); + if (o.out) fs.writeFileSync(o.out, JSON.stringify(out, null, 1)); + process.exit(code); +})().catch(e => { console.error('widgetrender: ' + e.stack); process.exit(2); }); diff --git a/upgrade-toolkit/playbooks/widget-render.tsv b/upgrade-toolkit/playbooks/widget-render.tsv new file mode 100644 index 0000000..5968d31 --- /dev/null +++ b/upgrade-toolkit/playbooks/widget-render.tsv @@ -0,0 +1,11 @@ +# What a drawn widget has, beyond the generic rules of bin/widgetrender.js (size, drawn content, no error text, no client +# error from the widget's own script). Read by widgetrender.js; one row per (widget, part). +# root: a class on the widget's root element (the element with the mx-name-* class); a comma list when versions differ +# (Ultimate Scheduler 1.4.0 bizzomate-scheduler, 3.8.0 ciphix-scheduler: both draw a Bryntum grid). selector: inside that root. +# rule: "h>0" = every match is drawn with a height above 0 (a part that collapsed to nothing); "min=N" = at least N drawn +# matches. when: always, or data = only when the check is told the records exist ("data": true, after a DB check). +# A row is added from a real broken render, with the build it was seen on. +root selector rule when reason source +bizzomate-scheduler,ciphix-scheduler .b-grid-subgrid h>0 always the resource rows area: 0 px tall with Ultimate Scheduler 1.4.0 on the 11.12 React client (header and toolbar drawn, no rows) FSM 11.12.7 before the 3.8.0 swap: TypeError setTimeSpan, React #520 +bizzomate-scheduler,ciphix-scheduler .b-grid-row min=1 data one row per resource (technician) same build: 0 rows, the fixed build 4 +bizzomate-scheduler,ciphix-scheduler .b-sch-event min=1 data the planned appointments same build: 0 events, the fixed build 4 diff --git a/upgrade-toolkit/steps/journeys.md b/upgrade-toolkit/steps/journeys.md index add42ad..8f8b9a7 100644 --- a/upgrade-toolkit/steps/journeys.md +++ b/upgrade-toolkit/steps/journeys.md @@ -108,6 +108,12 @@ What the generated journeys assert (content, not only "the page rendered"): entry point reaches through any chain of callers). The run prints them as INFO: listed, not blocking (E4-31, E5b-11, E5b-22). Real `todo` items stay INVALID; a `no-click-path` action you can prove dead in the OLD UI is `UNREACHABLE` (PASS*, its own count) with an evidence line, see "Coverage and honesty" (B4T2-14). + A pluggable widget is never a guard, and a guard only says the page opened. Whether the widget DREW is its own step: + `{"do": "rendered", "widget": "", "data": true}` (E2E-R1, `bin/widgetrender.js`, per-widget parts in + `playbooks/widget-render.tsv`). It FAILs a widget at 0 px, one with no drawn content, the client's "Could not render + widget" text, a playbook part that collapsed or is missing, or a client error from the widget's own script. Seen on + FSM 11.12.7 with Ultimate Scheduler 1.4.0: the page opened, every guard held, and the scheduler was a header over a + 0 px rows area. Pre-fix build FAIL 3/3, the 3.8.0 build PASS 3/3 (rows 8/8, events 4/4). Once per toolkit version: add `--positive-control`. Every ui-landing row must be PASS (mutant caught). A miss means the instrument cannot fail: stop. The run exits 0 when every ui-landing row is PASS and no row FAILs; it prints From c447116f7e46f2e5541974ffa3dc225eb4012e6d Mon Sep 17 00:00:00 2001 From: MendixMau Date: Mon, 16 Nov 2026 14:27:26 +0800 Subject: [PATCH 2/3] E2E-R1 review fixes: step-scoped client errors, display:none parts count as flat, widgetrender control - widgetrender.js: check() counts only errors logged after the step started - widgetrender.js: a part is flat when not shown or under 1 px tall (0x0 and display:none no longer pass h>0) - widgetrender.js: timeoutMs also from WIDGETRENDER_TIMEOUT_MS - controls/widgetrender_control.js + fixtures/widgetrender: broken, display:none and fixed pages (a minimal reconstruction of the Bryntum grid classes, not a captured page), wired as journeys-rendered-catch / -pass Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01HXpQSjPfSUmbjM87Luyq27 --- upgrade-toolkit/bin/widgetrender.js | 19 +++---- .../widgetrender/scheduler-broken-hidden.html | 10 ++++ .../widgetrender/scheduler-broken.html | 10 ++++ .../widgetrender/scheduler-fixed.html | 13 +++++ upgrade-toolkit/controls/run-controls.sh | 9 ++++ .../controls/widgetrender_control.js | 51 +++++++++++++++++++ 6 files changed, 103 insertions(+), 9 deletions(-) create mode 100644 upgrade-toolkit/controls/fixtures/widgetrender/scheduler-broken-hidden.html create mode 100644 upgrade-toolkit/controls/fixtures/widgetrender/scheduler-broken.html create mode 100644 upgrade-toolkit/controls/fixtures/widgetrender/scheduler-fixed.html create mode 100644 upgrade-toolkit/controls/widgetrender_control.js diff --git a/upgrade-toolkit/bin/widgetrender.js b/upgrade-toolkit/bin/widgetrender.js index 7ce23ac..7079229 100644 --- a/upgrade-toolkit/bin/widgetrender.js +++ b/upgrade-toolkit/bin/widgetrender.js @@ -13,13 +13,13 @@ // size its box is wider and taller than 0 // drawn it has a drawn descendant (box above 2 x 2 px, not hidden) with text, an image, a canvas or an svg // no error no "Could not render widget" / .alert-danger text inside it -// no client error from a widget script: a pageerror or console error since the last check whose text or stack names +// no client error from a widget script: a pageerror or console error logged during this step whose text or stack names // /widgets/ (resource 404s and errors from other scripts are listed as notes, not FAILs; "strict": true // FAILs on every client error) // Per widget, playbooks/widget-render.tsv rows whose root class (one of a comma list) the widget has: "h>0" (every match drawn with a height) // and "min=N" (at least N drawn matches); rows marked data apply only with "data": true (the step's DB check showed // the records exist: an empty scheduler on an empty table is not a defect). Inline "expect": [{"sel", "min"|"h"}] too. -// It polls up to timeoutMs (default 15000) until every rule holds on a still widget (nothing loading, two looks one +// It polls up to timeoutMs (default 15000; env WIDGETRENDER_TIMEOUT_MS or "timeoutMs") until every rule holds on a still widget (nothing loading, two looks one // second apart alike), so a widget still fetching gets its time; the verdict is the last state seen. // // journey step: {"do": "rendered", "widget": "bizzomateUltimateScheduler1", "data": true} @@ -43,10 +43,10 @@ function rules(file = PLAYBOOK) { return rows.map(l => Object.fromEntries(l.split('\t').map((v, i) => [head[i], v]))); } -// Record client errors from the moment the page exists; check() reads the ones since its previous call. +// Record client errors from the moment the page exists; check() reads the ones logged since it started. function watch(page) { if (LOGS.has(page)) return; - const log = { errs: [], seen: 0 }; LOGS.set(page, log); + const log = { errs: [] }; LOGS.set(page, log); page.on('pageerror', e => log.errs.push('pageerror: ' + String(e.stack || e.message).slice(0, 600))); page.on('console', m => { if (m.type() !== 'error') return; @@ -74,7 +74,7 @@ function measure(page, name, parts) { const got = parts.map(p => { const m = [...el.querySelectorAll(p.sel)]; return { ...p, n: m.length, drawn: m.filter(shown).length, - flat: m.filter(e => { const b = e.getBoundingClientRect(); return b.width > 0 && b.height < 1; }).length }; + flat: m.filter(e => !shown(e) || e.getBoundingClientRect().height < 1).length }; }); return { found: true, cls: el.className, box: [r.x, r.y, r.width, r.height].map(Math.round), kids: kids.length, drawn, errText, busy: !!el.querySelector('[class*="is-fetching"], [class*="is-loading"], .mx-progress'), parts: got }; @@ -87,7 +87,7 @@ function verdict(m, name) { if (!m.drawn) return `nothing drawn: ${m.kids} shown descendants, none with text, an image, a canvas or an svg`; if (m.errText.length) return 'error text in the widget: ' + m.errText[0]; for (const p of m.parts) { - if (p.h && (!p.n || p.flat)) return `${p.sel}: ${p.flat} of ${p.n} drawn 0 px tall (${p.why})`; + if (p.h && (!p.n || p.flat)) return `${p.sel}: ${p.flat} of ${p.n} not drawn or 0 px tall (${p.why})`; if (p.min && p.drawn < p.min) return `${p.sel}: ${p.drawn} drawn, at least ${p.min} expected (${p.why})`; } return null; @@ -96,8 +96,9 @@ function verdict(m, name) { // a: {widget, data, strict, expect, timeoutMs, rules}. Returns {ok, reason, m, errors, notes}; never throws on a FAIL. async function check(page, a) { watch(page); + const log = LOGS.get(page), from = log.errs.length; // only errors logged from this step on count (an earlier page's error is not this step's) const all = a.rules || rules(); - const ms = a.timeoutMs || 15000, until = Date.now() + ms; + const ms = a.timeoutMs || Number(process.env.WIDGETRENDER_TIMEOUT_MS) || 15000, until = Date.now() + ms; let m, bad, parts = [], last = ''; for (;;) { // the root's classes pick the playbook rows; read each round, the widget may mount after the page opened @@ -114,7 +115,7 @@ async function check(page, a) { last = sig; await page.waitForTimeout(bad ? 500 : 1000); } - const log = LOGS.get(page); const errs = log.errs.slice(log.seen); log.seen = log.errs.length; + const errs = log.errs.slice(from); const mine = errs.filter(e => !IGNORE.some(re => re.test(e)) && (a.strict || /\/widgets\//.test(e))); const notes = errs.filter(e => !mine.includes(e)); if (mine.length) bad = (bad ? bad + '; ' : '') + 'client error from a widget script: ' + mine[0].split('\n')[0].slice(0, 200); @@ -166,7 +167,7 @@ if (require.main === module) (async () => { out.push(r); const m = r.m || {}; console.log(`${r.verdict.padEnd(7)} ${role} .mx-name-${o.widget}${r.reason ? ': ' + r.reason : ''}`); - if (m.found) console.log(` box ${m.box.join(',')}, ${m.drawn} drawn of ${m.kids} shown descendants; ` + m.parts.map(p => `${p.sel} ${p.drawn}/${p.n} drawn${p.flat ? ', ' + p.flat + ' at 0 px' : ''}`).join('; ')); + if (m.found) console.log(` box ${m.box.join(',')}, ${m.drawn} drawn of ${m.kids} shown descendants; ` + m.parts.map(p => `${p.sel} ${p.drawn}/${p.n} drawn${p.flat ? ', ' + p.flat + ' not drawn or 0 px' : ''}`).join('; ')); for (const e of r.errors || []) console.log(' error: ' + e.split('\n')[0].slice(0, 160)); for (const e of r.notes || []) console.log(' note: ' + e.split('\n')[0].slice(0, 160)); } diff --git a/upgrade-toolkit/controls/fixtures/widgetrender/scheduler-broken-hidden.html b/upgrade-toolkit/controls/fixtures/widgetrender/scheduler-broken-hidden.html new file mode 100644 index 0000000..86760f4 --- /dev/null +++ b/upgrade-toolkit/controls/fixtures/widgetrender/scheduler-broken-hidden.html @@ -0,0 +1,10 @@ +widgetrender fixture + +
+
Scheduler toolbar
+
Mon Tue Wed
+ +
diff --git a/upgrade-toolkit/controls/fixtures/widgetrender/scheduler-broken.html b/upgrade-toolkit/controls/fixtures/widgetrender/scheduler-broken.html new file mode 100644 index 0000000..b18993f --- /dev/null +++ b/upgrade-toolkit/controls/fixtures/widgetrender/scheduler-broken.html @@ -0,0 +1,10 @@ +widgetrender fixture + +
+
Scheduler toolbar
+
Mon Tue Wed
+
+
diff --git a/upgrade-toolkit/controls/fixtures/widgetrender/scheduler-fixed.html b/upgrade-toolkit/controls/fixtures/widgetrender/scheduler-fixed.html new file mode 100644 index 0000000..d510119 --- /dev/null +++ b/upgrade-toolkit/controls/fixtures/widgetrender/scheduler-fixed.html @@ -0,0 +1,13 @@ +widgetrender fixture + +
+
Scheduler toolbar
+
Mon Tue Wed
+
+
Technician A
Repair
+
Technician B
Inspect
+
+
diff --git a/upgrade-toolkit/controls/run-controls.sh b/upgrade-toolkit/controls/run-controls.sh index b0b6f6e..0bc15d3 100755 --- a/upgrade-toolkit/controls/run-controls.sh +++ b/upgrade-toolkit/controls/run-controls.sh @@ -2174,6 +2174,15 @@ if [ -f ${TOOLKIT_E2E:-$B/../vendor/e2e}/journey-runner.js ]; then else skip journeys-engine-login-page-home-catch "no playwright with a browser"; skip journeys-landing-guard-catch "no playwright with a browser"; skip journeys-landing-guard-pass "no playwright with a browser"; fi else skip journeys-engine-patch-pass "no shared journey engine"; skip journeys-engine-syntax-pass "no shared journey engine"; skip journeys-engine-ready-any-match-pass "no shared journey engine"; skip journeys-engine-patch-drift-catch "no shared journey engine" skip journeys-engine-login-page-home-patch-pass "no shared journey engine"; skip journeys-engine-login-page-home-catch "no shared journey engine"; fi +# E2E-R1: the rendered verb (bin/widgetrender.js) on fixtures/widgetrender in a real browser: a collapsed or display:none part fails, +# the drawn one passes, an error logged before the step is not this step's. Needs no journey engine, only playwright with a browser. +RPW=${PLAYWRIGHT_NODE_PATH:-$HOME/mendix-playwright/node_modules} +NODE_PATH=$RPW node -e "require('playwright')" 2> /dev/null || RPW=$(npm root -g 2> /dev/null) +# a test launch, not executablePath(): a headless-shell install has no full Chrome at that path and still launches +if NODE_PATH=$RPW node -e "require('playwright').chromium.launch({args:['--use-mock-keychain','--password-store=basic']}).then(b=>b.close()).then(()=>process.exit(0),()=>process.exit(1))" 2> /dev/null; then + ctl journeys-rendered-catch 0 '^ok +broken: 0 px subgrid' '^ok +broken: part display:none' '^ok +broken, no data flag' '^ok +error logged during the step' '!^FAIL' -- env NODE_PATH=$RPW node $here/widgetrender_control.js + ctl journeys-rendered-pass 0 '^ok +fixed: rows and events drawn: PASS' '^ok +fixed, no data flag: PASS' '^ok +error logged before the step: PASS' '!^FAIL' -- env NODE_PATH=$RPW node $here/widgetrender_control.js +else skip journeys-rendered-catch "no playwright with a browser"; skip journeys-rendered-pass "no playwright with a browser"; fi # FN-3..FN-7, FN-11 (field finish pass): generator fixes on fake models (controls/generator_fn_control.py) GFN="python3 $here/generator_fn_control.py" ctl gen-fn-in-list-pass 0 '^ok +fields keep a list input, marked' '^ok +in_list fill is optional' '^ok +in_list fill has no own-row check' '^ok +fields leave a plain input unmarked' '!^FAIL' -- $GFN diff --git a/upgrade-toolkit/controls/widgetrender_control.js b/upgrade-toolkit/controls/widgetrender_control.js new file mode 100644 index 0000000..114a56f --- /dev/null +++ b/upgrade-toolkit/controls/widgetrender_control.js @@ -0,0 +1,51 @@ +'use strict'; +// widgetrender_control.js: bin/widgetrender.js measure/verdict/check in a real browser (E2E-R1 review fixes). +// +// node widgetrender_control.js (NODE_PATH must reach playwright with a browser) +// +// Pages: fixtures/widgetrender/*.html, a minimal reconstruction of the Bryntum grid classes the playbook selects, +// not a captured page. Cases, one line each ("ok : " or "FAIL : "): +// broken: subgrid 0 px tall, no rows, no events FAIL naming .b-grid-subgrid +// broken, part display:none (n>0, drawn 0) FAIL naming .b-grid-subgrid (the old flat count missed it) +// fixed: rows and events drawn PASS +// fixed, no data flag: only the h>0 row applies PASS +// broken, no data flag: the h>0 row still fails FAIL +// error logged before the step PASS (an earlier page's /widgets/ error is not this step's) +// error logged during the step FAIL naming the widget script error +// Exit 0 when every case holds, 1 otherwise. +const path = require('path'); +const { chromium } = require('playwright'); +const R = require('../bin/widgetrender.js'); +const dir = path.join(__dirname, 'fixtures', 'widgetrender'); +const url = f => 'file://' + path.join(dir, f); +const A = { widget: 'scheduler1', data: true, timeoutMs: 2500 }; + +(async () => { + let fail = 0; + const check = (name, ok, detail) => { if (!ok) fail++; console.log(`${ok ? 'ok ' : 'FAIL'} ${name}: ${detail}`); }; + const browser = await chromium.launch({ args: ['--use-mock-keychain', '--password-store=basic'] }); + const open = async f => { const ctx = await browser.newContext(); const page = await ctx.newPage(); R.watch(page); await page.goto(url(f)); return page; }; + let p, r; + p = await open('scheduler-broken.html'); r = await R.check(p, A); + check('broken: 0 px subgrid', !r.ok && /\.b-grid-subgrid/.test(r.reason), r.reason); + p = await open('scheduler-broken-hidden.html'); r = await R.check(p, A); + const part = r.m.parts.find(x => x.sel === '.b-grid-subgrid'); + check('broken: part display:none', !r.ok && /\.b-grid-subgrid: 1 of 1/.test(r.reason) && part.flat === 1, r.reason); + p = await open('scheduler-fixed.html'); r = await R.check(p, A); + check('fixed: rows and events drawn', r.ok, r.ok ? 'PASS' : r.reason); + r = await R.check(p, { ...A, data: false }); + check('fixed, no data flag', r.ok, r.ok ? 'PASS' : r.reason); + p = await open('scheduler-broken.html'); r = await R.check(p, { ...A, data: false }); + check('broken, no data flag', !r.ok && /\.b-grid-subgrid/.test(r.reason), r.reason); + p = await open('scheduler-fixed.html'); + await p.evaluate(() => console.error('Error from /widgets/ciphix/scheduler.js: earlier page')); + await p.waitForTimeout(200); + r = await R.check(p, A); + check('error logged before the step', r.ok && !r.errors.length, r.ok ? 'PASS' : r.reason); + setTimeout(() => p.evaluate(() => console.error('Error from /widgets/ciphix/scheduler.js: during step')).catch(() => {}), 300); + r = await R.check(p, A); + check('error logged during the step', !r.ok && /client error from a widget script/.test(r.reason), r.reason); + await browser.close(); + console.log(fail ? `${fail} FAILED` : 'all ok'); + process.exit(fail ? 1 : 0); +})().catch(e => { console.log(`FAIL control crashed: ${e.stack}`); process.exit(1); }); From a78ab2fefbe3af41e49a3059be297015c53384ce Mon Sep 17 00:00:00 2001 From: MendixMau Date: Mon, 16 Nov 2026 14:36:34 +0800 Subject: [PATCH 3/3] E2E-R1 review fix: the hidden-part fixture is visibility:hidden at 200 px, so the selftest fails when the !shown flat rule is reverted Review: MERGE-AFTER-FIX: display:none has a 0 px box, so the old height test already passed it. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01HXpQSjPfSUmbjM87Luyq27 --- .../fixtures/widgetrender/scheduler-broken-hidden.html | 2 +- upgrade-toolkit/controls/run-controls.sh | 2 +- upgrade-toolkit/controls/widgetrender_control.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/upgrade-toolkit/controls/fixtures/widgetrender/scheduler-broken-hidden.html b/upgrade-toolkit/controls/fixtures/widgetrender/scheduler-broken-hidden.html index 86760f4..63875d2 100644 --- a/upgrade-toolkit/controls/fixtures/widgetrender/scheduler-broken-hidden.html +++ b/upgrade-toolkit/controls/fixtures/widgetrender/scheduler-broken-hidden.html @@ -6,5 +6,5 @@
Scheduler toolbar
Mon Tue Wed
- +
diff --git a/upgrade-toolkit/controls/run-controls.sh b/upgrade-toolkit/controls/run-controls.sh index 0bc15d3..8b8a900 100755 --- a/upgrade-toolkit/controls/run-controls.sh +++ b/upgrade-toolkit/controls/run-controls.sh @@ -2180,7 +2180,7 @@ RPW=${PLAYWRIGHT_NODE_PATH:-$HOME/mendix-playwright/node_modules} NODE_PATH=$RPW node -e "require('playwright')" 2> /dev/null || RPW=$(npm root -g 2> /dev/null) # a test launch, not executablePath(): a headless-shell install has no full Chrome at that path and still launches if NODE_PATH=$RPW node -e "require('playwright').chromium.launch({args:['--use-mock-keychain','--password-store=basic']}).then(b=>b.close()).then(()=>process.exit(0),()=>process.exit(1))" 2> /dev/null; then - ctl journeys-rendered-catch 0 '^ok +broken: 0 px subgrid' '^ok +broken: part display:none' '^ok +broken, no data flag' '^ok +error logged during the step' '!^FAIL' -- env NODE_PATH=$RPW node $here/widgetrender_control.js + ctl journeys-rendered-catch 0 '^ok +broken: 0 px subgrid' '^ok +broken: part hidden' '^ok +broken, no data flag' '^ok +error logged during the step' '!^FAIL' -- env NODE_PATH=$RPW node $here/widgetrender_control.js ctl journeys-rendered-pass 0 '^ok +fixed: rows and events drawn: PASS' '^ok +fixed, no data flag: PASS' '^ok +error logged before the step: PASS' '!^FAIL' -- env NODE_PATH=$RPW node $here/widgetrender_control.js else skip journeys-rendered-catch "no playwright with a browser"; skip journeys-rendered-pass "no playwright with a browser"; fi # FN-3..FN-7, FN-11 (field finish pass): generator fixes on fake models (controls/generator_fn_control.py) diff --git a/upgrade-toolkit/controls/widgetrender_control.js b/upgrade-toolkit/controls/widgetrender_control.js index 114a56f..774dff2 100644 --- a/upgrade-toolkit/controls/widgetrender_control.js +++ b/upgrade-toolkit/controls/widgetrender_control.js @@ -6,7 +6,7 @@ // Pages: fixtures/widgetrender/*.html, a minimal reconstruction of the Bryntum grid classes the playbook selects, // not a captured page. Cases, one line each ("ok : " or "FAIL : "): // broken: subgrid 0 px tall, no rows, no events FAIL naming .b-grid-subgrid -// broken, part display:none (n>0, drawn 0) FAIL naming .b-grid-subgrid (the old flat count missed it) +// broken, part visibility:hidden, 200 px tall FAIL naming .b-grid-subgrid (the old flat count missed it) // fixed: rows and events drawn PASS // fixed, no data flag: only the h>0 row applies PASS // broken, no data flag: the h>0 row still fails FAIL @@ -30,7 +30,7 @@ const A = { widget: 'scheduler1', data: true, timeoutMs: 2500 }; check('broken: 0 px subgrid', !r.ok && /\.b-grid-subgrid/.test(r.reason), r.reason); p = await open('scheduler-broken-hidden.html'); r = await R.check(p, A); const part = r.m.parts.find(x => x.sel === '.b-grid-subgrid'); - check('broken: part display:none', !r.ok && /\.b-grid-subgrid: 1 of 1/.test(r.reason) && part.flat === 1, r.reason); + check('broken: part hidden', !r.ok && /\.b-grid-subgrid: 1 of 1/.test(r.reason) && part.flat === 1, r.reason); p = await open('scheduler-fixed.html'); r = await R.check(p, A); check('fixed: rows and events drawn', r.ok, r.ok ? 'PASS' : r.reason); r = await R.check(p, { ...A, data: false });