Skip to content

test(infra): add unit tests for semver-compare version utilities - #58313

Closed
aaronlab wants to merge 1 commit into
openclaw:mainfrom
aaronlab:test/semver-compare-coverage
Closed

aaronlab wants to merge 1 commit into
openclaw:mainfrom
aaronlab:test/semver-compare-coverage

Conversation

@aaronlab

Copy link
Copy Markdown
Contributor

Summary

  • Add comprehensive unit tests for all 4 exported functions in semver-compare.ts
  • Covers version parsing, comparison, prerelease ordering, legacy .beta.N normalization
  • These pure functions are used in update checks with zero prior coverage

Change Type

  • Test coverage

Test plan

  • All new tests pass (30/30)
  • CI passes

🤖 Generated with Claude Code

Add comprehensive test coverage for parseComparableSemver,
compareComparableSemver, comparePrereleaseIdentifiers, and
normalizeLegacyDotBetaVersion. These pure functions are used
in update checks and had zero prior test coverage.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@greptile-apps

greptile-apps Bot commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a new test file src/infra/semver-compare.test.ts providing unit test coverage for all four exported pure functions in src/infra/semver-compare.ts: normalizeLegacyDotBetaVersion, parseComparableSemver, comparePrereleaseIdentifiers, and compareComparableSemver. The functions handle update-check version comparison logic and had zero prior test coverage.

  • 30 tests across 4 describe blocks, verified accurate against the source implementation
  • Covers happy paths, edge cases (whitespace, v prefix, build metadata stripping, null/undefined/empty input, malformed versions), and prerelease ordering semantics (numeric vs. string identifier precedence, shorter-prefix rule)
  • Test file is picked up automatically by the existing \"src/**/*.test.ts\" glob in vitest.config.ts
  • All assertions were checked against the source and are correct
  • No production code is changed; this is a pure coverage addition

Confidence Score: 5/5

Safe to merge — pure test addition with no production code changes and all assertions verified correct.

No P0 or P1 issues found. All 30 test assertions were verified against the source implementation and are accurate. The test file integrates cleanly with the existing vitest setup and covers all four exported functions comprehensively including edge cases.

No files require special attention.

Reviews (1): Last reviewed commit: "test(infra): add unit tests for semver-c..." | Re-trigger Greptile

@vincentkoc vincentkoc added the triage: test-only-no-bug Candidate: test-only change has no linked bug or behavior evidence. label Apr 26, 2026
@vincentkoc vincentkoc self-assigned this Apr 29, 2026
@vincentkoc

Copy link
Copy Markdown
Member

Thanks for adding coverage here. Closing this because it is test-only without a linked regression, maintainer request, or behavior fix; please resubmit if there is a concrete semver bug this should guard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: M triage: test-only-no-bug Candidate: test-only change has no linked bug or behavior evidence.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants