Skip to content

test: add regression tests for issue #30#42

Merged
ShadyUnderLight merged 1 commit intomainfrom
feature/issue30-regression-tests
Apr 21, 2026
Merged

test: add regression tests for issue #30#42
ShadyUnderLight merged 1 commit intomainfrom
feature/issue30-regression-tests

Conversation

@ShadyUnderLight
Copy link
Copy Markdown
Owner

@ShadyUnderLight ShadyUnderLight commented Apr 21, 2026

Summary

Adds automated regression tests for issue #30 (缺少最小自动化回归测试). The existing CI only validated compilation; these tests cover high-risk logic that can silently pass CI but behave incorrectly at runtime.

New test files

TemperatureParsingTests.swift — 17 tests
extractTemperature range validation (1-120 C), invalid inputs, first-number-wins

EnumSavedValueTests.swift — 18 tests
TemperatureMode and MenuBarDisplayMode savedValue initializers — both modern rawValue strings and legacy display-name strings (e.g. "Hottest CPU")

LocalizationTests.swift — 15 tests
L10n.localizationCandidates fallback chain across en-/zh-/fr-FR/ja-JP, deduplication

DiagnosticsTests.swift — 17 tests
ProcessSnapshotDiagnostics state machine (markAttempt / markSuccess / markFailure), full lifecycle

MonitorViewModelTests.swift — 15 tests
ViewModel defaults, legacy settings migration, invalid-value fallbacks

TestExpose.swift
Test-only L10n wrapper exposing localizationCandidates to the test target

Source changes

  • Localization.swift: raise localizationCandidates from private to internal (test-only exposure)
  • SystemMetricsProvider.swift: add nonisolated extractTemperatureTest for test access

Test results

All 104 tests pass with 0 failures.

CI now includes swift test and will catch regressions in:

  • Temperature string parsing boundaries
  • Enum migration from legacy UserDefaults keys
  • Localization fallback order
  • Diagnostics counter accumulation
  • ViewModel default and fallback behaviour

TemperatureParsingTests: 17 tests covering extractTemperature boundaries
  (valid range 1-120°C), invalid inputs, and multiple-number handling.

EnumSavedValueTests: 18 tests for TemperatureMode and MenuBarDisplayMode
  savedValue initializers — both modern rawValue strings and legacy
  display-name strings (e.g. 'Hottest CPU').

LocalizationTests: 15 tests for L10n localizationCandidates fallback chain
  across en-*/zh-*/fr-/ja-JP locales, deduplication, and edge cases.

DiagnosticsTests: 17 tests for ProcessSnapshotDiagnostics state machine
  (markAttempt / markSuccess / markFailure) and full lifecycle transitions.

MonitorViewModelTests: 15 tests for ViewModel defaults, legacy settings
  migration (temperatureMode + menuBarDisplayMode), and fallbacks.

TestExpose.swift: test-only L10n wrapper exposing localizationCandidates
  to the test target.

Source changes:
- Localization.swift: make localizationCandidates internal (was private)
- SystemMetricsProvider.swift: add nonisolated extractTemperatureTest
@ShadyUnderLight ShadyUnderLight merged commit 295cf24 into main Apr 21, 2026
2 checks passed
@ShadyUnderLight ShadyUnderLight deleted the feature/issue30-regression-tests branch April 21, 2026 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant