Download task_023/tests/validate_ui_behavior.js from Lego-X/UXInteract: direct link, hf CLI and curl.
- Browser
- Download file 2.77 kB
-
https://huggingface.co/datasets/Lego-X/UXInteract/resolve/main/task_023/tests/validate_ui_behavior.js
- Command line
-
hf download hf://datasets/Lego-X/UXInteract/task_023/tests/validate_ui_behavior.js
-
curl -L -o validate_ui_behavior.js https://huggingface.co/datasets/Lego-X/UXInteract/resolve/main/task_023/tests/validate_ui_behavior.js
2.77 kB
| const fs = require('fs'); | |
| const path = require('path'); | |
| const { pathToFileURL } = require('url'); | |
| const { chromium } = require('playwright'); | |
| (async () => { | |
| const root = process.cwd(); | |
| if (fs.existsSync(path.join(root, 'figma'))) throw new Error('figma folder should be removed'); | |
| for (const entry of fs.readdirSync(root, { withFileTypes: true })) { | |
| if (entry.isDirectory() && entry.name.toLowerCase() === 'figma') throw new Error('no figma directory should remain'); | |
| } | |
| const sourceFiles = []; | |
| function walk(dir) { | |
| for (const entry of fs.readdirSync(dir, { withFileTypes: true })) { | |
| const p = path.join(dir, entry.name); | |
| if (entry.isDirectory() && !['tests','logs','node_modules'].includes(entry.name)) walk(p); | |
| if (entry.isFile() && /\.(js|jsx|ts|tsx)$/.test(entry.name)) sourceFiles.push(p); | |
| } | |
| } | |
| walk(root); | |
| const joined = sourceFiles.map(p => fs.readFileSync(p, 'utf8')).join('\n'); | |
| if (/from\s+['\"][^'\"]*figma|require\(['\"][^'\"]*figma|@\/components\/figma/.test(joined)) throw new Error('source should not keep stale figma imports after removing the folder'); | |
| const app = fs.readFileSync(path.join(root, 'src', 'app.js'), 'utf8'); | |
| if (!app.includes('sendPrompt')) throw new Error('application sendPrompt logic should remain present'); | |
| if (!fs.existsSync(path.join(root, 'package.json'))) throw new Error('project config should be preserved'); | |
| const browser = await chromium.launch({ headless: true }); | |
| const page = await browser.newPage(); | |
| await page.goto(pathToFileURL(path.join(root, 'index.html')).href, { waitUntil: 'domcontentloaded' }); | |
| // Accept either the data-testid contract hooks OR the starter fixture's original | |
| // ids (#prompt / #send / #output and a <main>/#app root). The instruction says the | |
| // app logic must NOT change after removing figma/, so a solution that merely deletes | |
| // the folder and keeps the fixture's original markup must still pass. | |
| const appRoot = page.locator('[data-testid="app-root"], main, #app').first(); | |
| const promptInput = page.locator('[data-testid="prompt-input"], #prompt').first(); | |
| const sendButton = page.locator('[data-testid="send-button"], #send').first(); | |
| const outputArea = page.locator('[data-testid="output-area"], #output').first(); | |
| if (!(await appRoot.isVisible())) throw new Error('core page should still render after cleanup'); | |
| await promptInput.fill('hello restored app'); | |
| await sendButton.click(); | |
| await page.waitForTimeout(100); | |
| const output = (await outputArea.textContent()) || ''; | |
| if (!/hello restored app/.test(output)) throw new Error('send/output area should keep working after figma cleanup'); | |
| await browser.close(); | |
| })().catch(err => { console.error(err && err.stack || err); process.exit(1); }); | |