ProWM-Bench / data /rs /probes /hacker0x01__react-datepicker-4643.json
simonlqy's picture
Initial release of ProWM-Bench v1.0.0 (part 2)
ea621d1 verified
Raw History Blame Contribute Delete
4.3 kB
{
"build_script": "build",
"build_workdir": ".",
"bundle_artifact": "",
"decision_relevant_fields": [
"adapter_state.newPropClassApplied",
"adapter_state.legacyWarningEmitted",
"adapter_state.legacyPropClassApplied"
],
"execution_mode": "node",
"expected_page_errors": [],
"instance_id": "hacker0x01__react-datepicker-4643",
"payload": {},
"predicate_description": "The new calendarIconClassName prop is applied to the calendar icon SVG and the legacy calendarIconClassname prop emits a deprecation warning.",
"predicate_js": "(s) => s.adapter_state.newPropClassApplied === true && s.adapter_state.legacyWarningEmitted === true",
"product_output_kind": "rendered_document",
"program_js": "const fs = require('fs');\n\nconst input = JSON.parse(Buffer.from(process.argv[1], 'base64').toString('utf8'));\nconst outputPath = process.argv[2];\n\nconst esc = (v) => String(v).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');\n\nlet state;\nlet page;\n\ntry {\n const React = require('react');\n const ReactDOMServer = require('react-dom/server');\n const DatePicker = require('/testbed/dist/index.js').default;\n\n const warnings = [];\n const originalWarn = console.warn;\n console.warn = (...args) => {\n warnings.push(args.join(' '));\n };\n\n const newPropClass = 'new-prop-class';\n const legacyPropClass = 'legacy-prop-class';\n\n const newPropHtml = ReactDOMServer.renderToStaticMarkup(\n React.createElement(DatePicker, {\n selected: new Date('2023-12-17T00:00:00Z'),\n showIcon: true,\n calendarIconClassName: newPropClass,\n toggleCalendarOnIconClick: true,\n })\n );\n\n const legacyPropHtml = ReactDOMServer.renderToStaticMarkup(\n React.createElement(DatePicker, {\n selected: new Date('2023-12-17T00:00:00Z'),\n showIcon: true,\n calendarIconClassname: legacyPropClass,\n toggleCalendarOnIconClick: true,\n })\n );\n\n console.warn = originalWarn;\n\n const newHasClass = newPropHtml.includes(newPropClass);\n const legacyHasClass = legacyPropHtml.includes(legacyPropClass);\n const legacyWarning = warnings.some(\n (w) => w.includes('calendarIconClassname') && w.includes('deprecated')\n );\n\n state = {\n render_ok: true,\n newPropClassApplied: newHasClass,\n legacyPropClassApplied: legacyHasClass,\n legacyWarningEmitted: legacyWarning,\n warnings: warnings,\n };\n\n page = `<!doctype html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<title>${esc(input.title)}</title>\n<style>\n body { font-family: sans-serif; padding: 20px; }\n .fixture { margin: 24px 0; padding: 16px; border: 1px solid #ddd; border-radius: 4px; }\n .fixture h3 { margin: 0 0 12px 0; font-size: 14px; color: #333; }\n .new-prop-class { fill: #e74c3c; }\n .legacy-prop-class { fill: #3498db; }\n svg { width: 24px; height: 24px; vertical-align: middle; }\n input { margin-left: 8px; padding: 4px; }\n</style>\n</head>\n<body>\n<div class=\"fixture\">\n <h3>calendarIconClassName (new prop)</h3>\n ${newPropHtml}\n</div>\n<div class=\"fixture\">\n <h3>calendarIconClassname (legacy prop)</h3>\n ${legacyPropHtml}\n</div>\n<script>window.__WM_STATE__=${JSON.stringify(state).replace(/</g, '\\\\u003c')};window.__WM_READY__=true;</script>\n</body>\n</html>`;\n} catch (e) {\n state = {\n render_ok: false,\n error: { name: String(e && e.name || 'Error'), message: String(e && e.message || e) },\n };\n page = `<!doctype html>\n<html lang=\"en\">\n<head><meta charset=\"utf-8\"><title>${esc(input.title)}</title></head>\n<body>\n<div role=\"alert\">${esc(state.error.name + ': ' + state.error.message)}</div>\n<script>window.__WM_STATE__=${JSON.stringify(state).replace(/</g, '\\\\u003c')};window.__WM_READY__=true;</script>\n</body>\n</html>`;\n}\n\nfs.writeFileSync(outputPath, page, 'utf8');",
"rationale": "Rendering with calendarIconClassName and the legacy calendarIconClassname shows the new prop is ignored before the fix and applied after, while the legacy prop emits a deprecation warning only after the fix.",
"repo": "Hacker0x01/react-datepicker",
"schema_version": "worldmodelmmbench.render-probe.v3",
"title": "Calendar icon class name prop naming",
"viewport": [
1280,
960
],
"volatile_fields": []
}