fix(POSTV1-09): 展示项目生成图片
Dada P0-A isolated Windows CI / validate-and-package (push) Waiting to run

This commit is contained in:
suyx
2026-08-05 19:00:07 +08:00
parent e4aec01ea6
commit 1713607572
3 changed files with 106 additions and 12 deletions
+32 -1
View File
@@ -33,6 +33,10 @@ function routeSession(page: Page) {
}));
}
function generatedImageSvg(label: string) {
return `<svg xmlns="http://www.w3.org/2000/svg" width="300" height="400"><rect width="300" height="400" fill="#d9f24f"/><text x="150" y="210" text-anchor="middle">${label}</text></svg>`;
}
async function captureEvidence(page: Page, caseId: string, name: string) {
const root = process.env.DADA_EVIDENCE_DIR_PROJECTS;
if (!root) return;
@@ -75,6 +79,12 @@ test("TDD-WP2-PROJ-005 limits failed-empty selection on the project list", async
],
}), contentType: "application/json", status: 200,
}));
await page.route(`**/api/v1/private-assets/projects/${successId}/images/*`, (route) => route.fulfill({
body: generatedImageSvg("城市工作室"),
contentType: "image/svg+xml",
headers: { "Content-Disposition": "attachment; filename=\"dada-original.png\"" },
status: 200,
}));
let batchPayload: unknown;
await page.route("**/api/v1/projects/failed-empty/trash", async (route) => {
batchPayload = route.request().postDataJSON();
@@ -86,6 +96,12 @@ test("TDD-WP2-PROJ-005 limits failed-empty selection on the project list", async
await expect(page.getByRole("heading", { name: "项目" })).toBeVisible();
await expect(page.getByText("2 / 20 active")).toBeVisible();
const projectPreview = page.getByRole("img", { name: "城市工作室预览图" });
await expect(projectPreview).toHaveAttribute(
"src",
`/api/v1/private-assets/projects/${successId}/images/00000000-0000-4000-8000-000000000213`,
);
await expect(projectPreview).toHaveCSS("object-fit", "cover");
await expect(page.getByLabel("选择失败草稿:失败草稿")).toBeVisible();
await expect(page.getByLabel("选择失败草稿:城市工作室")).toHaveCount(0);
await page.getByLabel("选择失败草稿:失败草稿").check();
@@ -99,9 +115,10 @@ test("TDD-WP2-PROJ-005 limits failed-empty selection on the project list", async
test("TDD-WP2-PROJ-001 keeps ratio fixed and blocks an eleventh image in project detail", async ({ page }) => {
await routeSession(page);
const projectId = "00000000-0000-4000-8000-000000000221";
const currentImageId = "00000000-0000-4000-8000-000000000222";
await page.route(`**/api/v1/projects/${projectId}`, (route) => route.fulfill({
body: JSON.stringify({
created_at: "2026-07-28T08:00:00.000Z", current_image_id: "00000000-0000-4000-8000-000000000222",
created_at: "2026-07-28T08:00:00.000Z", current_image_id: currentImageId,
draft_prompt: "城市工作室", generations: [], images: Array.from({ length: 10 }, (_, index) => ({
created_at: `2026-07-28T08:${String(index).padStart(2, "0")}:00.000Z`,
generation_id: `00000000-0000-4000-8000-${String(223 + index).padStart(12, "0")}`,
@@ -111,11 +128,25 @@ test("TDD-WP2-PROJ-001 keeps ratio fixed and blocks an eleventh image in project
status: "active", successful_image_count: 10, updated_at: "2026-07-28T08:10:00.000Z",
}), contentType: "application/json", status: 200,
}));
await page.route(`**/api/v1/private-assets/projects/${projectId}/images/*`, (route) => route.fulfill({
body: generatedImageSvg("生成结果"),
contentType: "image/svg+xml",
headers: { "Content-Disposition": "attachment; filename=\"dada-original.png\"" },
status: 200,
}));
await page.goto(`${webUrl}/app/projects/${projectId}`);
await expect(page.getByRole("heading", { name: "城市工作室" })).toBeVisible();
await expect(page.getByText("固定比例 3:4")).toBeVisible();
await expect(page.getByText("10 / 10 张成功图")).toBeVisible();
const currentImage = page.getByRole("img", { name: "城市工作室当前底图" });
await expect(currentImage).toHaveAttribute(
"src",
`/api/v1/private-assets/projects/${projectId}/images/${currentImageId}`,
);
await expect(currentImage).toHaveAttribute("loading", "eager");
await expect(currentImage).toHaveCSS("object-fit", "contain");
await expect(page.getByRole("img", { name: "生成结果 10" })).toBeVisible();
await expect(page.getByRole("button", { name: "继续生成" })).toBeDisabled();
await expect(page.getByText("请先删除一张非当前底图的历史图")).toBeVisible();
await expect(page.getByRole("radio")).toHaveCount(0);