fix: 修复组件预览底部按钮溢出与咨询表单缺失

This commit is contained in:
que01 committed 2026-10-09 15:12:40 +08:00
1 parent 5b85fe769f
commit fd2e970d8b
8 files changed
+151 -8

No files matched your search

+47 -1
View File
@@ -76,7 +76,19 @@ const runtimeWorkspace = {
},
},
],
inquiryForms: [],
inquiryForms: [
{
key: "brand-inquiry",
version: "1",
purpose: "inquiry",
target: "brand",
submissionAction: "create-inquiry",
fields: [
{ key: "name", label: "称呼", type: "text", required: true },
{ key: "message", label: "需求说明", type: "textarea", required: true },
],
},
],
trustItems: [{ ...adminTrust }],
trustPresentation: {},
capabilities: [],
@@ -89,6 +101,7 @@ const templateContent = {
{ key: "offerings", page: "offerings", label: "套餐餐品" },
{ key: "service", page: "service", label: "出摊服务" },
{ key: "detail", page: "detail", label: "详情页" },
{ key: "inquiry", page: "inquiry", label: "定制/咨询" },
],
assetSlots: [],
trustContentTypes: [
@@ -362,12 +375,45 @@ test("Admin 按通用预览目标筛选字段并同步品牌草稿", async ({ pa
await page.getByText("出摊服务", { exact: true }).click();
await expect(preview.locator(".schedule-card")).toContainText("周一到周五营业");
await page.getByText("详情页", { exact: true }).click();
const detailBounds = await preview.evaluate((element) => {
const canvas = element.querySelector(".component-template-preview__canvas")!;
const bar = element.querySelector(".food-detail .bar")!;
const canvasBox = canvas.getBoundingClientRect();
const barBox = bar.getBoundingClientRect();
return {
position: getComputedStyle(bar).position,
left: barBox.left - canvasBox.left,
right: canvasBox.right - barBox.right,
bottom: canvasBox.bottom - barBox.bottom,
};
});
expect(detailBounds.position).toBe("absolute");
expect(detailBounds.left).toBeGreaterThanOrEqual(-1);
expect(detailBounds.right).toBeGreaterThanOrEqual(-1);
expect(detailBounds.bottom).toBeGreaterThanOrEqual(-1);
await preview.locator(".food-detail .bar").scrollIntoViewIfNeeded();
await expect(preview.locator(".food-detail .bar button")).toBeVisible();
await preview.screenshot({ path: "../../.codex-tasks/preview-proportion/detail.png" });
await preview.locator('[data-editor-target="acheng-campus-food.detail.detailCopy"]').click();
await expect(preview.locator(".component-template-preview__outline.is-selected")).toHaveAttribute(
"data-selected-target",
"acheng-campus-food.detail.detailCopy",
);
await expect(page.getByLabel("价格标题")).toBeVisible();
await page.getByText("定制/咨询", { exact: true }).click();
await expect(preview.locator(".inquiry-form .form-field")).toHaveCount(2);
await expect(preview.locator(".inquiry-form")).toContainText("称呼");
await expect(preview.locator(".inquiry-form")).toContainText("需求说明");
await preview.locator(".inquiry-form").scrollIntoViewIfNeeded();
await preview.screenshot({ path: "../../.codex-tasks/preview-proportion/inquiry.png" });
const formOverflow = await preview
.locator(".inquiry-form")
.evaluate((form) => form.scrollWidth - form.clientWidth);
expect(formOverflow).toBeLessThanOrEqual(1);
await page.getByRole("button", { name: "浏览页面" }).click();
await preview.locator(".inquiry-form input").first().fill("预览访客");
await expect(preview.locator(".inquiry-form input").first()).toHaveValue("预览访客");
await page.getByRole("button", { name: "点选编辑" }).click();
await page.getByText("套餐餐品", { exact: true }).click();
await expect
.poll(() =>