fix(e2e): 加固核心生成向导冒烟测试(v2:按钮定位/等待/进度页断言) #1950
@@ -51,7 +51,7 @@ type AssetListResponse = {
|
||||
test.describe("Core generation flow", () => {
|
||||
test.describe.configure({ timeout: 360_000 })
|
||||
|
||||
test("walks through 5-step wizard and starts generation", async ({ page, request }) => {
|
||||
test("walks through wizard with count modal and starts generation", async ({ page, request }) => {
|
||||
test.setTimeout(360_000)
|
||||
|
||||
await routeBrowserApiToTestApi(page)
|
||||
@@ -215,19 +215,25 @@ test.describe("Core generation flow", () => {
|
||||
.waitFor({ state: "detached", timeout: 30_000 })
|
||||
.catch(() => {})
|
||||
|
||||
// Wait for generation API to be called
|
||||
// 前端直接创建生成任务:POST /generation/tasks
|
||||
// 定位底部操作栏的「✨ 确认生成视频」按钮(带 emoji 前缀,Playwright hasText 是子串匹配,无需写全)
|
||||
// 使用底部操作栏 xx-step-actions 作用域,避免命中标题页内的"换一个""生成标题"等其他 primary 按钮
|
||||
const confirmBtn = page
|
||||
.locator(".xx-step-actions .xx-btn-primary")
|
||||
.filter({ hasText: "确认生成" })
|
||||
await expect(confirmBtn).toBeVisible({ timeout: 30_000 })
|
||||
await expect(confirmBtn).toBeEnabled({ timeout: 30_000 })
|
||||
|
||||
// Wait for generation API to be called — 先挂监听再点击,避免竞态
|
||||
const generatePromise = page.waitForResponse(
|
||||
(response) => {
|
||||
const url = response.url()
|
||||
const path = new URL(url).pathname
|
||||
return response.request().method() === "POST" && path.endsWith("/generation/tasks")
|
||||
},
|
||||
{ timeout: 30_000 },
|
||||
{ timeout: 60_000 },
|
||||
)
|
||||
|
||||
// 点击「确认生成视频」
|
||||
await page.locator(".xx-btn-primary").filter({ hasText: "确认生成视频" }).first().click()
|
||||
await confirmBtn.click()
|
||||
|
||||
// Verify generation was triggered
|
||||
const genResp = await generatePromise
|
||||
@@ -247,16 +253,17 @@ test.describe("Core generation flow", () => {
|
||||
expect(genData.items.length).toBeGreaterThan(0)
|
||||
expect(genData.items[0].id).toBeTruthy()
|
||||
|
||||
// 单视频(N=1):点击「确认生成视频」后跳 Step 4「确认生成」,展示实时渲染进度
|
||||
await expect(page.getByRole("heading", { name: "🎬 确认生成" })).toBeVisible({
|
||||
timeout: 30_000,
|
||||
})
|
||||
// 单视频(N=1):点击「确认生成视频」后跳步骤 4「确认生成」进度页,展示进度卡
|
||||
// 注意:Step4 内容只有进度卡/错误卡,没有 h3「🎬 确认生成」标题;标题由 StepsBar 展示
|
||||
await expect(page.getByText("视频渲染中")).toBeVisible({ timeout: 30_000 })
|
||||
|
||||
// 等待渲染完成:进度卡变为「视频生成完成」(最长等待 3 分钟)
|
||||
await expect(page.getByText("视频生成完成")).toBeVisible({ timeout: 180_000 })
|
||||
|
||||
// 全部完成后「下一步:选择封面」解锁,点击进入 Step 5
|
||||
await page.getByRole("button", { name: /下一步:选择封面/ }).click()
|
||||
// 全部完成后底部按钮变为「下一步:选择封面」,点击进入 Step 5
|
||||
const nextCoverBtn = page.getByRole("button", { name: /下一步:选择封面/ })
|
||||
await expect(nextCoverBtn).toBeVisible({ timeout: 30_000 })
|
||||
await nextCoverBtn.click()
|
||||
await expect(page.getByRole("heading", { name: /选择封面/ })).toBeVisible({
|
||||
timeout: 30_000,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user