接入人味文案案例自动保存

This commit is contained in:
czj
2026-07-08 13:33:45 +08:00
parent 79913ef7f7
commit e867f4f07e
6 changed files with 198 additions and 18 deletions
+9
View File
@@ -2,10 +2,14 @@ import { expect, test } from "@playwright/test";
test("普通文案优化标签页可以生成文案结果", async ({ page }) => {
await page.route("**/api/copy/renwei-optimize", async (route) => {
const payload = route.request().postDataJSON() as { publish_target?: string };
expect(payload.publish_target).toBe("朋友圈");
await route.fulfill({
status: 200,
contentType: "application/json",
body: JSON.stringify({
case: { id: "case_copy_1", case_type: "human_copy" },
result_version: { id: "ver_copy_1", version: 1 },
result: {
optimized_text: "我观察到大家越来越难进入心流了。",
change_notes: [
@@ -42,12 +46,17 @@ test("普通文案优化标签页可以生成文案结果", async ({ page }) =>
await page.getByLabel("访问密钥").fill("local-dev-key");
await page.getByLabel("原始文案").fill("我观察到大家越来越难进入心流");
await page.getByLabel("发布目标").fill("朋友圈");
await page.getByRole("button", { name: "优化文案" }).click();
await expect(page.getByText("优化后文案")).toBeVisible();
await expect(page.locator(".copy-result")).toContainText(
"我观察到大家越来越难进入心流了。",
);
await expect(page.getByRole("link", { name: "查看案例详情" })).toHaveAttribute(
"href",
"/cases/case_copy_1",
);
await expect(page.getByText("改动说明")).toBeVisible();
await expect(page.getByText("AI 味检查")).toBeVisible();
});