| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- import { readFileSync } from 'fs';
- import { resolve } from 'path';
- // 契约:admin.family.actionMenu(修订于 FAMILY-WB-2026-11-13-V1 §S1-1)
- // 溯源·旧需求:docs/superpowers/specs/2026-11-08-family-admin-list-polish.md §需求5
- // (去掉「查看成员」「删除」下拉项,保留「更多」下拉)
- // 溯源·新需求:docs/需求分析/2026-11-13-家庭运营工作台重构需求变更.md §S1-1
- // 「行操作只保留【进入工作台】【编辑】,删除『更多』下拉;单家庭功能移入 FamilyWorkbench.vue」
- // 溯源·实现:cfc-web/src/views/Families.vue
- //
- // 修订说明:原契约要求「更多」下拉必须渲染(旧 2026-11-08 列表打磨需求),
- // 本次需求变更明示删除「更多」下拉,故本契约反向断言其已移除,并校验保留【编辑】/【进入工作台】。
- const VIEWS_DIR = resolve(__dirname, '../views')
- const FAMILIES_VUE_PATH = resolve(VIEWS_DIR, 'Families.vue')
- const source = readFileSync(FAMILIES_VUE_PATH, 'utf8')
- function extractActionColumnBlock(src) {
- const startTag = '<el-table-column label="操作"'
- const start = src.indexOf(startTag)
- if (start === -1) return ''
- const end = src.indexOf('</el-table-column>', start)
- if (end === -1) return ''
- return src.slice(start, end + '</el-table-column>'.length)
- }
- const actionColumnBlock = extractActionColumnBlock(source)
- function extractHandleActionCmd(src) {
- const startTag = 'handleActionCmd(row, cmd)'
- const start = src.indexOf(startTag)
- if (start === -1) return ''
- return src.slice(start)
- }
- const actionCmdBody = extractHandleActionCmd(source)
- describe('Families 操作列契约(FAMILY-WB-2026-11-13-V1 S1-1 精简)', () => {
- it('操作列必须存在', () => {
- expect(actionColumnBlock).not.toBe('')
- })
- it('「更多」下拉菜单已删除(S1-1:行操作仅保留进入工作台/编辑)', () => {
- expect(actionColumnBlock).not.toMatch(/<el-dropdown-menu/)
- expect(actionColumnBlock).not.toMatch(/更多/)
- })
- it('保留【编辑】入口', () => {
- expect(actionColumnBlock).toMatch(/编辑/)
- })
- it('保留【进入工作台】入口(push /family-workbench?familyId)', () => {
- expect(source).toMatch(/family-workbench/)
- expect(source).toMatch(/familyId\s*:\s*row\.id/)
- })
- it('下拉菜单不应再出现「查看成员」项(command="viewMembers")', () => {
- expect(actionColumnBlock).not.toMatch(/command=["']viewMembers["']/)
- })
- it('下拉菜单不应再出现「删除」项(command="delete")', () => {
- expect(actionColumnBlock).not.toMatch(/command=["']delete["']/)
- })
- it('handleActionCmd 不应再分发 viewMembers 指令', () => {
- expect(actionCmdBody).not.toMatch(/case\s+['"]viewMembers['"]/)
- })
- it('handleActionCmd 不应再分发 delete 指令', () => {
- expect(actionCmdBody).not.toMatch(/case\s+['"]delete['"]/)
- })
- })
|