Download web/scripts/verify-pulse-ui.mjs from loveaa/OneAlign: direct link, hf CLI and curl.
- Browser
- Download file 2.64 kB
-
https://huggingface.co/spaces/loveaa/OneAlign/resolve/main/web/scripts/verify-pulse-ui.mjs
- Command line
-
hf download hf://spaces/loveaa/OneAlign/web/scripts/verify-pulse-ui.mjs
-
curl -L -o verify-pulse-ui.mjs https://huggingface.co/spaces/loveaa/OneAlign/resolve/main/web/scripts/verify-pulse-ui.mjs
2.64 kB
| import fs from 'node:fs' | |
| import path from 'node:path' | |
| import {createRequire} from 'node:module' | |
| import assert from 'node:assert/strict' | |
| const require=createRequire(import.meta.url) | |
| const {chromium}=require(process.env.PLAYWRIGHT_MODULE||'C:/Users/didi/.cache/codex-runtimes/codex-primary-runtime/dependencies/node/node_modules/playwright') | |
| const base=process.env.PULSE_TEST_URL||'http://127.0.0.1:7103' | |
| const output=path.resolve('../tmp/pulse-ui-20261015');fs.mkdirSync(output,{recursive:true}) | |
| const browser=await chromium.launch({headless:true,executablePath:process.env.CHROME_EXECUTABLE||'C:/Program Files/Google/Chrome/Application/chrome.exe'}) | |
| const state=path.resolve('.local/pulse-ui-browser-state.json') | |
| const context=await browser.newContext({viewport:{width:1480,height:1020},deviceScaleFactor:1,...(fs.existsSync(state)?{storageState:state}:{})}) | |
| const page=await context.newPage(),errors=[] | |
| page.on('pageerror',e=>errors.push(e.message)) | |
| const report={at:new Date().toISOString(),base,checks:[],errors} | |
| try{ | |
| for(const [route,name] of [['/app','app-home'],['/workspace','desktop-home'],['/app/agent','app-agent'],['/app/devices','app-devices'],['/app/metrics','app-metrics']]){ | |
| await page.goto(base+route);await page.getByRole('link',{name:'Home Pulse',exact:true}).first().waitFor();await page.waitForFunction(()=>!document.querySelector('.pulse-inspector-head')?.textContent.includes('正在连接'),{timeout:30000});await page.waitForTimeout(600) | |
| if(route==='/app'){await page.waitForFunction(()=>[...document.querySelectorAll('.pulse-home-photo img')].every(im=>im.complete&&im.naturalWidth>0),{timeout:20000})} | |
| await page.screenshot({path:path.join(output,name+'.png')});report.checks.push(route) | |
| } | |
| await page.setViewportSize({width:390,height:844});await page.goto(base+'/app');await page.waitForTimeout(1000);await page.screenshot({path:path.join(output,'mobile-390.png')}) | |
| assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth),true,'Mobile viewport must not overflow horizontally') | |
| report.checks.push('390px responsive layout') | |
| await context.storageState({path:state}) | |
| assert.deepEqual(errors,[]) | |
| report.status='passed';console.log('Browser route checks passed:',report.checks.length) | |
| }catch(e){report.status='failed';report.failure=e.message;await page.screenshot({path:path.join(output,'failure.png')}).catch(()=>{});console.log('Browser check stopped:',e.message);process.exitCode=1} | |
| finally{fs.writeFileSync(path.join(output,'smoke-report.json'),JSON.stringify(report,null,2));await context.storageState({path:state});await browser.close()} | |