OneAlign / web /scripts /verify-pulse-catalog.mjs
loveaa's picture
Home Pulse 1.2: app interface, recommended event policies and independent location reminders
cdd19e1 verified
Raw History Blame Contribute Delete
2.28 kB
import fs from 'node:fs'
import {createRequire} from 'node:module'
import assert from 'node:assert/strict'
const require=createRequire(import.meta.url),{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',cloud=base.startsWith('https:'),report={base,checks:[],status:'running'}
const browser=await chromium.launch({headless:true,executablePath:process.env.CHROME_EXECUTABLE||'C:/Program Files/Google/Chrome/Application/chrome.exe'})
const page=await browser.newPage({viewport:{width:390,height:844}});page.setDefaultTimeout(40000)
let models=0
page.on('request',r=>{if(r.method()==='POST'&&/\/setups\/draft|\/trial$|\/observe$/.test(r.url()))models++})
await page.route('**/api/media/catalog',async route=>{await new Promise(r=>setTimeout(r,3000));await route.continue()})
try{
await page.goto(base+'/app/agent');const button=page.getByRole('button',{name:/小狗围栏守护/})
assert.equal(await button.isDisabled(),true);await button.click()
assert.match(await page.locator('select[aria-label="观察来源"] option:checked').innerText(),/幼犬翻越围栏/)
await page.waitForFunction(()=>document.querySelector('video')?.readyState>=2,null,{timeout:40000})
assert.match(await page.locator('video').getAttribute('src'),/smartbench_0188/)
await page.getByRole('button',{name:/观察画面/}).click();await page.screenshot({path:'../tmp/pulse-ui-20261015/'+(cloud?'cloud':'local')+'-correct-source.png'})
report.checks.push('Slow catalog cannot silently select another scene','Dog quick action selects the verified enclosure clip')
await page.goto(base+'/app');await page.waitForFunction(()=>{const im=document.querySelector('.pulse-home-photo img');return im?.complete&&im.naturalWidth>0},null,{timeout:40000})
report.checks.push('Home poster decodes as a real image');assert.equal(models,0);report.status='passed';console.log(JSON.stringify(report))
}catch(e){report.status='failed';report.failure=e.message;process.exitCode=1;console.log(JSON.stringify(report))}
finally{fs.writeFileSync('.local/pulse-catalog-'+(cloud?'cloud':'local')+'.json',JSON.stringify(report,null,2));await browser.close()}