|
@@ -1,29 +1,22 @@
|
|
|
/**
|
|
/**
|
|
|
- * admin.family.reportEntry 契约级单测(TDD-RED 阶段,预期红)
|
|
|
|
|
|
|
+ * admin.family.reportEntry 契约级单测(修订于 FAMILY-WB-2026-11-13-V1 §S1-1)
|
|
|
*
|
|
*
|
|
|
* 能力键: admin.family.reportEntry
|
|
* 能力键: admin.family.reportEntry
|
|
|
- * 溯源·需求: docs/superpowers/specs/2026-11-08-family-admin-list-polish.md §需求2
|
|
|
|
|
|
|
+ * 溯源·旧需求: docs/superpowers/specs/2026-11-08-family-admin-list-polish.md §需求2
|
|
|
* (列表上传报告数为 0 时也可点击,进入后可代传报告、查看报告)
|
|
* (列表上传报告数为 0 时也可点击,进入后可代传报告、查看报告)
|
|
|
- * 溯源·设计: cfc-web/src/views/Families.vue
|
|
|
|
|
- * - L62-67 去掉 reportCount>0 条件(reportCount=0 也渲染可点击 el-link)
|
|
|
|
|
- * - L206-226 reports 明细弹窗补「代传报告」入口(跳转 ProxyReportUpload 或内嵌上传)
|
|
|
|
|
|
|
+ * 溯源·新需求: docs/需求分析/2026-11-13-家庭运营工作台重构需求变更.md §S1-1
|
|
|
|
|
+ * 「报告/方案/任务/优惠券数改为纯文本(不可点击)」+「删除 openPlanGen / openDetailDialog / 详情弹窗模板」
|
|
|
|
|
+ * 溯源·实现: cfc-web/src/views/Families.vue(统计数纯文本);cfc-web/src/views/FamilyWorkbench.vue(报告 tab 代传报告能力落点)
|
|
|
*
|
|
*
|
|
|
- * 【为何以「源码契约」而非「shallowMount 组件挂载」方式书写】
|
|
|
|
|
- * 参考风格(ActivityAudit.spec.js)使用 shallowMount 挂载组件。但当前 cfclub 主链的
|
|
|
|
|
- * Families.vue 模板存在一处先在的硬编译错误:查看成员弹窗中 `<el-empty v-else>`
|
|
|
|
|
- * 嵌套在 `<el-table>`(其 v-if 挂在 table 自身)内部,vue-template-compiler 将其
|
|
|
|
|
- * 列为 errors[],导致 vue-jest 无法加载整个组件(suite 直接编译失败)。本任务明确禁止
|
|
|
|
|
- * 修改 src/main 实现,故无法绕过该先在障碍。GREEN 阶段落地本能力时会同步修正该嵌套;
|
|
|
|
|
- * 届时可将本文件升级为 shallowMount 挂载式测试。
|
|
|
|
|
- *
|
|
|
|
|
- * 因此本文件采用「源码契约」断言:读取真实的 Families.vue 源码,断言设计契约所需
|
|
|
|
|
- * 结构/行为缺失(RED)。GREEN 阶段实现后断言转绿。断言聚焦行为契约,不锁定实现细节
|
|
|
|
|
- * (跳转路由 vs 内嵌上传二者任一即可)。
|
|
|
|
|
|
|
+ * 修订说明:原契约按 2026-11-08 旧需求断言「可点击 el-link + reports 明细弹窗代传报告入口」。
|
|
|
|
|
+ * 本次需求变更(2026-11-13)将上述行为整体迁移到单家庭工作台 FamilyWorkbench.vue,
|
|
|
|
|
+ * Families.vue 列表仅保留纯文本统计数。故本契约改为:
|
|
|
|
|
+ * AC1 校验 Families.vue 报告数为纯文本(无 el-link / 无 reportCount>0 门控 / 无 openDetailDialog);
|
|
|
|
|
+ * AC2 校验代传报告能力已从 Families.vue 移除(迁移到 FamilyWorkbench,由 FamilyWorkbench.contract.spec.js 覆盖)。
|
|
|
*/
|
|
*/
|
|
|
import fs from 'fs'
|
|
import fs from 'fs'
|
|
|
import path from 'path'
|
|
import path from 'path'
|
|
|
|
|
|
|
|
-// 读取真实组件源码(相对本测试文件:src/__tests__/views -> src/views)
|
|
|
|
|
const srcPath = path.resolve(__dirname, '../../views/Families.vue')
|
|
const srcPath = path.resolve(__dirname, '../../views/Families.vue')
|
|
|
const source = fs.readFileSync(srcPath, 'utf8')
|
|
const source = fs.readFileSync(srcPath, 'utf8')
|
|
|
|
|
|
|
@@ -35,66 +28,35 @@ function reportCountColumn() {
|
|
|
return source.slice(start, end)
|
|
return source.slice(start, end)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-/** 取报告明细弹窗的 reports 分区块(`detailType === 'reports'` 至下一个 detailType 分支开头) */
|
|
|
|
|
-function reportsDialogBlock() {
|
|
|
|
|
- const start = source.indexOf("detailType === 'reports'")
|
|
|
|
|
- expect(start).toBeGreaterThan(-1) // 明细弹窗 reports 分支存在是既有契约
|
|
|
|
|
- const end = source.indexOf("detailType ===", start + 1)
|
|
|
|
|
- return source.slice(start, end > 0 ? end : start + 5000)
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-/** 取组件 script 段(`<script>` 至 `</script>`) */
|
|
|
|
|
-function scriptBlock() {
|
|
|
|
|
- const start = source.indexOf('<script>')
|
|
|
|
|
- const end = source.indexOf('</script>')
|
|
|
|
|
- return source.slice(start, end)
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-describe('admin.family.reportEntry 契约 (TDD-RED)', () => {
|
|
|
|
|
- describe('AC1 · 列表 reportCount=0 也渲染可点击链接', () => {
|
|
|
|
|
- /** 当前源码中 reportCount 列内容(含 v-if 门控与 v-else 灰字两个分支) */
|
|
|
|
|
|
|
+describe('admin.family.reportEntry 契约(FAMILY-WB-2026-11-13-V1 S1-1 修订)', () => {
|
|
|
|
|
+ describe('AC1 · 列表 reportCount 为纯文本展示(不可点击)', () => {
|
|
|
const col = () => reportCountColumn()
|
|
const col = () => reportCountColumn()
|
|
|
|
|
|
|
|
- it('reportCount 列不应再包含 `reportCount > 0` 门控(L62-67 契约要求去掉该条件)', () => {
|
|
|
|
|
|
|
+ it('reportCount 列不应包含 `reportCount > 0` 门控', () => {
|
|
|
expect(col()).not.toMatch(/reportCount\s*>\s*0/)
|
|
expect(col()).not.toMatch(/reportCount\s*>\s*0/)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- it('reportCount 列不应再包含 `.cell-zero` 灰字 fallback(L62-67 契约要求改为 el-link)', () => {
|
|
|
|
|
|
|
+ it('reportCount 列不应包含 `.cell-zero` 灰字 fallback', () => {
|
|
|
expect(col()).not.toContain('cell-zero')
|
|
expect(col()).not.toContain('cell-zero')
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- it('reportCount 列的 el-link 不应再被 `v-if="scope.row.reportCount > 0"` 门控,且需保留 openDetailDialog 点击行为', () => {
|
|
|
|
|
- expect(col()).toContain('<el-link')
|
|
|
|
|
- expect(col()).toContain("openDetailDialog(scope.row.id, 'reports')")
|
|
|
|
|
- // 契约核心:当前 el-link 被 reportCount>0 门控包围(<el-link v-if="scope.row.reportCount > 0"...),RED 阶段应断言其未被门控
|
|
|
|
|
- expect(col()).not.toMatch(/<el-link[^>]*v-if\s*=\s*["']scope\.row\.reportCount\s*>\s*0["']/)
|
|
|
|
|
|
|
+ it('reportCount 列改为纯文本:不再有 el-link / openDetailDialog(S1-1)', () => {
|
|
|
|
|
+ expect(col()).not.toContain('<el-link')
|
|
|
|
|
+ expect(source).not.toContain('openDetailDialog')
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- describe('AC2 · 报告明细弹窗补「代传报告」入口', () => {
|
|
|
|
|
- const dialog = () => reportsDialogBlock()
|
|
|
|
|
- const script = () => scriptBlock()
|
|
|
|
|
-
|
|
|
|
|
- it('reports 明细弹窗区块内需出现「代传报告」文案或语义标记(design anchor L206-226)', () => {
|
|
|
|
|
- const hasEntry =
|
|
|
|
|
- dialog().includes('代传报告') ||
|
|
|
|
|
- dialog().includes('proxy-report-entry') ||
|
|
|
|
|
- dialog().includes('handleProxyReportUpload') ||
|
|
|
|
|
- dialog().includes('goProxyReportUpload')
|
|
|
|
|
- expect(hasEntry).toBe(true)
|
|
|
|
|
|
|
+ describe('AC2 · 代传报告入口已迁移至单家庭工作台(S1-1)', () => {
|
|
|
|
|
+ it('Families.vue 不再保留 goProxyReportUpload / handleProxyReportUpload / openProxyReportUpload 处理方法', () => {
|
|
|
|
|
+ expect(source).not.toMatch(/goProxyReportUpload|handleProxyReportUpload|openProxyReportUpload/)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- it('组件 script 需提供处理代传报告流程的方法(跳转 ProxyReportUpload 路由或触发内嵌上传)', () => {
|
|
|
|
|
- const hasProxyHandler =
|
|
|
|
|
- /(goProxyReportUpload|handleProxyReportUpload|openProxyReportUpload)/.test(script()) ||
|
|
|
|
|
- (/report-proxy-upload/.test(script()))
|
|
|
|
|
- expect(hasProxyHandler).toBe(true)
|
|
|
|
|
|
|
+ it("Families.vue 不再保留 reports 明细弹窗(detailType === 'reports' 已删除)", () => {
|
|
|
|
|
+ expect(source).not.toContain("detailType === 'reports'")
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- it('代传报告流程需绑定 familyId(跳转时需携带 query.familyId 或复用当前 detailFamilyId)', () => {
|
|
|
|
|
- const s = script()
|
|
|
|
|
- expect(s).toMatch(/familyId/)
|
|
|
|
|
- expect(s).toMatch(/report-proxy-upload|ProxyReportUpload/)
|
|
|
|
|
|
|
+ it('Families.vue 不再含「代传报告」文案(能力迁移到 FamilyWorkbench 报告 tab)', () => {
|
|
|
|
|
+ expect(source).not.toContain('代传报告')
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|