You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Give version helper tests independent oracles - #173
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>
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.
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: 5
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title clearly describes the main change: adding independent oracles to the version helper tests.
Docstring Coverage
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
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Replace skip-on-null, tautological ISO
toBeTruthy(), and semver-shape checks inapp/helpers/version.test.tswith 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.mdis not in this repo; this applies the same leftover-assert rules: every remaining test needs an independent oracle.app/helpers/version.tsitself needed no production change. After #170/#171 the helper still prefers bakedCOMMIT_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:getAppVersiononly matched/^\d+\.\d+\.\d+/(a hardcoded0.0.0would pass)nulland used tautologicaltoISOString().toBeTruthy()SOURCE_COMMIT, and invalid-SHA fallthroughTesting
getAppVersion()hardcoded to0.0.0failed against package.json4.1.1baked at image build CHANGEDfailed the env object oraclenpx vitest run app/helpers/version.test.ts— 6 tests passednpm run validate— format, lint, typecheck, and 45 files / 306 tests passedNo app behavior changed, so control CLI
request/browsewould not prove anything beyond the existing suite.Pre-existing lint warning left alone:
beforeEachinmedia-metadata-tools.test.ts.System recap
Risk: low Touches: test suite only (
app/helpers/version.test.ts)(extends existing coverage; no product code)
version.tsunchanged (covered-code flag was missing oracles in the listed tests)/feed,/media,/artURL or GUID changesSummary by CodeRabbit