Download task_013/tests/validate_ui_behavior.js from Lego-X/UXInteract: direct link, hf CLI and curl.
- Browser
- Download file 1.73 kB
-
https://huggingface.co/datasets/Lego-X/UXInteract/resolve/main/task_013/tests/validate_ui_behavior.js
- Command line
-
hf download hf://datasets/Lego-X/UXInteract/task_013/tests/validate_ui_behavior.js
-
curl -L -o validate_ui_behavior.js https://huggingface.co/datasets/Lego-X/UXInteract/resolve/main/task_013/tests/validate_ui_behavior.js
1.73 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: 900, height: 700 } }); | |
| await page.route(/^https?:\/\//, route => route.abort('blockedbyclient')); | |
| await page.goto(pathToFileURL(path.join(process.cwd(), 'index.html')).href, { waitUntil: 'domcontentloaded' }); | |
| await page.locator('[data-testid="write-trigger"]').click(); | |
| const prompt = page.locator('[data-testid="prompt-input"]'); | |
| await prompt.fill('first question'); | |
| await page.locator('[data-testid="send-button"]').click(); | |
| await page.waitForTimeout(150); | |
| const followup = page.locator('[data-testid="followup-input"]'); | |
| if (!(await followup.isVisible())) throw new Error('follow-up input should be created after first send'); | |
| const focusedId = await page.evaluate(() => document.activeElement && document.activeElement.getAttribute('data-testid')); | |
| if (focusedId !== 'followup-input') throw new Error(`follow-up input should autofocus, focused=${focusedId}`); | |
| await page.keyboard.type('second question'); | |
| const value = await followup.inputValue(); | |
| if (value !== 'second question') throw new Error('typing should go directly into focused follow-up input'); | |
| await page.keyboard.press('Enter'); | |
| await page.waitForTimeout(100); | |
| const submitted = (await page.evaluate(()=>window.__getSubmissions())).at(-1); | |
| if (submitted !== 'second question') { | |
| throw new Error('Enter should submit or record the focused follow-up question'); | |
| } | |
| await browser.close(); | |
| })().catch(err => { console.error(err && err.stack || err); process.exit(1); }); | |