fix: 完善模板可视化编辑闭环与通用验收

This commit is contained in:
que01 committed 2026-10-10 16:20:08 +08:00
1 parent fa6b492bce
commit 22a82dbfba
39 files changed
+7773 -443

No files matched your search

+37 -2
View File
@@ -7,7 +7,10 @@ import {
presentationFieldName,
readPresentationValue,
} from "../src/features/brand/presentation-bindings.ts";
import { resolvePreviewSelection } from "../src/features/brand/preview-selection.ts";
import {
resolvePreviewSelection,
previewTrustRecordId,
} from "../src/features/brand/preview-selection.ts";
const config = {
founder: "阿成",
@@ -184,6 +187,38 @@ assert.deepEqual(resolvePreviewSelection("offering.card", "one", targets, "offer
targetKey: "offering.card",
recordId: "one",
});
assert.equal(resolvePreviewSelection("offering.card", undefined, targets, "offerings"), undefined);
assert.deepEqual(resolvePreviewSelection("offering.card", undefined, targets, "offerings"), {
targetKey: "offering.card",
});
assert.equal(resolvePreviewSelection("brand.hero", "one", targets, "home"), undefined);
assert.equal(resolvePreviewSelection("brand.hero", undefined, targets, "offerings"), undefined);
// 未挂载的同源编辑入口不能清空已有字段。
assert.deepEqual(
applyPresentationValues(
{ founder: "保留姓名", title: "保留职位" },
[
{
key: "identity",
fields: [
{ key: "founder", binding: "brand.config.founder" },
{ key: "title", binding: "brand.config.title" },
],
},
],
{ "identity:founder": "修改姓名" },
),
{ founder: "修改姓名", title: "保留职位" },
);
assert.equal(
previewTrustRecordId(
[
{ id: "plain", type: "credential", config: {} },
{ id: "structured", type: "credential", config: { stats: [] } },
],
"credential",
),
"structured",
);
assert.equal(previewTrustRecordId([], "credential"), undefined);