test: 增加门窗行业示例内容夹具
This commit is contained in:
1 parent
286aad2955
commit
cd9352a849
2 files changed
+115
-12
No files matched your search
+44
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"offerings": [
|
||||
{
|
||||
"kind": "product",
|
||||
"name": "序章·入户门",
|
||||
"summary": "为别墅入口定制的整樘门系统",
|
||||
"description": "从尺度、材质到五金与安装,建立入户第一印象。",
|
||||
"categoryKey": "entrance-door"
|
||||
},
|
||||
{
|
||||
"kind": "product",
|
||||
"name": "庭院·边界门",
|
||||
"summary": "连接建筑与庭院的定制门",
|
||||
"description": "结合院落尺度、动线与立面关系完成设计。",
|
||||
"categoryKey": "garden-door"
|
||||
},
|
||||
{
|
||||
"kind": "product",
|
||||
"name": "室内·静谧门",
|
||||
"summary": "统一室内空间秩序的户内门",
|
||||
"description": "关注比例、收口、隔音与触感的整体定制。",
|
||||
"categoryKey": "interior-door"
|
||||
},
|
||||
{
|
||||
"kind": "service",
|
||||
"name": "一对一门系统设计咨询",
|
||||
"summary": "从现场到方案的完整设计沟通",
|
||||
"description": "提交建筑与空间信息后,由主理人进行初步判断与沟通。",
|
||||
"categoryKey": "custom"
|
||||
}
|
||||
],
|
||||
"trustContent": [
|
||||
{ "type": "profile", "title": "主理人的门作观" },
|
||||
{ "type": "portfolio", "title": "别墅门系统案例" },
|
||||
{ "type": "process", "title": "从测量到交付" },
|
||||
{ "type": "credential", "title": "材料与工艺标准" }
|
||||
],
|
||||
"inquiryFields": [
|
||||
{ "key": "projectType", "label": "项目类型", "type": "select" },
|
||||
{ "key": "projectStage", "label": "项目阶段", "type": "select" },
|
||||
{ "key": "siteDescription", "label": "项目概况", "type": "textarea" },
|
||||
{ "key": "phone", "label": "联系方式", "type": "phone" }
|
||||
]
|
||||
}
|
||||
@@ -2,16 +2,75 @@ const fs = require("node:fs");
|
||||
const path = require("node:path");
|
||||
const root = path.resolve(__dirname, "..");
|
||||
const fixtureFiles = ["linjing-door.json", "minimal-neutral.json", "doors-industry.json"];
|
||||
const fixtures = fixtureFiles.map((file) => JSON.parse(fs.readFileSync(path.join(__dirname, "fixtures", file), "utf8")));
|
||||
for (const fixture of fixtures) {
|
||||
const modules = fixture.requiredModules.map((key) => path.join(root, "components/modules", key));
|
||||
const missing = modules.filter((directory) => ![".js", ".json", ".wxml", ".wxss"].every((extension) => fs.existsSync(path.join(directory, `${path.basename(directory)}${extension}`))));
|
||||
if (missing.length) { console.error(`${fixture.templateKey}: missing module files: ${missing.join(", ")}`); process.exit(1); }
|
||||
const pageMap = { home: "pages/index/index", offerings: "pages/services/index", detail: "pages/offering/detail", inquiry: "pages/inquiry/index", success: "pages/inquiry-success/index", records: "pages/records/index", profile: "pages/bookings/index" };
|
||||
const missingPages = fixture.pages.filter((key) => !fs.existsSync(path.join(root, `${pageMap[key]}.json`)));
|
||||
if (missingPages.length) { console.error(`${fixture.templateKey}: missing page manifests: ${missingPages.join(", ")}`); process.exit(1); }
|
||||
if (!fixture.layout?.home?.length) { console.error(`${fixture.templateKey}: missing home layout`); process.exit(1); }
|
||||
if (fixture.requiredCapabilities && fixture.requiredCapabilities.includes("inquiry") && !fixture.requiredModules.includes("inquiry-form")) { console.error(`${fixture.templateKey}: inquiry capability requires inquiry-form module`); process.exit(1); }
|
||||
if (fixture.visualAnchors?.home && JSON.stringify(fixture.layout.home) !== JSON.stringify(fixture.visualAnchors.home)) { console.error(`${fixture.templateKey}: home layout does not match visual anchors`); process.exit(1); }
|
||||
console.log(`Fixture ${fixture.templateKey}@${fixture.version} passed: ${fixture.requiredModules.length} modules.`);
|
||||
const fixtures = fixtureFiles.map((file) =>
|
||||
JSON.parse(fs.readFileSync(path.join(__dirname, "fixtures", file), "utf8")),
|
||||
);
|
||||
const doorsContent = JSON.parse(
|
||||
fs.readFileSync(path.join(__dirname, "fixtures", "doors-content.json"), "utf8"),
|
||||
);
|
||||
if (
|
||||
doorsContent.offerings.length < 3 ||
|
||||
doorsContent.trustContent.length < 3 ||
|
||||
doorsContent.inquiryFields.length < 3
|
||||
) {
|
||||
console.error("doors: content fixture must include offerings, trust content, and inquiry fields");
|
||||
process.exit(1);
|
||||
}
|
||||
if (!doorsContent.offerings.every((item) => item.kind === "product" || item.kind === "service")) {
|
||||
console.error("doors: offerings must use shared product or service kinds");
|
||||
process.exit(1);
|
||||
}
|
||||
for (const fixture of fixtures) {
|
||||
const modules = fixture.requiredModules.map((key) => path.join(root, "components/modules", key));
|
||||
const missing = modules.filter(
|
||||
(directory) =>
|
||||
![".js", ".json", ".wxml", ".wxss"].every((extension) =>
|
||||
fs.existsSync(path.join(directory, `${path.basename(directory)}${extension}`)),
|
||||
),
|
||||
);
|
||||
if (missing.length) {
|
||||
console.error(`${fixture.templateKey}: missing module files: ${missing.join(", ")}`);
|
||||
process.exit(1);
|
||||
}
|
||||
const pageMap = {
|
||||
home: "pages/index/index",
|
||||
offerings: "pages/services/index",
|
||||
detail: "pages/offering/detail",
|
||||
inquiry: "pages/inquiry/index",
|
||||
success: "pages/inquiry-success/index",
|
||||
records: "pages/records/index",
|
||||
profile: "pages/bookings/index",
|
||||
};
|
||||
const missingPages = fixture.pages.filter(
|
||||
(key) => !fs.existsSync(path.join(root, `${pageMap[key]}.json`)),
|
||||
);
|
||||
if (missingPages.length) {
|
||||
console.error(`${fixture.templateKey}: missing page manifests: ${missingPages.join(", ")}`);
|
||||
process.exit(1);
|
||||
}
|
||||
if (!fixture.layout?.home?.length) {
|
||||
console.error(`${fixture.templateKey}: missing home layout`);
|
||||
process.exit(1);
|
||||
}
|
||||
if (
|
||||
fixture.requiredCapabilities &&
|
||||
fixture.requiredCapabilities.includes("inquiry") &&
|
||||
!fixture.requiredModules.includes("inquiry-form")
|
||||
) {
|
||||
console.error(`${fixture.templateKey}: inquiry capability requires inquiry-form module`);
|
||||
process.exit(1);
|
||||
}
|
||||
if (
|
||||
fixture.visualAnchors?.home &&
|
||||
JSON.stringify(fixture.layout.home) !== JSON.stringify(fixture.visualAnchors.home)
|
||||
) {
|
||||
console.error(`${fixture.templateKey}: home layout does not match visual anchors`);
|
||||
process.exit(1);
|
||||
}
|
||||
console.log(
|
||||
`Fixture ${fixture.templateKey}@${fixture.version} passed: ${fixture.requiredModules.length} modules.`,
|
||||
);
|
||||
}
|
||||
console.log(
|
||||
`Content fixture doors passed: ${doorsContent.offerings.length} offerings, ${doorsContent.trustContent.length} trust entries, ${doorsContent.inquiryFields.length} inquiry fields.`,
|
||||
);
|
||||
Reference in new issue
Block a user