(janitor/test-prune): consolidate redundant mock-echo tests in admin-github-router - #5634
Open
kilo-code-bot[bot] wants to merge 1 commit into
Open
(janitor/test-prune): consolidate redundant mock-echo tests in admin-github-router#5634kilo-code-bot[bot] wants to merge 1 commit into
kilo-code-bot[bot] wants to merge 1 commit into
Conversation
Three router endpoints (getKilocodeOpenPullRequestsSummary, getKilocodeRecentlyClosedExternalPRs) each had a standalone 'returns X for admin users' test that only asserted the router result equals the exact object handed to a same-test mock, with no input and no branching logic exercised — a pure mock echo. Each of these had a sibling 'passes repos parameter through to the service' test in the same describe block that already drove the admin-success path with real input. Merge the response-equality assertion into the parameter-forwarding test so both behaviors (successful pass-through of the service response, and correct argument forwarding) are verified by one test per endpoint, and delete the now-redundant standalone test. Also drop three assertions in the 'returns recently merged external PRs' test that re-derived facts (array length, first item's number) already implied by the preceding toEqual on the same mock object. No behavioral coverage is lost: - The FORBIDDEN-for-non-admin test in each describe block already covers the admin gate. - The service-level business logic (default repos, draft filtering, bot/team classification) is covered independently and more thoroughly in apps/web/src/lib/github/open-pull-request-counts.test.ts. - The router procedures are literal pass-throughs to the mocked service (admin-router.ts:511-556); no router-owned transformation logic existed to lose coverage of.
Contributor
Author
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Executive SummaryTest-only consolidation of redundant mock-echo assertions in Files Reviewed (1 files)
Reviewed by grok-4.6 · Input: 158.1K · Output: 5.4K · Cached: 59.6K Review guidance: REVIEW.md from base branch |
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.
What
Consolidates redundant tests in
apps/web/src/routers/admin-github-router.test.ts.Three router endpoints each had a standalone
'returns X for admin users'test whose only assertion wasexpect(result).toEqual(mockX)against a value returned by a mock configured in the same test, called with no input. Each of these had a sibling'passes repos parameter through to the service'test in the samedescribeblock that already exercised the admin-success path with real input and asserted the mock's call arguments.admin.github.getKilocodeOpenPullRequestsSummaryadmin.github.getKilocodeRecentlyClosedExternalPRsFor each, the response-equality assertion was merged into the existing parameter-forwarding test (now asserting both "service response passes through unmodified" and "input is forwarded to the service"), and the standalone mock-echo test was deleted.
Also removed three assertions in
'returns recently merged external PRs for admin users'(result.length,result[0]?.number) that re-derive facts already implied by thetoEqual(mockMergedPrs)assertion on the preceding line — same test, no coverage change.Why these are safe to remove
admin-router.ts:511-556) is a literal pass-through:return service({...args}), with no router-owned branching, filtering, or transformation of the response. There is no router logic whose regression the deleted assertions could have caught beyond "the mock returned what it was told to return."describeblock retains its'throws FORBIDDEN for non-admin users'test, which is the only meaningful branch (admin vs. non-admin) at this layer.reposselection, draft filtering, bot/team PR classification, week-boundary computation) is exercised directly and extensively inapps/web/src/lib/github/open-pull-request-counts.test.ts, which calls the real (unmocked) service functions rather than a mock.Validation
git stash+ baseline run ofpnpm --filter web exec jest routers/admin-github-router.test.tsfails identically before and after this change (10 tests → 8 tests, matching the 2 removed) due to this sandbox having no reachable PostgreSQL instance (ECONNREFUSEDininsertTestUser/cleanupDbForTest). This is a pre-existing sandbox limitation, not something introduced by this change — the test file requires DB-backedcreateCallerForUser/insertTestUserhelpers that this environment cannot provision (no docker/postgres available).node_modules/.bin/oxlint apps/web/src/routers/admin-github-router.test.ts— 0 warnings, 0 errors.tsgo --noEmit(apps/web) — no errors.oxfmt— no additional formatting changes needed.