refactor: 收敛公开工作区运行时契约

This commit is contained in:
que01 committed 2026-09-25 12:19:20 +08:00
1 parent d5e63be074
commit 9b61047ec6
13 files changed
+93 -64

No files matched your search

+1 -1
View File
@@ -15,7 +15,7 @@ Page({
.then((workspace) =>
this.setData({
brand: workspace.brand || {},
trustContent: workspace.trustContent || [],
trustContent: workspace.trustPresentation || {},
pageRenderer: workspace.pageRenderers?.profile || "",
records: [],
templateKey: workspace.visualTemplate?.key || "",
+1 -1
View File
@@ -44,7 +44,7 @@ Page({
: {};
this.setData({
brand: activeBrand,
trustContent: workspace.trustContent || [],
trustContent: workspace.trustPresentation || {},
offerings: activeOfferings,
modules: workspace.modules || [],
moduleVariants: workspace.moduleVariants || {},
+1 -1
View File
@@ -32,7 +32,7 @@ Page({
const presentation = workspace.brand?.visualPresentation?.inquiry || {};
this.setData({
offering,
fields: form?.fields || workspace.fields || [],
fields: form?.fields || [],
formId: form?.key || form?.id || "",
title: isQuote ? "获取报价方案" : presentation.title || "需求咨询",
eyebrow: isQuote ? "QUOTE REQUEST" : presentation.eyebrow || "CONSULTATION",
@@ -44,6 +44,19 @@ test("已发布 workspace 正常返回", async () => {
assert.equal(workspace.brand.name, "测试品牌");
});
test("运行时只消费 canonical workspace 字段", async () => {
const workspace = await loadWithResponse({
publication: { status: "published" },
brand: { name: "测试品牌" },
offerings: [],
trustPresentation: { bio: "品牌介绍" },
inquiryForms: [],
});
assert.deepEqual(workspace.trustContent, { bio: "品牌介绍" });
assert.equal(workspace.fields, undefined);
assert.equal(workspace.inquiryForm, undefined);
});
test("模板声明的业务提供项展示字段会保留在小程序 view model", async () => {
const workspace = await loadWithResponse({
publication: { status: "published" },