Files
dj/integration-work/browser-test/verify_storyboard_delete_ui.cjs
2026-11-13 11:46:25 +08:00

23 lines
2.3 KiB
JavaScript

const {chromium}=require('playwright-core');const assert=require('node:assert/strict');const path=require('node:path');
(async()=>{
const browser=await chromium.launch({channel:'chrome',headless:true});
try {
const page=await browser.newPage({viewport:{width:1600,height:1100}}),errors=[];page.on('pageerror',e=>errors.push(e.message));
await page.goto('http://127.0.0.1:18986/drama/1/episode/1',{waitUntil:'networkidle'});
await page.getByText('视频制作',{exact:true}).first().click();
const row=id=>page.locator(`[data-storyboard-id="${id}"]`),dialog=page.getByRole('alertdialog');
await page.getByRole('button',{name:'删除分镜 5',exact:true}).click();await dialog.waitFor();
assert.match(await dialog.innerText(),/#05/);await dialog.getByRole('button',{name:'取消',exact:true}).click();assert.equal(await row(5).count(),1);
await page.getByRole('button',{name:'删除分镜 2',exact:true}).click();await dialog.getByRole('button',{name:'确认删除',exact:true}).click();
await page.getByText(/任务 #2 正在生成/).waitFor();assert.equal(await row(2).count(),1);await dialog.getByRole('button',{name:'取消',exact:true}).click();
await row(5).click();await page.getByRole('button',{name:'删除分镜 5',exact:true}).click();await dialog.getByRole('button',{name:'确认删除',exact:true}).click();await row(5).waitFor({state:'detached'});
assert.match(await row(6).innerText(),/#06/);
await page.getByRole('button',{name:'选择',exact:true}).click();await row(6).click();await row(7).click();
await page.getByTestId('delete-selected-storyboards').click();assert.match(await dialog.innerText(),/#06、#07/);
await dialog.getByRole('button',{name:'确认删除',exact:true}).click();await row(6).waitFor({state:'detached'});await row(7).waitFor({state:'detached'});
await page.reload({waitUntil:'networkidle'});assert.equal(await row(5).count(),0);assert.equal(await row(6).count(),0);assert.equal(await row(7).count(),0);assert.equal(await row(2).count(),1);
await page.screenshot({path:path.join(process.env.STORYBOARD_FIXTURE,'storyboard-delete-ui.png')});assert.deepEqual(errors,[]);
console.log('PASS UI: single delete confirmation, cancel, active rejection, batch, stable numbers, reload, no page errors');
} finally {await browser.close()}
})().catch(e=>{console.error(e.stack);process.exit(1)});