fix: 完善模板可视化编辑闭环与通用验收
This commit is contained in:
1 parent
fa6b492bce
commit
22a82dbfba
39 files changed
+7773
-443
No files matched your search
@@ -116,6 +116,7 @@ export type TemplateTrustContentType = {
|
||||
placeholder?: string;
|
||||
required?: boolean;
|
||||
configFields?: TemplateAdminField[];
|
||||
previewTargets?: Array<{ key: string; label: string; page?: string }>;
|
||||
maxPublishedItems?: number;
|
||||
hideStandardFields?: Array<"summary" | "content">;
|
||||
};
|
||||
|
||||
@@ -169,7 +169,12 @@ test("shared brand facts have one editor and template-specific offering detail b
|
||||
const bindings = manifest.admin.sections.flatMap((section) =>
|
||||
section.fields.map((field) => field.binding),
|
||||
);
|
||||
assert.ok(!bindings.some((binding) => sharedBrandBindings.has(binding)), key);
|
||||
for (const field of manifest.admin.sections.flatMap((section) => section.fields)) {
|
||||
if (sharedBrandBindings.has(field.binding)) {
|
||||
assert.ok(field.previewTarget, key + ": shared facts need visual targets");
|
||||
assert.ok(!field.binding.includes(".config."), "Shared facts must use canonical columns");
|
||||
}
|
||||
}
|
||||
}
|
||||
const foodRoot = path.join(packageRoot, "template-acheng-campus-food");
|
||||
const food = JSON.parse(fs.readFileSync(path.join(foodRoot, "template.json"), "utf8"));
|
||||
|
||||
@@ -24,6 +24,13 @@ for (const directory of templateDirectories) {
|
||||
const targets = sections.flatMap((section) =>
|
||||
(section.previewTargets ?? []).map((target) => ({ ...target, page: section.page, section })),
|
||||
);
|
||||
for (const declaration of manifest.trustContentTypes ?? [])
|
||||
for (const target of declaration.previewTargets ?? [])
|
||||
targets.push({
|
||||
...target,
|
||||
page: declaration.pages?.[0] ?? "home",
|
||||
section: { fields: declaration.configFields ?? [] },
|
||||
});
|
||||
const keys = targets.map((target) => target.key);
|
||||
assert.equal(new Set(keys).size, keys.length, "preview target keys must be unique");
|
||||
|
||||
@@ -32,7 +39,7 @@ for (const directory of templateDirectories) {
|
||||
assert.ok(field.binding, `${section.key}.${field.key} must have an editable binding`);
|
||||
assert.ok(field.previewTarget, `${section.key}.${field.key} must map to a visual region`);
|
||||
assert.ok(
|
||||
section.previewTargets?.some((target) => target.key === field.previewTarget),
|
||||
targets.some((target) => target.key === field.previewTarget),
|
||||
`${section.key}.${field.key} references an undeclared previewTarget`,
|
||||
);
|
||||
}
|
||||
@@ -44,9 +51,11 @@ for (const directory of templateDirectories) {
|
||||
);
|
||||
for (const child of target.children)
|
||||
assert.ok(
|
||||
section.previewTargets?.some(
|
||||
(candidate) => candidate.key === child && !candidate.composite,
|
||||
),
|
||||
targets.some((candidate) => candidate.key === child && !candidate.composite) ||
|
||||
(child.startsWith("trust:") &&
|
||||
(manifest.trustContentTypes ?? []).some(
|
||||
(declaration) => `trust:${declaration.type}` === child,
|
||||
)),
|
||||
`${target.key} references missing or composite child ${child}`,
|
||||
);
|
||||
assert.ok(
|
||||
@@ -69,7 +78,10 @@ for (const directory of templateDirectories) {
|
||||
for (const target of targets)
|
||||
if (!target.composite)
|
||||
assert.ok(
|
||||
target.section.fields.some((field) => field.previewTarget === target.key),
|
||||
target.section.fields.some((field) => field.previewTarget === target.key) ||
|
||||
(manifest.trustContentTypes ?? []).some((declaration) =>
|
||||
(declaration.configFields ?? []).some((field) => field.previewTarget === target.key),
|
||||
),
|
||||
`${target.key} must map to at least one editable field`,
|
||||
);
|
||||
|
||||
|
||||
Reference in new issue
Block a user