diff --git a/apps/miniapp/package.json b/apps/miniapp/package.json index 8012f39..8ea21e3 100644 --- a/apps/miniapp/package.json +++ b/apps/miniapp/package.json @@ -9,6 +9,7 @@ }, "scripts": { "test:fixture": "node test/validate-fixture.cjs", + "test:visual-fixture": "node test/validate-visual-fixture.cjs", "lint": "eslint src --ext .ts", "typecheck": "tsc -p tsconfig.json --noEmit", "clean": "rimraf dist" diff --git a/apps/miniapp/test/fixtures/linjing-door-visual.json b/apps/miniapp/test/fixtures/linjing-door-visual.json new file mode 100644 index 0000000..888f2b2 --- /dev/null +++ b/apps/miniapp/test/fixtures/linjing-door-visual.json @@ -0,0 +1 @@ +{"templateKey":"linjing-door","viewport":{"width":375,"height":812},"states":{"home":{"page":"pages/index/index","anchors":["founder-card","brand-hero","trust-proof","trust-manifesto","offering-list"]},"offerings":{"page":"pages/services/index","anchors":["作品与系统","查看详情"]},"detail":{"page":"pages/offering/detail","anchors":["预约测量"]},"inquiry":{"page":"pages/inquiry/index","anchors":["PRIVATE CONSULTATION","提交"]},"success":{"page":"pages/inquiry-success/index","anchors":["已收到","查看"]},"records-empty":{"page":"pages/records/index","anchors":["咨询记录","咨询"]},"profile":{"page":"pages/bookings/index","anchors":["直派服务区域与履约说明","一门一档"]}}} diff --git a/apps/miniapp/test/validate-visual-fixture.cjs b/apps/miniapp/test/validate-visual-fixture.cjs new file mode 100644 index 0000000..63a6194 --- /dev/null +++ b/apps/miniapp/test/validate-visual-fixture.cjs @@ -0,0 +1,18 @@ +const fs = require("node:fs"); +const path = require("node:path"); +const root = path.resolve(__dirname, ".."); +const fixture = JSON.parse(fs.readFileSync(path.join(__dirname, "fixtures/linjing-door-visual.json"), "utf8")); +const failures = []; +for (const [state, definition] of Object.entries(fixture.states)) { + const wxmlPath = path.join(root, `${definition.page}.wxml`); + if (!fs.existsSync(wxmlPath)) { failures.push(`${state}: missing ${definition.page}.wxml`); continue; } + let content = fs.readFileSync(wxmlPath, "utf8"); + const componentRefs = [...content.matchAll(/<([a-z][a-z0-9-]*)\s/g)].map((match) => match[1]).filter((name) => name.includes("-")); + for (const ref of componentRefs) { + const candidate = path.join(root, "components/modules", ref, `${ref}.wxml`); + if (fs.existsSync(candidate)) content += fs.readFileSync(candidate, "utf8"); + } + for (const anchor of definition.anchors) if (!content.includes(anchor)) failures.push(`${state}: missing anchor ${anchor}`); +} +if (failures.length) { console.error(failures.join("\n")); process.exit(1); } +console.log(`Visual fixture ${fixture.templateKey} passed: ${Object.keys(fixture.states).length} states at ${fixture.viewport.width}x${fixture.viewport.height}.`); diff --git a/docs/template-runtime-progress.md b/docs/template-runtime-progress.md index 69c76b4..2742749 100644 --- a/docs/template-runtime-progress.md +++ b/docs/template-runtime-progress.md @@ -39,6 +39,7 @@ - [x] 建立 `OfferingDetail` 与 `InquiryForm` 标准模块骨架,待页面接入。 - [x] 建立 `Records`、`Profile`、`SuccessSummary` 用户链路模块骨架。 - [x] 建立林境门作模板 fixture 和标准模块 / 页面完整性检查。 +- [x] 建立固定页面状态、视口和视觉锚点清单,可供后续截图回归执行。 - [ ] Phase 3:模板中心、安装快照、升级和回滚。 - [ ] Phase 4:Capability Plugin。 - [ ] Phase 5:林境门作与第二行业双模板验证。