test(前端): 接线尺子补两处盲区——SFC 注释假接线与 tab 失败路径
(a) stripComments 增剥 <!-- -->:往页面追加两行 HTML 注释就能同时骗过
「watch activeId」与「读 requestCompanyId」两条断言,实测缺口现在仍在列。
(c) I5 失败路径三支钉子:store 必须 catch 出 error 再 rethrow(口径照
admin-session.ts:37-39)、模板不得出现 tab.error(提示条不在已批的两处
界面暴露里)、组件必须 .catch 接住 rethrow。变异取证 M1/M2/M3 各判红
6/4/2,对照轮 6/5/1(唯一红仍是计划明令的接线正向半支)。
全量前端 1726/1725/1、vue-tsc rc=0。
This commit is contained in:
@@ -32,7 +32,7 @@ test('正向:声明 companyScoped 的页,其 api 文件必须真的带 company
|
||||
for (const file of page.pageFiles) {
|
||||
// 与 api 侧同口径先剥注释(约束 6:注释里出现字面量不算接线)——否则一句
|
||||
// `// 这里读 companyTab.requestCompanyId` 就能同时骗过下面两条断言。
|
||||
// 残留面:stripComments 只剥 JS 的 `//` 与 `/* */`,Vue 模板的 `<!-- -->` 不剥。
|
||||
// 残留面已封:stripComments 现在 JS 的 `//`、`/* */` 与 Vue 模板的 `<!-- -->` 三类都剥。
|
||||
const source = stripComments(read(file))
|
||||
if (!/watch\(\(\)\s*=>\s*companyTab\.activeId/.test(source)) {
|
||||
gaps.push(`${file} 没监听公司 tab:切 tab 不重取数 = 这页的 tab 是装饰品`)
|
||||
@@ -98,6 +98,9 @@ function listTs(dir: string): string[] {
|
||||
// 放进块注释会把注释当场截断,node 的 TS 解析器随即报 ERR_INVALID_TYPESCRIPT_SYNTAX——整支用例加载都失败。)
|
||||
function stripComments(source: string): string {
|
||||
return source
|
||||
// Vue 模板的 <!-- --> 也要剥:pageFiles 取样全是 .sfc.vue,一句 `<!-- watch(() => companyTab.activeId) -->`
|
||||
// 在只剥 JS 注释时能同时骗过 page 侧两条钉子(2026-10-05 复评 (a))。
|
||||
.replace(/<!--[\s\S]*?-->/g, '')
|
||||
.replace(/\/\*[\s\S]*?\*\//g, '')
|
||||
.split(/\r?\n/)
|
||||
.filter((line) => !line.trimStart().startsWith('//'))
|
||||
@@ -171,4 +174,14 @@ test('挂载与单一尺子:tab 条挂在壳层、公司名读 companyName、
|
||||
'visibleForOperator 必须含「有可选公司」判定,全是停用公司时 tab 条整体不渲染')
|
||||
assert.match(store, /requestCompanyId\(\)[\s\S]{0,120}companyIdForRequest/,
|
||||
'requestCompanyId 必须是 companyIdForRequest 的唯一出口(页面只读这个 getter)')
|
||||
|
||||
// 失败路径也要有钉子(2026-10-05 复评 (c)):改前 `initialize` 只有 try/finally ⇒ GET /companies 抛错时
|
||||
// loaded 永远 false、tab 条静默消失、异常落 unhandled rejection(全仓 src 无 errorHandler 兜底)。
|
||||
// 只补代码不补钉子的话,Task 8-12 里谁把它改回 try/finally,1726 支用例一支都不会红——那是"修好了但没护栏"。
|
||||
assert.match(store, /catch \(error\)[\s\S]{0,420}this\.error =[\s\S]{0,120}throw error/,
|
||||
'initialize 必须 catch 出 error 状态再 rethrow(口径照 admin-session.ts:37-39),不许退回只有 try/finally')
|
||||
// error 只许住 store 与 console:一旦进模板就是§12 第 5 条没批的那一处新界面暴露。
|
||||
assert.equal(tabs.includes('tab.error'), false, '不许把 error 渲染进模板:提示条/文案都不在已批的两处暴露里')
|
||||
assert.match(tabs, /initialize\(\)\.catch\(/,
|
||||
'组件侧必须 .catch 接住 store 的 rethrow,否则又变回 unhandled rejection')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user