test(useGitHub): fix and unskip the missing-branchName test#52
Open
dev48v wants to merge 1 commit into
Open
Conversation
The "should throw an error if branchName is missing" test was skipped during the Jest→Vitest migration because it asserted a throw, while updateFileOnGitHub actually returns null (after a destructive toast) when branchName is missing — consistent with its BlueprintFile | null return type and its other guard clauses. The null/no-op behavior is the intended contract, so align the test with it instead of the source: assert it returns null, shows the "Branch Required" toast, and makes no fetch. Renamed and un-skipped. Fixes weval-org#49
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes the skipped
useGitHubtest called out in #49.should throw an error if branchName is missingwas.skipped during the Jest→Vitest migration (#45 / PR #46) because it asserted a throw, butupdateFileOnGitHubactually returnsnull(after showing a destructive "Branch Required" toast) whenbranchNameis missing.Fixes #49
Decision: keep the source, fix the test
Returning
nullis the intended contract, not a bug:updateFileOnGitHubis declaredPromise<BlueprintFile | null>.ready) already does the same thing — toast +return null.nullresult rather than a thrown error.So this aligns the test with the source (the graceful no-op) instead of changing the source. The test is renamed, un-skipped, and now asserts that the call:
null,Branch Requireddestructive toast,fetch.Testing
pnpm vitest run --project web src/app/sandbox/hooks/useGitHub.test.ts→ 12 passed (previously 11 + 1 skipped).pnpm test:web→ 49 files / 597 tests passed, none skipped from this file.pnpm typecheck→ clean (0 errors).Test-only change; no source/behavior change.