const fs=require('fs'),path=require('path');const {chromium}=require('C:/Users/Administrator/.cache/codex-runtimes/codex-primary-runtime/dependencies/node/node_modules/playwright'); const root=path.resolve(__dirname,'..'),base='http://127.0.0.1:8000'; const env=Object.fromEntries(fs.readFileSync(path.join(root,'.env.server'),'utf8').split(/\r?\n/).filter(x=>x&&!x.startsWith('#')).map(x=>{const i=x.indexOf('=');return[x.slice(0,i),x.slice(i+1)]})); (async()=>{let browser;try{ browser=await chromium.launch({headless:true,channel:'chrome'});const page=await browser.newPage({viewport:{width:1440,height:1000}}),errors=[];page.on('pageerror',e=>errors.push(e.message)); await page.goto(base+'/login');await page.getByPlaceholder('输入你的账号').fill(env.ADMIN_USERNAME);await page.getByPlaceholder('输入密码',{exact:true}).fill(env.ADMIN_PASSWORD);await page.getByRole('button',{name:'进入工作空间'}).click();await page.waitForURL('**/create/image'); await page.goto(base+'/workflow');await page.getByRole('heading',{name:'把三个瞬间,连成一个故事。'}).waitFor();await page.locator('.v2-toolbar .el-select').first().click();await page.locator('.el-select-dropdown__item').filter({hasText:'V2验收-三分镜-20261110'}).click(); await page.getByRole('button',{name:'预览 workflow.mp4',exact:true}).waitFor({timeout:15000}); const order=await page.locator('.v2-step>strong').allTextContents();if(JSON.stringify(order)!==JSON.stringify(['镜头一','镜头二','镜头三','成片渲染']))throw new Error('Unexpected step display order'); await page.getByRole('button',{name:'预览 workflow.mp4',exact:true}).click();const video=page.locator('.el-dialog video');await video.waitFor(); await page.waitForFunction(()=>{const v=document.querySelector('.el-dialog video');return v&&v.readyState>=2&&Math.abs(v.duration-15)<.1}); await video.evaluate(async v=>{v.muted=true;await v.play();await new Promise(resolve=>{v.addEventListener('seeked',resolve,{once:true});v.currentTime=10.5});v.pause()}); const media=await video.evaluate(v=>({duration:v.duration,width:v.videoWidth,height:v.videoHeight,seek_seconds:v.currentTime,ready_state:v.readyState,error:v.error?.message||null}));if(media.error||Math.abs(media.seek_seconds-10.5)>.2)throw new Error('Playback seek failed'); await page.screenshot({path:path.join(root,'qa/v2-playback-desktop.png'),fullPage:true}); const report={step_order:order,media,errors};fs.writeFileSync(path.join(root,'qa/v2-playback.json'),JSON.stringify(report,null,2));console.log(JSON.stringify(report)); }finally{if(browser)await browser.close()}})().catch(e=>{console.error(e.message);process.exitCode=1});