Fix translation language pipeline regressions#66
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthrough为项目添加测试目标与回归测试,扩展应用语言集合,向翻译引擎与服务引入可选源语言,新增 OCR 噪声过滤逻辑,统一语言显示/提示名与本地化键名;多数改动为新增或结构性调整。 Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant TranslationService
participant Registry
participant AppSettings
participant Provider
participant TranslationEngine
Client->>TranslationService: 请求翻译(text, source?, target)
TranslationService->>Registry: resolvedProvider(for:)
alt provider 已存在
Registry-->>TranslationService: Provider
else provider 不存在
TranslationService->>AppSettings: 获取 engineConfig (MainActor)
AppSettings-->>TranslationService: 返回 config
TranslationService->>Registry: createProvider(for: config)
Registry-->>TranslationService: Provider
end
TranslationService->>Provider: translate(text, config)
Provider->>TranslationEngine: translate(text, config with sourceLanguage?)
TranslationEngine->>TranslationEngine: validateLanguageAvailability(source?, target, text)
TranslationEngine-->>Provider: 翻译结果或错误
Provider-->>TranslationService: 返回结果或错误
TranslationService-->>Client: 返回最终结果或抛出错误
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
ScreenTranslate/Services/TranslationEngine.swift (1)
300-304:⚠️ Potential issue | 🟡 Minor
unsupportedLanguagePair的 source 文案与实际 sourceLanguage 不一致。当前在 Line 302 固定使用“自动检测”,即使用户已显式选择源语言也会提示错误来源,易误导排障。建议优先显示
sourceLanguage?.localizedName。建议修改
case .unsupported(let languageName): + let sourceName = sourceLanguage?.localizedName + ?? NSLocalizedString("translation.auto.detected", comment: "") throw TranslationEngineError.unsupportedLanguagePair( - source: NSLocalizedString("translation.auto.detected", comment: ""), + source: sourceName, target: languageName )🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@ScreenTranslate/Services/TranslationEngine.swift` around lines 300 - 304, The error constructs an unsupportedLanguagePair using a hardcoded "translation.auto.detected" string, which can misrepresent the actual source selection; update the .unsupported case in TranslationEngine (where TranslationEngineError.unsupportedLanguagePair is thrown) to use the real source language display when available by preferring sourceLanguage?.localizedName (or falling back to NSLocalizedString("translation.auto.detected", comment: "")) for the source parameter so the thrown error reflects the actual source language.
🧹 Nitpick comments (3)
ScreenTranslateTests/TranslationPipelineRegressionTests.swift (2)
27-39: 移除集合字面量末尾的逗号。SwiftLint 报告
trailing_comma警告。🔧 建议的修复
let segments = [ TextSegment(text: "100", boundingBox: .zero, confidence: 0.99), TextSegment(text: "Q4 Revenue increased significantly", boundingBox: .zero, confidence: 0.99), - TextSegment(text: "25%", boundingBox: .zero, confidence: 0.99), + TextSegment(text: "25%", boundingBox: .zero, confidence: 0.99) ]🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@ScreenTranslateTests/TranslationPipelineRegressionTests.swift` around lines 27 - 39, The array literal in testFilteredForTranslationRemovesNoiseButKeepsContent has a trailing comma after the last TextSegment which triggers SwiftLint's trailing_comma warning; edit the segments array in that test (the TextSegment initializers inside testFilteredForTranslationRemovesNoiseButKeepsContent) and remove the final comma after TextSegment(text: "25%", ...) so the last element has no trailing comma; run SwiftLint or tests to confirm the warning is resolved while keeping use of TextSegment, ScreenAnalysisResult, and filteredForTranslation unchanged.
41-59: 移除集合字面量末尾的逗号。SwiftLint 报告
trailing_comma警告。🔧 建议的修复
TextSegment( text: "2024", boundingBox: CGRect(x: 0.95, y: 0.40, width: 0.03, height: 0.02), confidence: 0.99 - ), + ) ]🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@ScreenTranslateTests/TranslationPipelineRegressionTests.swift` around lines 41 - 59, The array literal for `segments` in testFilteredForTranslationFallsBackWhenEverySegmentLooksLikeNoise()` has a trailing comma that triggers SwiftLint's `trailing_comma` warning; remove the trailing comma after the last `TextSegment(...)` entry so the `segments` array literal does not end with a comma (update the `segments` declaration and any similar array/tuple literals in this test if present).ScreenTranslate/Services/TranslationEngine.swift (1)
65-72:fromTranslationCode(_:)建议做大小写与分隔符归一化,提升解析鲁棒性。目前仅做精确
rawValue匹配,像EN、zh_Hans这类常见输入会解析失败。建议修改
static func fromTranslationCode(_ code: String?) -> TranslationLanguage? { - guard let code, - !code.isEmpty, - code.lowercased() != TranslationLanguage.auto.rawValue else { + guard let raw = code?.trimmingCharacters(in: .whitespacesAndNewlines), + !raw.isEmpty else { return nil } - return TranslationLanguage(rawValue: code) + let normalized = raw.replacingOccurrences(of: "_", with: "-") + if normalized.caseInsensitiveCompare(TranslationLanguage.auto.rawValue) == .orderedSame { + return nil + } + return TranslationLanguage.allCases.first { + $0.rawValue.caseInsensitiveCompare(normalized) == .orderedSame + } }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@ScreenTranslate/Services/TranslationEngine.swift` around lines 65 - 72, The fromTranslationCode(_:) currently only does exact rawValue matching so inputs like "EN" or "zh-Hans" fail; normalize the incoming code by trimming whitespace, lowercasing, and replacing "-" with "_" (e.g., let normalized = code.trimmingCharacters(...).lowercased().replacingOccurrences(of: "-", with: "_")), then guard against empty and compare against TranslationLanguage.auto.rawValue; attempt TranslationLanguage(rawValue: normalized) first, and if that returns nil, try a fallback using the primary subtag (split normalized on "_" and try TranslationLanguage(rawValue: parts[0])) so common variants like "EN", "en-US", "zh-Hans" map correctly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@ScreenTranslate/Services/TranslationEngine.swift`:
- Around line 285-286: 在调用 Apple 翻译 API 时不要在 sourceLanguage 为自动检测时回退到英文:把所有硬编码为
Locale.Language(identifier: "en") 的地方改为直接使用
sourceLanguage?.localeLanguage(它会在自动检测时为 nil),并确保将该可空值传入 LanguageAvailability
检查和 TranslationSession 初始化(例如在构造 TranslationSession/TranslationOptions 时传入
source 而非默认
"en")。定位符:sourceLanguage、localeLanguage、LanguageAvailability、TranslationSession(及构造
TranslationOptions/Session 的调用)——用可选 localeLanguage/nil 代替强制回退为英语。
---
Outside diff comments:
In `@ScreenTranslate/Services/TranslationEngine.swift`:
- Around line 300-304: The error constructs an unsupportedLanguagePair using a
hardcoded "translation.auto.detected" string, which can misrepresent the actual
source selection; update the .unsupported case in TranslationEngine (where
TranslationEngineError.unsupportedLanguagePair is thrown) to use the real source
language display when available by preferring sourceLanguage?.localizedName (or
falling back to NSLocalizedString("translation.auto.detected", comment: "")) for
the source parameter so the thrown error reflects the actual source language.
---
Nitpick comments:
In `@ScreenTranslate/Services/TranslationEngine.swift`:
- Around line 65-72: The fromTranslationCode(_:) currently only does exact
rawValue matching so inputs like "EN" or "zh-Hans" fail; normalize the incoming
code by trimming whitespace, lowercasing, and replacing "-" with "_" (e.g., let
normalized = code.trimmingCharacters(...).lowercased().replacingOccurrences(of:
"-", with: "_")), then guard against empty and compare against
TranslationLanguage.auto.rawValue; attempt TranslationLanguage(rawValue:
normalized) first, and if that returns nil, try a fallback using the primary
subtag (split normalized on "_" and try TranslationLanguage(rawValue: parts[0]))
so common variants like "EN", "en-US", "zh-Hans" map correctly.
In `@ScreenTranslateTests/TranslationPipelineRegressionTests.swift`:
- Around line 27-39: The array literal in
testFilteredForTranslationRemovesNoiseButKeepsContent has a trailing comma after
the last TextSegment which triggers SwiftLint's trailing_comma warning; edit the
segments array in that test (the TextSegment initializers inside
testFilteredForTranslationRemovesNoiseButKeepsContent) and remove the final
comma after TextSegment(text: "25%", ...) so the last element has no trailing
comma; run SwiftLint or tests to confirm the warning is resolved while keeping
use of TextSegment, ScreenAnalysisResult, and filteredForTranslation unchanged.
- Around line 41-59: The array literal for `segments` in
testFilteredForTranslationFallsBackWhenEverySegmentLooksLikeNoise()` has a
trailing comma that triggers SwiftLint's `trailing_comma` warning; remove the
trailing comma after the last `TextSegment(...)` entry so the `segments` array
literal does not end with a comma (update the `segments` declaration and any
similar array/tuple literals in this test if present).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e96bba07-29cd-4771-82ae-de8108f6a4c9
📒 Files selected for processing (21)
ScreenTranslate.xcodeproj/project.pbxprojScreenTranslate/Features/Onboarding/OnboardingViewModel.swiftScreenTranslate/Features/TextTranslation/TextTranslationPopupWindow.swiftScreenTranslate/Features/TranslationFlow/TranslationFlowController.swiftScreenTranslate/Models/AppLanguage.swiftScreenTranslate/Models/ScreenAnalysisResult.swiftScreenTranslate/Resources/en.lproj/Localizable.stringsScreenTranslate/Resources/fr.lproj/Localizable.stringsScreenTranslate/Resources/ko.lproj/Localizable.stringsScreenTranslate/Resources/pt.lproj/Localizable.stringsScreenTranslate/Resources/ru.lproj/Localizable.stringsScreenTranslate/Resources/zh-Hans.lproj/Localizable.stringsScreenTranslate/Services/AppleTranslationProvider.swiftScreenTranslate/Services/Translation/Providers/CompatibleTranslationProvider.swiftScreenTranslate/Services/Translation/Providers/LLMTranslationProvider.swiftScreenTranslate/Services/TranslationEngine.swiftScreenTranslate/Services/TranslationService.swiftScreenTranslateTests/KeyboardShortcutTests.swiftScreenTranslateTests/ScreenTranslateErrorTests.swiftScreenTranslateTests/ShortcutRecordingTypeTests.swiftScreenTranslateTests/TranslationPipelineRegressionTests.swift
| source: sourceLanguage?.localeLanguage ?? Locale.Language(identifier: "en"), | ||
| target: language.localeLanguage |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
Apple Translation framework 文档中,source language 未指定(auto-detect)时,LanguageAvailability 与 TranslationSession 的推荐调用方式是什么?将 source 默认设为 English 是否等价于自动检测?
💡 Result:
Apple Translation framework 文档中,当 source language 未指定(auto-detect)时: LanguageAvailability 的推荐调用方式是使用 status(for:to:) 方法,提供 sample text(源文本样本)和目标语言,来检查基于文本自动检测源语言的翻译对是否可用。这允许框架基于文本检测源语言并评估支持状态。(来源:官方文档 LanguageAvailability,status(for:to:) 描述为 "Checks to see if the framework supports the language pairing based off a string of sample text." 示例在 WWDC24 和教程中显示使用文本片段检查。) TranslationSession 的推荐调用方式是在 SwiftUI 的 .translationTask(source:target:action:) 中将 source 参数设为 nil(或 TranslationSession.Configuration(source: nil, target: ...)),框架会自动尝试识别源语言,如果无法确定则提示用户选择。(来源:官方文档 translationTask,WWDC24 视频:"Using nil for the source language will attempt to identify the content’s language automatically. If the framework can’t determine the language, it’ll ask the user to pick." 多个示例代码确认 sourceLanguage: nil 或 source: nil。) 将 source 默认设为 English 不等价于自动检测。因为指定 English 要求文本是英语,如果文本是其他语言,翻译会出错或不准确;自动检测(nil)会根据文本内容识别实际语言,支持多语言输入。(来源:WWDC24 最佳实践 "Whenever you’re unsure about what language the content is in or what language to translate into, use nil",文档强调 source nil 触发自动识别。)
Citations:
- 1: https://developer.apple.com/documentation/translation/languageavailability
- 2: https://developer.apple.com/documentation/Translation/translating-text-within-your-app
- 3: https://developer.apple.com/documentation/translation/languageavailability?changes=late_3_8
- 4: https://developer.apple.com/documentation/translation/translationsession
- 5: https://developer.apple.com/documentation/translation/translating-text-within-your-app
- 6: https://developer.apple.com/videos/play/wwdc2024/10117/?time=441
- 7: https://developer.apple.com/documentation/swiftui/view/translationtask(source:target:preferredstrategy:action:)?changes=_3
- 8: https://www.createwithswift.com/using-the-translation-framework-for-language-to-language-translation/
🏁 Script executed:
#!/bin/bash
# 目的:确认 auto 源语言会传入 nil,并追踪到当前英文回退路径
rg -n -C3 'translationSourceLanguage == \.auto|from:\s*sourceLanguage|sourceLanguage:\s*config\.sourceLanguage|sourceLanguage\?\.localeLanguage \?\? Locale\.Language\(identifier: "en"\)|\(source \?\? \.english\)\.localeLanguage' --type=swiftRepository: hubo1989/ScreenTranslate
Length of output: 17672
当源语言为自动检测时,应传入 nil 而非强制回退为英文。
第 285 和 321 行在 sourceLanguage == nil 时被硬编码为英文,与 Apple Translation 框架的推荐做法不符。官方文档明确指出,应使用 nil 让框架自动识别源语言,而将源语言设为 English 并不等价于自动检测——若输入非英语文本,会导致可用性检查失败或翻译结果错误。
建议修改:
- 第 285 行:直接使用
sourceLanguage?.localeLanguage(或考虑将 nil 传给 LanguageAvailability) - 第 321 行:修改 TranslationSession 初始化,使用
source的实际值而非默认英文
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@ScreenTranslate/Services/TranslationEngine.swift` around lines 285 - 286, 在调用
Apple 翻译 API 时不要在 sourceLanguage 为自动检测时回退到英文:把所有硬编码为 Locale.Language(identifier:
"en") 的地方改为直接使用 sourceLanguage?.localeLanguage(它会在自动检测时为 nil),并确保将该可空值传入
LanguageAvailability 检查和 TranslationSession 初始化(例如在构造
TranslationSession/TranslationOptions 时传入 source 而非默认
"en")。定位符:sourceLanguage、localeLanguage、LanguageAvailability、TranslationSession(及构造
TranslationOptions/Session 的调用)——用可选 localeLanguage/nil 代替强制回退为英语。
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
ScreenTranslate/Services/TranslationEngine.swift (1)
281-317:⚠️ Potential issue | 🟡 Minor显式源语言在不支持配对错误里被忽略。
Line 281-285 已引入
sourceLanguage,但 Line 315 仍固定显示translation.auto.detected。当用户明确选择源语言时,这条错误信息会误导。🔧 建议修改
case .unsupported(let languageName): + let sourceName = sourceLanguage?.localizedName + ?? NSLocalizedString("translation.auto.detected", comment: "") throw TranslationEngineError.unsupportedLanguagePair( - source: NSLocalizedString("translation.auto.detected", comment: ""), + source: sourceName, target: languageName )🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@ScreenTranslate/Services/TranslationEngine.swift` around lines 281 - 317, The unsupported-language branch currently always passes NSLocalizedString("translation.auto.detected", ...) as the source to TranslationEngineError.unsupportedLanguagePair, which ignores an explicitly provided sourceLanguage; update validateLanguageAvailability to compute a sourceLabel (use Self.sourceLocaleLanguage(for: sourceLanguage) when available to get the explicit source name, otherwise fall back to NSLocalizedString("translation.auto.detected", ...)) and pass that sourceLabel into TranslationEngineError.unsupportedLanguagePair(source:target:) instead of the hard-coded auto-detected string.
♻️ Duplicate comments (1)
ScreenTranslate/Services/TranslationEngine.swift (1)
331-337:⚠️ Potential issue | 🔴 Critical自动检测在实际翻译阶段仍被硬编码为英文。
Line 336 仍使用
(source ?? .english).localeLanguage。当source == nil或.auto时,可用性检查走的是“自动检测”语义(Line 430-435),但真正翻译却固定英文,前后语义不一致,且与本 PR 目标冲突。Apple Translation framework 当前官方文档中,`TranslationSession` 是否支持通过 `source: nil` 实现自动检测?请给出可用初始化签名、最低平台版本,并说明 `installedSource:` 与自动检测是否等价。🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@ScreenTranslate/Services/TranslationEngine.swift` around lines 331 - 337, The TranslationSession is being constructed with a hardcoded fallback to English ((source ?? .english).localeLanguage) which breaks the intended "auto" detection path; update the TranslationSession initialization to honor source == nil or source == .auto by passing nil (or the SDK-supported parameter) for installedSource when the availability check around the "auto detection" logic (see the code handling .auto at the availability check region) indicates automatic detection is supported, and otherwise fall back to a real installed language; verify the exact TranslationSession initializer signature and minimum platform version from Apple docs and only pass installedSource when required (or use the initializer that accepts an optional source) so installedSource and automatic detection semantics remain consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@ScreenTranslateTests/TranslationPipelineRegressionTests.swift`:
- Around line 38-42: 测试中的数组字面量在末尾包含多余的尾随逗号,触发 SwiftLint 的 trailing_comma 规则;在
TranslationPipelineRegressionTests.swift 中找到创建 segments 的数组(包含 TextSegment(...)
条目)以及文件中另一处相同模式的数组,并移除数组最后一个元素后的逗号(即删除 "TextSegment(text: \"25%\", ...),"
末尾的逗号和其他类似位置的尾随逗号),保持其余格式不变以消除警告。
---
Outside diff comments:
In `@ScreenTranslate/Services/TranslationEngine.swift`:
- Around line 281-317: The unsupported-language branch currently always passes
NSLocalizedString("translation.auto.detected", ...) as the source to
TranslationEngineError.unsupportedLanguagePair, which ignores an explicitly
provided sourceLanguage; update validateLanguageAvailability to compute a
sourceLabel (use Self.sourceLocaleLanguage(for: sourceLanguage) when available
to get the explicit source name, otherwise fall back to
NSLocalizedString("translation.auto.detected", ...)) and pass that sourceLabel
into TranslationEngineError.unsupportedLanguagePair(source:target:) instead of
the hard-coded auto-detected string.
---
Duplicate comments:
In `@ScreenTranslate/Services/TranslationEngine.swift`:
- Around line 331-337: The TranslationSession is being constructed with a
hardcoded fallback to English ((source ?? .english).localeLanguage) which breaks
the intended "auto" detection path; update the TranslationSession initialization
to honor source == nil or source == .auto by passing nil (or the SDK-supported
parameter) for installedSource when the availability check around the "auto
detection" logic (see the code handling .auto at the availability check region)
indicates automatic detection is supported, and otherwise fall back to a real
installed language; verify the exact TranslationSession initializer signature
and minimum platform version from Apple docs and only pass installedSource when
required (or use the initializer that accepts an optional source) so
installedSource and automatic detection semantics remain consistent.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: cae58cde-d6e7-4fbc-b298-04aebbd16c55
📒 Files selected for processing (2)
ScreenTranslate/Services/TranslationEngine.swiftScreenTranslateTests/TranslationPipelineRegressionTests.swift
There was a problem hiding this comment.
🧹 Nitpick comments (1)
ScreenTranslateTests/TranslationPipelineRegressionTests.swift (1)
23-35: 测试名称与实际测试内容不符。测试方法名为
testNoiseHeuristicFiltersCoordinateLikeText,但实际测试的是百分比字符串("12.5%")和边缘位置的月份标签("Jan"),并未测试真正的坐标格式(如"0.5, 0.3"、"(x:0.5, y:0.3)"、"x: 0.5"等)。根据
ScreenAnalysisResult.swift中的isLikelyTranslationNoise实现,存在专门的坐标正则匹配逻辑,但当前测试未覆盖。建议:
- 将方法名改为更准确的
testNoiseHeuristicFiltersTicksAndLabels,或- 添加实际的坐标格式测试用例以提高覆盖率
♻️ 建议添加坐标格式测试用例
func testNoiseHeuristicFiltersCoordinateLikeText() { let tick = TextSegment(text: "12.5%", boundingBox: .zero, confidence: 0.95) let sentence = TextSegment(text: "Revenue growth", boundingBox: .zero, confidence: 0.95) let monthTick = TextSegment( text: "Jan", boundingBox: CGRect(x: 0.01, y: 0.94, width: 0.05, height: 0.02), confidence: 0.99 ) + let coordinatePair = TextSegment(text: "0.5, 0.3", boundingBox: .zero, confidence: 0.95) + let singleCoordinate = TextSegment(text: "x: 0.5", boundingBox: .zero, confidence: 0.95) XCTAssertTrue(tick.isLikelyTranslationNoise) XCTAssertTrue(monthTick.isLikelyTranslationNoise) + XCTAssertTrue(coordinatePair.isLikelyTranslationNoise) + XCTAssertTrue(singleCoordinate.isLikelyTranslationNoise) XCTAssertFalse(sentence.isLikelyTranslationNoise) }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@ScreenTranslateTests/TranslationPipelineRegressionTests.swift` around lines 23 - 35, Rename or expand the test so it matches the behavior being asserted: either rename the test method testNoiseHeuristicFiltersCoordinateLikeText to testNoiseHeuristicFiltersTicksAndLabels to reflect it currently checks percent ticks and edge labels (referencing TextSegment and isLikelyTranslationNoise), or add additional TextSegment instances containing coordinate-like strings (e.g., "0.5, 0.3", "(x:0.5, y:0.3)", "x: 0.5") and assert they are isLikelyTranslationNoise to cover the coordinate regex branch in ScreenAnalysisResult.isLikelyTranslationNoise; update assertions accordingly and keep the existing percent and month label assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@ScreenTranslateTests/TranslationPipelineRegressionTests.swift`:
- Around line 23-35: Rename or expand the test so it matches the behavior being
asserted: either rename the test method
testNoiseHeuristicFiltersCoordinateLikeText to
testNoiseHeuristicFiltersTicksAndLabels to reflect it currently checks percent
ticks and edge labels (referencing TextSegment and isLikelyTranslationNoise), or
add additional TextSegment instances containing coordinate-like strings (e.g.,
"0.5, 0.3", "(x:0.5, y:0.3)", "x: 0.5") and assert they are
isLikelyTranslationNoise to cover the coordinate regex branch in
ScreenAnalysisResult.isLikelyTranslationNoise; update assertions accordingly and
keep the existing percent and month label assertions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f955df7c-3c26-497c-8c02-81a2e77f3007
📒 Files selected for processing (1)
ScreenTranslateTests/TranslationPipelineRegressionTests.swift
Summary
ScreenTranslateTestsXCTest target and include regression coverage for translation pipeline behaviorxcodebuild testTesting
Summary by CodeRabbit
发布说明
新功能
改进
测试