Download task_021/tests/validate_ui_behavior.js from Lego-X/UXInteract: direct link, hf CLI and curl.
- Browser
- Download file 1.46 kB
-
https://huggingface.co/datasets/Lego-X/UXInteract/resolve/main/task_021/tests/validate_ui_behavior.js
- Command line
-
hf download hf://datasets/Lego-X/UXInteract/task_021/tests/validate_ui_behavior.js
-
curl -L -o validate_ui_behavior.js https://huggingface.co/datasets/Lego-X/UXInteract/resolve/main/task_021/tests/validate_ui_behavior.js
1.46 kB
| const path = require('path'); | |
| const { pathToFileURL } = require('url'); | |
| const { chromium } = require('playwright'); | |
| (async () => { | |
| const browser = await chromium.launch({ headless: true }); | |
| const page = await browser.newPage({ viewport: { width: 1000, height: 700 } }); | |
| await page.goto(pathToFileURL(path.join(process.cwd(), 'index.html')).href, { waitUntil: 'domcontentloaded' }); | |
| const required = ['AppShell', 'NavigationSidebar', 'MainContentArea', 'PromptResponseBlock', 'PromptInput', 'AIContentArea']; | |
| const names = await page.locator('[data-component-name]').evaluateAll(nodes => nodes.map(n => n.getAttribute('data-component-name'))); | |
| for (const name of required) { | |
| if (!names.includes(name)) throw new Error(`missing data-component-name ${name}`); | |
| } | |
| const duplicates = names.filter((name, index) => names.indexOf(name) !== index); | |
| if (duplicates.length) throw new Error(`component names should be stable and unique: ${duplicates.join(',')}`); | |
| const registry = await page.evaluate(() => window.componentRegistry || window.COMPONENT_REGISTRY || null); | |
| if (!registry || typeof registry !== 'object') throw new Error('component registry should be exposed for future component-name conversations'); | |
| for (const name of required) { | |
| if (!(name in registry)) throw new Error(`component registry missing ${name}`); | |
| } | |
| await browser.close(); | |
| })().catch(err => { console.error(err && err.stack || err); process.exit(1); }); | |