Files
2026Technology-Competition/tests/test-cases.md
T

18 KiB
Raw Blame History

测试用例清单

来源:tests/*.test.tssuite() / test() 声明。共 26 个测试文件、197 条用例

1. adapter.test.ts — Adapter Tests6

# 用例 覆盖点
1 ESLintAdapter has correct id and languages 适配器标识与支持语言
2 StylelintAdapter has correct id and languages 适配器标识与支持语言
3 ESLintAdapter check returns AdapterResult structure 静态分析返回结构
4 ESLintAdapter surfaces octal literal as eslint:parse-error 八进制字面量解析错误上报
5 ESLintAdapter surfaces \8 escape as eslint:parse-error 非法转义解析错误上报
6 ESLintAdapter parses JSX in .js without parse error JSX 语法解析

2. ai-empty-response.test.ts — AI Empty Response Handling13

# 用例 覆盖点
7 parseJsonResponse throws empty-response error on blank input 空响应识别
8 parseJsonResponse parses valid JSON normally 正常 JSON 解析
9 chatWithRetry retries once on EmptyContentError 空内容自动重试
10 chatWithRetry propagates error when retry also returns empty 重试仍空则抛错
11 chatWithRetry does not retry on non-retryable errors 非重试类错误不重试
12 chatWithRetry retries on 429 and succeeds 429 重试成功
13 chatWithRetry retries 429 up to 3 times then throws 429 重试上限
14 chatWithRetry fails immediately on 401 401 立即失败
15 chatWithRetry retries on network error (TypeError) 网络错误重试
16 chatWithRetry retries on timeout (AbortError) 超时重试
17 chatWithRetry backoff is exponential 指数退避
18 isRetryableError classifies error types 错误分类
19 openai-compatible reports max_tokens truncation clearly token 截断提示

3. ai-fix-engine.test.ts — AI FixEngine Tests4

# 用例 覆盖点
20 aiFixDiagnostic applies AI fix and converges AI 修复收敛
21 aiFixDiagnostic returns ai-match-failed when originalText not found 原文未匹配
22 aiFixDiagnostic returns ai-no-fix when AI provides empty fix AI 无修复
23 aiFixDiagnostic retries until issue resolved within maxIterations 迭代上限内收敛

4. config.test.ts — Config Tests4

# 用例 覆盖点
24 getAIConfig returns default values AI 配置默认值
25 AI individual getters return defaults 单项配置 getter
26 getLinterForLanguage returns configured linter 语言→linter 映射
27 getFixMaxIterations returns default 修复迭代默认值

5. customFixEngine.test.ts — Custom FixEngine Tests5

# 用例 覆盖点
28 aiFixReviewIssue applies AI fix and converges after verify 自定义规则 AI 修复收敛
29 aiFixReviewIssue returns ai-match-failed when originalText not found 原文未匹配
30 aiFixReviewIssue retries until verify passes within maxIterations 验证驱动重试
31 aiFixReviewIssue accepts last fix when verify never passes 验证不过时接受最后修复
32 aiFixReviewIssue retries empty fix once then fails with ai-no-fix 空修复重试一次后失败

6. dedup-prompt.test.ts — Dedup Prompt Tests3

# 用例 覆盖点
33 buildDedupOnlyPrompt 同时提供静态规则与自定义规则 去重 prompt 组装
34 自定义规则时包含静态规则 去重 prompt 规则合并
35 buildKnownRulesSection 生成的规则包含全部 已知规则段完整性

7. diagnostics.test.ts — DiagnosticMarkers Tests6

# 用例 覆盖点
36 toVscodeDiagnostics maps severity correctly 严重级别映射
37 toVscodeDiagnostics preserves range 范围保留
38 toVscodeDiagnostics prefixes message with plugin and linter 消息前缀
39 toVscodeDiagnostics handles ruleId without linter prefix 无前缀 ruleId
40 toVscodeDiagnostics sets source and code for quick fix hover hover 修复来源/代码
41 toVscodeDiagnostics returns empty array for empty input 空输入

8. fixEngine.test.ts — FixEngine Tests5

# 用例 覆盖点
42 ESLint adapter attaches fix object for autofixable issues 可自动修复诊断挂 fix
43 fixDiagnostic multi-round convergence produces applied fixes 多轮修复收敛
44 fixDiagnostic returns not-autofixable for non-fixable rule 不可修复规则
45 fixDiagnostic no-change returns no-change 无变化场景
46 fixDiagnostic fixes only the targeted issue, not adjacent same-rule instance 定点修复不误伤相邻同类

9. fixSession.test.ts — FixSession Tests6

# 用例 覆盖点
47 add/get/has roundtrip 会话读写
48 get returns undefined for missing key 缺失键
49 getEntries filters per uri 按 uri 过滤
50 clear removes entries for uri only 按 uri 清理
51 recordFixes merges multi-round fixes under same key 多轮修复合并
52 undo restores original text via workspace edit 撤销恢复原文

10. import-dedup.test.ts — Import Dedup Tests24

# 用例 覆盖点
53 重复规则:全局检查并标注 全局重复检查
54 全局 exact:全部标注 exact 去重
55 全局 overlap:全部检查并标注 overlap 去重
56 跨规则 exact 标注(overlap 归 none 跨规则 exact 归属
57 用户指定 exact 后取消标注 用户决策 exact
58 用户标注 overlap 将标注加 # 前缀 overlap 标注头
59 用户标注 none 加 # 前缀 none 标注头
60 已标注 duplicateLevel/duplicateOf/duplicateReason 剔出标注 已标注剔除
61 标注规则 duplicateReason 标注头回填原由 原因回填
62 编辑 description 确认 YAML 使用该值 description 编辑
63 编辑 severity 确认 YAML 使用该 severity severity 编辑
64 编辑 languages 确认 YAML 有 languages languages 编辑
65 编辑切换为标注、标注转为编辑值 编辑/标注互转
66 无编辑时保留原始 yamlContent 原始内容保留
67 severity 缺失默认为 warning severity 默认
68 severity 非法值默认为 warning severity 兜底
69 id 缺失生成 rule-N id 自动命名
70 多个 id 缺失依次 rule-1, rule-2... 递增命名
71 description 缺失时使用 message(中文存在) 双语回退
72 message 缺失时使用 description(中文存在) 双语回退
73 description 与 message 同时缺失时兜底 全缺失兜底
74 重复规则的重复校验回归 去重回归
75 id 带引号、字段带引号保留 id 引号 id
76 scalar 字段带引号、保留引号 引号 scalar

11. merger.test.ts — Merger Tests12

# 用例 覆盖点
77 mergeResults counts correctly 计数正确
78 mergeResults marks degraded when AI fails AI 失败降级
79 mergeResults sorts diagnostics by severity then line 排序
80 mergeResults marks fixable only diagnostics with fix object 可修复标记
81 mergeResults converts aiFindings line to 0-based 行号 0 基化
82 mergeResults pairs translations by originalRuleId not index 按规则 id 配对翻译
83 mergeResults handles duplicate ruleId translations in order 重复 id 有序
84 mergeResults matches translations by normalized ruleId when prefix missing 缺前缀归一化匹配
85 mergeResults matches translations by normalized ruleId with slash variant 斜杠变体匹配
86 mergeResults prefers exact ruleId match over normalized 精确匹配优先
87 mergeResults computes aiFixableLinterIndices excluding native fix and sqlfluff AI 可修复索引
88 mergeResults aiFixableLinterIndices empty when AI unavailable AI 不可用置空

12. messages.test.ts — I18n Tests9

# 用例 覆盖点
89 all message keys have values for all three languages 三语 key 完整
90 default language is zh-CN 默认语言
91 setLanguage changes current language 语言切换
92 t() falls back to key when key does not exist 缺失 key 回退
93 t() returns zh-CN string in zh-CN language 中文翻译
94 t() returns English string in en language 英文翻译
95 t() returns Japanese string in ja language 日文翻译
96 t() with template variables 模板变量
97 t() with multiple template variables 多模板变量

13. pipeline.test.ts — Pipeline Tests1

# 用例 覆盖点
98 Full pipeline: linter check + merge 全链路(linter + 合并)

14. rule-filter.test.ts — Rule Filter Tests15

# 用例 覆盖点
99 规则匹配当前语言 语言匹配
100 规则未匹配被过滤 不匹配过滤
101 规则为空:全部保留 空规则集
102 规则缺失:全部保留 缺失过滤
103 规则按语言匹配后去重 去重
104 规则未匹配语言则去除 语言不匹配去除
105 规则为空时去重 空集去重
106 规则 + 语言映射匹配时过滤结果优先 优先级
107 typescriptreact 同源映射到 typescript TSX 映射
108 plsql 同源映射到 sql PL/SQL 映射
109 JSP 映射 java 规则 JSP→Java
110 JSP 不映射 css 规则 JSP→CSS 排除
111 普通 HTML 触发 JSP 过滤 java 规则 HTML→JSP
112 全部过滤触发 skippedRequestA=true 全过滤标记
113 部分过滤触发 skippedRequestA=false 部分过滤标记

15. sqlfluff-prs.test.ts — SqlFluff PRS Tests4

# 用例 覆盖点
114 buildPRSMessage extracts fragment from description PRS 片段提取
115 buildPRSMessage flattens newlines in fragment 换行压平
116 buildPRSMessage truncates long fragments 长片段截断
117 buildPRSMessage falls back to description when pattern missing 无匹配回退

16. sqlfluff-range.test.ts — SqlFluff Range Tests6

# 用例 覆盖点
118 full positions convert to zero-based range 完整位置 0 基化
119 missing end positions fall back to start (comment JJ01 case) 缺终点回退(JJ01
120 legacy line_no/line_pos keys are honored 旧版 key 兼容
121 null positions fall back to defaults null 兜底
122 zero positions are clamped to valid values 零值钳制
123 missing all positions produce a safe zero range 全缺失安全范围

17. jsp-extractor.test.ts — JspExtractor Tests9

# 用例 覆盖点
124 extracts script block as javascript script 块提取
125 extracts style block as css style 块提取
126 extracts statement scriptlet with line offset 语句型 scriptlet
127 extracts declaration scriptlet 声明型 scriptlet
128 extracts expression scriptlet 表达式型 scriptlet
129 skips directives and comments 指令/注释跳过
130 reports sourceStart/sourceEnd positions 源区间定位
131 returns empty array for plain html 纯 HTML 无段落
132 collects script, style and scriptlet sections 多段落收集

18. report.test.ts — Report Tests7

# 用例 覆盖点
133 renders header metadata 报告头元数据
134 renders empty report with no-problems banner 空报告无问题提示
135 renders linter diagnostics with severity emoji and suggestion 严重级 emoji 与建议
136 renders custom rule diagnostics 自定义规则段
137 renders ai findings with category and suggestion AI 发现段
138 renders degraded banner and errors section 降级横幅与错误区
139 omits tools line when no adapters 无工具时不显示

19. method-extractor.test.ts — MethodExtractor Tests9

# 用例 覆盖点
140 fallback regex finds js function declarations and arrow functions JS 方法兜底正则
141 fallback regex finds java methods Java 方法兜底正则
142 fallback regex returns empty for unsupported language 不支持语言返回空
143 extractMethodScope returns code, signature and callers 方法作用域+调用者
144 extractMethodScope identifies callees 被调用者识别
145 expandToMethodBody ignores braces inside strings and comments 括号配对(跳过字符串/注释)
146 extractSignature strips leading comments 签名去注释
147 inferRole maps getter, process and generic names 角色推断
148 extractMethodScope returns null when range matches no method 无命中返回 null

20. fix-prompt.test.ts — FixPrompt Tests10

# 用例 覆盖点
149 buildFixSystemPrompt defaults to Chinese 中文系统提示词
150 buildFixSystemPrompt returns English variant 英文系统提示词
151 buildFixSystemPrompt returns Japanese variant 日文系统提示词
152 buildFixUserPrompt includes issue, message and context 用户提示词组装
153 buildFixUserPrompt includes suggestion when present 建议追加
154 buildFixUserPrompt omits suggestion when blank 空建议省略
155 buildFixContext windows around line with padding 上下文窗口+对齐
156 buildFixContext clamps at document boundaries 边界钳制
157 buildVerifySystemPrompt has language variants 校验系统提示词
158 buildVerifyUserPrompt includes issue and code 校验用户提示词

21. registry.test.ts — Provider Registry Tests7

# 用例 覆盖点
159 returns empty when no extension uri 无 URI 返回空
160 loads builtin providers from extension providers.json 内置 Provider 加载
161 caches providers across calls 注册表缓存
162 invalidateProviderCache forces reload 缓存失效
163 returns empty for missing or invalid providers.json 缺失/非法文件
164 getProviderById finds or misses 按 ID 查询
165 getAllProviderMeta returns name and models Provider 元数据

22. provider-chat.test.ts — Provider Chat Tests11

# 用例 覆盖点
166 openai chat returns content with bearer auth OpenAI 兼容协议成功
167 openai 401 throws invalid key error 401 无效密钥
168 openai truncation raises EmptyContentError token 截断空响应
169 openai empty content raises EmptyContentError 空内容错误
170 openai other status throws 其他状态报错
171 gemini chat returns text Gemini 协议成功
172 gemini empty content raises EmptyContentError Gemini 空响应
173 gemini non-ok throws Gemini 报错
174 claude chat returns text with api key header Claude 协议成功
175 claude 401 throws Claude 401
176 claude empty content raises EmptyContentError Claude 空响应

23. import-service.test.ts — ImportService Tests7

# 用例 覆盖点
177 parseImportableYaml handles arrays and quoted ids YAML 数组/引号
178 parseImportableYaml fills message from description and vice versa 字段互填
179 buildFinalYaml uses edited rules when present 编辑规则分支
180 buildFinalYaml comments exact duplicates and strips duplicate metadata 精确重复注释
181 buildFinalYaml keeps all when no overrides 无覆盖全保留
182 applyConversion writes final yaml to nested target path 写入目标文件
183 convert throws for unsupported extension 不支持格式报错

24. yaml-parser.test.ts — YamlParser Tests3

# 用例 覆盖点
184 returns empty when rules dir missing 目录缺失
185 loads rules from yaml files with severity normalization 规则加载与严重级归一
186 skips incomplete rules and non-yaml files 不完整规则/非 yaml 跳过

25. excel-converter.test.ts — ExcelConverter Tests7

# 用例 覆盖点
187 buildMarkdownTable renders sheet title, header, separator and data rows Markdown 表格渲染格式
188 buildMarkdownTable fills missing fields with empty string 缺失单元格填充
189 buildMarkdownTable renders columns from union of row keys 列键并集(无表头文件列保留)
190 renderWorkbookToMarkdown includes all non-empty sheets of galaxy fixture 真实多 Sheet 文件渲染
191 renderWorkbookToMarkdown keeps galaxy rule content faithful for AI conversion 规则内容忠实传递给 AI
192 renderWorkbookToMarkdown skips empty sheets 空表跳过
193 renderWorkbookToMarkdown returns null when no sheet has data 全空工作簿返回 null

26. webview-escape.test.ts — Webview Escape Tests4

# 用例 覆盖点
194 escapes greater-than as > 大于号转义
195 escapes less-than, ampersand and double quote 小于号/与号/双引号转义
196 escapes combined diagnostic message content 组合消息内容转义
197 does not double-escape existing entities 既有实体的转义行为

统计

文件 用例数
adapter.test.ts 6
ai-empty-response.test.ts 13
ai-fix-engine.test.ts 4
config.test.ts 4
customFixEngine.test.ts 5
dedup-prompt.test.ts 3
diagnostics.test.ts 6
excel-converter.test.ts 7
fixEngine.test.ts 5
fixSession.test.ts 6
import-dedup.test.ts 24
merger.test.ts 12
messages.test.ts 9
pipeline.test.ts 1
rule-filter.test.ts 15
sqlfluff-prs.test.ts 4
sqlfluff-range.test.ts 6
jsp-extractor.test.ts 9
report.test.ts 7
method-extractor.test.ts 9
fix-prompt.test.ts 10
registry.test.ts 7
provider-chat.test.ts 11
import-service.test.ts 7
yaml-parser.test.ts 3
webview-escape.test.ts 4
合计 197