feat: v0.11.0 导出报告全面增强 - 新增Patch标准差异第四格式(标准unified diff含hunk头/上下文3行/modified展开-旧+新/尾部无换行标记,产物可直接git apply;canBuildPatch逐行判定判等选项污染,不可导出时菜单禁用+title解释+App双保险拦截)、TXT/Markdown报告分块省略(复用buildSegments段间省略提示行,MD每段独立成表;完全一致保持全量留档语义)、报告元信息增强(版本号进尾部署名/文件夹报告忽略规则说明行超5条截断/快照基线内容对照导出附对照说明含保存时间/HTML文件卡行数修正为原始文本口径)、导出目录记忆(windowState新增lastReportDir独立于lastDir),新增33单测与2条E2E(666单测+32E2E全过覆盖率97.85/93.06/93.7/97.85),文档四件套同步

This commit is contained in:
2026-08-20 13:54:08 +08:00
parent 79ba3055cc
commit 4fd8506ffb
16 changed files with 705 additions and 84 deletions
+39
View File
@@ -270,6 +270,45 @@ test.describe('报告导出(主进程写盘链路)', () => {
await removeTmpDir(dir)
}
})
test('导出 Patch 标准差异:unified diff 落盘且含 hunk 头与增删行(0.11.0', async () => {
const dir = await makeTmpDir('difflens-e2e-patch-')
try {
const { app, window } = await launchApp()
await pasteText(window, 'left', 'ctx1\nold line\nctx2')
await pasteText(window, 'right', 'ctx1\nnew line\nctx2')
const savePath = join(dir, 'changes.patch')
await stubSaveDialog(app, savePath)
await window.getByRole('button', { name: '导出报告' }).click()
await window.getByRole('button', { name: 'Patch 标准差异' }).click()
await expect(window.getByText(/报告已保存/)).toBeVisible()
const patch = await readFile(savePath, 'utf-8')
// 标准 unified diff 结构:文件头 + hunk 头(两侧各 3 行)+ 上下文/增删行
expect(patch).toMatch(/^--- a\//)
expect(patch).toContain('+++ b/')
expect(patch).toContain('@@ -1,3 +1,3 @@')
expect(patch.split('\n')).toContain(' ctx1')
expect(patch.split('\n')).toContain('-old line')
expect(patch.split('\n')).toContain('+new line')
expect(patch.split('\n')).toContain(' ctx2')
await app.close()
} finally {
await removeTmpDir(dir)
}
})
test('开忽略大小写后 Patch 菜单项禁用(判等污染守卫,0.11.0)', async () => {
const { app, window } = await launchApp()
await pasteText(window, 'left', 'same\nBeta')
await pasteText(window, 'right', 'same\nBETA')
await window.getByLabel('忽略大小写').check()
await expect(window.getByText('两文件内容完全一致')).toBeVisible()
await window.getByRole('button', { name: '导出报告' }).click()
// 判等选项把 Beta/BETA 判为相同:unchanged 行两侧文本不同,Patch 无法表达
const item = window.getByRole('button', { name: 'Patch 标准差异' })
await expect(item).toBeDisabled()
await app.close()
})
})
test.describe('文件夹对比(主进程真实扫描链路)', () => {