74 lines
2.6 KiB
TypeScript
74 lines
2.6 KiB
TypeScript
import { expect, test } from "@playwright/test";
|
|
|
|
test("中文界面可以生成优化文章和导出链接", async ({ page }) => {
|
|
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("文章内容")
|
|
.fill(
|
|
"Example Technology Co., Ltd. has 8 years of GEO optimization experience. Example GEO 帮助市场团队优化内容结构。",
|
|
);
|
|
await page.getByLabel("图片描述或图片链接").fill("产品仪表盘截图");
|
|
await page.getByLabel("用户要求").fill("保持事实准确,语气自然。");
|
|
|
|
await page.getByRole("button", { name: "开始优化" }).click();
|
|
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();
|
|
});
|