Skip to content

Give version helper tests independent oracles - #173

Merged
kody-bot merged 1 commit into
mainfrom
cleanup/keep-tests-tight-2026-11-10
Nov 10, 2026
Merged

kody-bot merged 1 commit into
mainfrom
cleanup/keep-tests-tight-2026-11-10

Conversation

@kody-bot

@kody-bot kody-bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Intent

Replace skip-on-null, tautological ISO toBeTruthy(), and semver-shape checks in app/helpers/version.test.ts with independent oracles (package.json version, git HEAD, baked env commit object) so a real regression fails.

Door: two-way

Cleanup: none

Why

Daily keep-tests-tight pass on 8f19b287d44f...ae58047c8b94. docs/contributing/testing-principles.md is not in this repo; this applies the same leftover-assert rules: every remaining test needs an independent oracle.

app/helpers/version.ts itself needed no production change. After #170/#171 the helper still prefers baked COMMIT_SHA / SOURCE_COMMIT (source: 'env', message 'baked at image build', date is process start) and falls back to git. The listed tests did not pin that behavior:

  • getAppVersion only matched /^\d+\.\d+\.\d+/ (a hardcoded 0.0.0 would pass)
  • git coverage early-returned on null and used tautological toISOString().toBeTruthy()
  • baked SHA coverage omitted message, date, SOURCE_COMMIT, and invalid-SHA fallthrough

Testing

  • Mutation: getAppVersion() hardcoded to 0.0.0 failed against package.json 4.1.1
  • Mutation: baked message baked at image build CHANGED failed the env object oracle
  • npx vitest run app/helpers/version.test.ts — 6 tests passed
  • npm run validate — format, lint, typecheck, and 45 files / 306 tests passed

No app behavior changed, so control CLI request/browse would not prove anything beyond the existing suite.

Pre-existing lint warning left alone: beforeEach in media-metadata-tools.test.ts.

System recap

Risk: low Touches: test suite only (app/helpers/version.test.ts)

(extends existing coverage; no product code)

  • version.ts unchanged (covered-code flag was missing oracles in the listed tests)
  • No public /feed, /media, /art URL or GUID changes
  • No OAuth/MCP auth behavior change

Summary by CodeRabbit

  • Tests
    • Expanded version checks to cover package-version matching, Git metadata, composed version information, and commit-source fallbacks.
    • Git metadata failures now fail the relevant tests instead of being skipped.

Replace skip-on-null, tautological ISO checks, and semver-shape matches
with package.json, git HEAD, and baked-SHA expected objects so a wrong
version, commit, or env fallback fails.

Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
@coderabbitai

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Explain Change →

Walkthrough

The version helper tests now check package version, Git HEAD metadata, composed version information, and commit selection from COMMIT_SHA and SOURCE_COMMIT. They also check that invalid baked values fall back to Git metadata.

Changes: Version Helper Tests

Layer / File(s) Summary
Version metadata and commit resolution tests
app/helpers/version.test.ts
The tests verify version information against package and Git data. They check COMMIT_SHA precedence, SOURCE_COMMIT fallback, and Git fallback for invalid values.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Suggested reviewers: kentcdodds

Merge Risk: Minimal · up to 51852

The tests improve version-metadata checks, and no actionable merge-blocking risk is established. The additional edge-case test can be deferred.

Pre-merge checks: Passed 5

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly describes the main change: adding independent oracles to the version helper tests.
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 1 files.

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional comments: 1

app/helpers/version.test.ts: 1

116-121: Trivial · Functional Correctness · Quick win

Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

The invalid-SHA test does not cover a valid SOURCE_COMMIT behind an invalid COMMIT_SHA.

The test sets COMMIT_SHA to not-a-sha and SOURCE_COMMIT to abc. Both values are invalid, so the test passes if the code ignores SOURCE_COMMIT.

In readBakedCommitSha, COMMIT_SHA || SOURCE_COMMIT picks the invalid COMMIT_SHA first. The function then returns null. This means a valid SOURCE_COMMIT is never used in that case.

The new test does not pin down that behavior. A later change could alter the precedence, and this test would still pass. Add a case with an invalid COMMIT_SHA and a valid SOURCE_COMMIT. Assert the intended result. The current source falls back to git.

Proposed additional test

+test('getCommitInfo does not use a valid SOURCE_COMMIT when COMMIT_SHA is set but invalid', async () => {
+	using _env = restoreCommitEnv()
+	setEnvVar('COMMIT_SHA', 'not-a-sha')
+	setEnvVar('SOURCE_COMMIT', sourceCommitSha)
+
+	await expect(getCommitInfo()).resolves.toEqual(await gitHeadCommit())
+})
Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: da8782cf-1f2a-4b06-9e9e-05cd12d2a7ec
Commits

Reviewing files that changed from the base of the PR and between ae58047 and 51852a1.

Files selected for processing: 1

  • app/helpers/version.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@kody-bot
kody-bot merged commit a8e3497 into main Nov 10, 2026
5 checks passed
@kody-bot
kody-bot deleted the cleanup/keep-tests-tight-2026-11-10 branch November 10, 2026 10:44
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.

2 participants