修正追踪初始化竞态与浏览器验证
This commit is contained in:
+54
-5
@@ -1,10 +1,61 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
test("中文界面可以生成优化文章和导出链接", async ({ page }) => {
|
||||
test.setTimeout(180_000);
|
||||
const jobId = "job_mvp";
|
||||
const factCard = {
|
||||
company_full_name: "Example Technology Co., Ltd.",
|
||||
company_short_names: ["Example Tech"],
|
||||
brand_names: ["Example"],
|
||||
product_names: ["Example GEO"],
|
||||
target_industry: "GEO optimization",
|
||||
target_audience: "市场团队",
|
||||
experience_years: 8,
|
||||
core_claims: ["拥有 8 年 GEO 优化经验"],
|
||||
forbidden_claims: [],
|
||||
image_topics: ["产品仪表盘"],
|
||||
uncertain_items: [],
|
||||
is_ready_for_optimization: true,
|
||||
confirmed_by_user: false,
|
||||
};
|
||||
const article = {
|
||||
job_id: jobId,
|
||||
revision: 1,
|
||||
title: "Example Technology Co., Ltd. GEO 指南",
|
||||
summary: "面向市场团队的 GEO 优化说明。",
|
||||
body_markdown: "## 服务能力\nExample GEO 帮助团队优化内容结构。",
|
||||
image_suggestions: [],
|
||||
changed_sections: ["title", "body"],
|
||||
requires_user_confirmation: [],
|
||||
};
|
||||
const qaReport = {
|
||||
job_id: jobId,
|
||||
revision: 1,
|
||||
overall_status: "pass",
|
||||
checks: [],
|
||||
};
|
||||
|
||||
await page.route("**/api/jobs/optimize-stream", async (route) => {
|
||||
const events = [
|
||||
{ type: "job_created", job: { id: jobId } },
|
||||
{ type: "fact_card_ready", job_id: jobId, fact_card: factCard },
|
||||
{ type: "draft_ready", job_id: jobId, article },
|
||||
{ type: "qa_ready", job_id: jobId, qa_report: qaReport },
|
||||
{
|
||||
type: "final_ready",
|
||||
job_id: jobId,
|
||||
optimized_article: article,
|
||||
qa_report: qaReport,
|
||||
export_paths: {},
|
||||
},
|
||||
];
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/x-ndjson; charset=utf-8",
|
||||
body: `${events.map((event) => JSON.stringify(event)).join("\n")}\n`,
|
||||
});
|
||||
});
|
||||
|
||||
await page.goto("/");
|
||||
|
||||
await page.getByLabel("访问密钥").fill("local-dev-key");
|
||||
await page
|
||||
.getByLabel("文章内容")
|
||||
@@ -15,9 +66,7 @@ test("中文界面可以生成优化文章和导出链接", async ({ page }) =>
|
||||
await page.getByLabel("用户要求").fill("保持事实准确,语气自然。");
|
||||
|
||||
await page.getByRole("button", { name: "开始优化" }).click();
|
||||
await expect(page.getByRole("link", { name: "optimized.md" })).toBeVisible({
|
||||
timeout: 120_000,
|
||||
});
|
||||
await expect(page.getByRole("link", { name: "optimized.md" })).toBeVisible();
|
||||
await expect(page.getByText("质量报告")).toBeVisible();
|
||||
await expect(page.getByRole("link", { name: "optimized.docx" })).toBeVisible();
|
||||
await expect(page.getByRole("link", { name: "qa_report.json" })).toBeVisible();
|
||||
|
||||
Reference in New Issue
Block a user