Download task_019/tests/validate_ui_behavior.js from Lego-X/UXInteract: direct link, hf CLI and curl.
- Browser
- Download file 1.81 kB
-
https://huggingface.co/datasets/Lego-X/UXInteract/resolve/main/task_019/tests/validate_ui_behavior.js
- Command line
-
hf download hf://datasets/Lego-X/UXInteract/task_019/tests/validate_ui_behavior.js
-
curl -L -o validate_ui_behavior.js https://huggingface.co/datasets/Lego-X/UXInteract/resolve/main/task_019/tests/validate_ui_behavior.js
1.81 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(); | |
| await page.setViewportSize({ width: 500, height: 700 }); | |
| await page.goto(pathToFileURL(path.join(process.cwd(), 'index.html')).href, { waitUntil: 'domcontentloaded' }); | |
| let small = await page.locator('[data-testid="placeholder"]').boundingBox(); | |
| if (!small || small.x < 63) throw new Error(`small-window placeholder should keep 64px left margin, x=${small && small.x}`); | |
| await page.setViewportSize({ width: 1200, height: 800 }); | |
| await page.goto(pathToFileURL(path.join(process.cwd(), 'index.html')).href, { waitUntil: 'domcontentloaded' }); | |
| let expanded = await page.evaluate(() => { | |
| const sidebar = document.querySelector('[data-testid="sidebar"]').getBoundingClientRect(); | |
| const content = document.querySelector('[data-testid="main-content"]').getBoundingClientRect(); | |
| return { gap: content.left - sidebar.right, contentLeft: content.left, contentWidth: content.width, viewport: innerWidth, sidebarRight: sidebar.right }; | |
| }); | |
| if (expanded.gap < 63) throw new Error(`expanded sidebar/content gap should be at least 64px, got ${expanded.gap}`); | |
| const expandedCenter = expanded.contentLeft + expanded.contentWidth / 2; | |
| await page.locator('[data-testid="toggle-sidebar"]').click(); | |
| await page.waitForTimeout(150); | |
| let collapsed = await page.locator('[data-testid="main-content"]').boundingBox(); | |
| if (!collapsed || collapsed.x < 63) throw new Error(`collapsed content should keep 64px left margin, x=${collapsed && collapsed.x}`); | |
| await browser.close(); | |
| })().catch(err => { console.error(err && err.stack || err); process.exit(1); }); | |