23 lines
5.1 KiB
JavaScript
23 lines
5.1 KiB
JavaScript
|
|
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.getByRole('button',{name:'新建',exact:true}).click();await page.getByRole('button',{name:'载入鲲鹏示例',exact:true}).click();await page.locator('.v2-shots>section').nth(19).waitFor();
|
|||
|
|
if(await page.locator('.v2-shots>section').count()!==20)throw new Error('Example shot count');
|
|||
|
|
await page.getByText('20 个镜头 · 2400 帧 · 100.00 秒',{exact:true}).waitFor();
|
|||
|
|
const first=page.locator('.v2-shots>section').first(),second=page.locator('.v2-shots>section').nth(1),original=await first.locator('textarea').inputValue();
|
|||
|
|
await first.getByRole('button',{name:'后移',exact:true}).click();if(await second.locator('textarea').inputValue()!==original)throw new Error('Move shot');await second.getByRole('button',{name:'前移',exact:true}).click();
|
|||
|
|
const duration=first.locator('.el-input-number input').first();await duration.fill('1');await duration.press('Tab');await page.getByText('20 个镜头 · 2304 帧 · 96.00 秒',{exact:true}).waitFor();await duration.fill('5');await duration.press('Tab');
|
|||
|
|
await page.getByRole('button',{name:'添加镜头',exact:true}).click();if(await page.locator('.v2-shots>section').count()!==21)throw new Error('Add shot');await page.locator('.v2-shots>section').last().getByRole('button',{name:'删除镜头',exact:true}).click();
|
|||
|
|
await page.getByPlaceholder('故事名称').fill('鲲鹏·20镜头100秒示例(未运行)');const pending=page.waitForResponse(r=>r.url().endsWith('/api/workflows')&&r.request().method()==='POST');await page.getByRole('button',{name:'保存草稿',exact:true}).click();const response=await pending;if(response.status()!==201)throw new Error('Save new example status '+response.status());const draft=await response.json();if(draft.current_run_id)throw new Error('Saving must not run');
|
|||
|
|
await page.reload();await page.getByText('20 个镜头 · 2400 帧 · 100.00 秒',{exact:true}).waitFor();await page.screenshot({path:path.join(root,'qa/v3-workflow-desktop.png')});
|
|||
|
|
await page.mouse.move(1000,700);await page.mouse.wheel(0,20000);await page.waitForTimeout(350);const desktop=await page.locator('.v2-page').evaluate(e=>({top:e.scrollTop,height:e.clientHeight,total:e.scrollHeight,overflow:e.scrollWidth>e.clientWidth+2}));if(desktop.top<1||desktop.overflow)throw new Error('Desktop scroll');
|
|||
|
|
await page.setViewportSize({width:390,height:844});await page.locator('.v2-page').evaluate(e=>e.scrollTop=0);await page.screenshot({path:path.join(root,'qa/v3-workflow-mobile.png')});await page.mouse.move(240,600);await page.mouse.wheel(0,50000);await page.waitForTimeout(350);const mobile=await page.locator('.v2-page').evaluate(e=>({top:e.scrollTop,height:e.clientHeight,total:e.scrollHeight,overflow:e.scrollWidth>e.clientWidth+2}));if(mobile.top<1||mobile.overflow||mobile.total-mobile.height-mobile.top>4)throw new Error('Mobile scroll or settings unreachable');await page.screenshot({path:path.join(root,'qa/v3-workflow-mobile-bottom.png')});
|
|||
|
|
const help=await browser.newPage({viewport:{width:1440,height:1000}});const manual=await help.goto(base+'/help/manual.html');if(manual.status()!==200)throw new Error('Manual unavailable');await help.getByRole('heading',{name:'CMVR Visual 操作手册',exact:true}).waitFor();await help.screenshot({path:path.join(root,'qa/v3-manual-desktop.png')});await help.setViewportSize({width:390,height:844});if(await help.evaluate(()=>document.documentElement.scrollWidth>innerWidth+2))throw new Error('Manual mobile horizontal overflow');await help.screenshot({path:path.join(root,'qa/v3-manual-mobile.png')});
|
|||
|
|
await help.goto(base+'/help/kunpeng.html');await help.getByRole('heading',{name:'鲲鹏长视频制作指南',exact:true}).waitFor();if(await help.locator('tbody tr').count()!==20)throw new Error('Story guide shot table');
|
|||
|
|
const report={draft_id:draft.id,saved_without_running:true,shots:20,seconds:100,add_remove_reorder_duration:true,desktop,mobile,manuals:true,errors};fs.writeFileSync(path.join(root,'qa/v3-browser.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});
|