test(registry): pin useRegistryUpdateMutation coverage to fix Coveralls flake#2035
Merged
test(registry): pin useRegistryUpdateMutation coverage to fix Coveralls flake#2035
Conversation
…ls flake Coveralls has been reporting a -0.02% regression on PRs that touch only docs/CI because line 59 of use-registry-update-mutation.ts (the generic `throw e` rethrow inside putRegistry) was only ever hit ambiently via registry-tab.test.tsx. Depending on MSW teardown and test scheduling it sometimes flipped to uncovered, producing a spurious -2.25% delta on this file (~-0.02% total). Add a direct unit test that exercises every branch of the hook: default/url/local_path happy paths, api_url with full/partial/no auth, OIDC_DISCOVERY and AUTH_FIELDS_REQUIRED error patterns, non-matching PUT errors for both api_url and url types (covers `throw e` from both guard paths), and the authenticateWithRegistry login-failure path (REGISTRY_WRONG_AUTH_TOAST + invalidate + fire-and-forget logout). Verified lcov output is byte-identical across three consecutive coverage runs, with DA:59 pinned at hit-count 3.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds deterministic unit tests for useRegistryUpdateMutation to stabilize Coveralls line coverage and prevent flapping caused by previously-ambient execution of the throw e rethrow branch in putRegistry.
Changes:
- Add a new hook-focused test suite that exercises all
useRegistryUpdateMutationbranches (success + error paths). - Explicitly covers
putRegistryerror classification (OIDC discovery/auth-required) and the generic rethrow behavior. - Covers
authenticateWithRegistryfailure behavior (rejects with known toast + invalidation + logout call).
…on deterministically Addresses Copilot review feedback on #2035: - Pin the exact thrown value in the two rethrow tests so line 59 (`throw e`) is protected against regressions that would wrap the original error in a new Error. - In the login-failure test, await the mutation promise directly (`await expect(promise).rejects.toMatchObject(...)`) instead of the side-effecting `.catch` + local variable pattern, so the toast assertion no longer races the React Query observer notification. Made-with: Cursor
peppescg
approved these changes
Apr 17, 2026
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.
The
coverage/coverallscheck has been flapping between "no change" and "Coverage decreased (-0.02%) to 63.188%" on PRs that touch only docs/CI (e.g. #2032). Coveralls pinpoints the regression to exactly one line:renderer/src/common/components/settings/registry/use-registry-update-mutation.ts:59— the genericthrow erethrow insideputRegistry's.catch. That line has no dedicated test; its coverage is entirely ambient fromrenderer/src/common/components/settings/tabs/__tests__/registry-tab.test.tsx, which never forces a non-matching PUT error. Depending on MSW teardown and test scheduling it sometimes flipped to uncovered, producing the-2.25% on this file (-0.02% total) that Coveralls was reporting.renderer/src/common/components/settings/registry/__tests__/use-registry-update-mutation.test.ts— 12 direrenderHooktests that pin every branch ofuseRegistryUpdateMutation`type = default(empty PUT body),type = url({ url }+ cache updated),type = local_path({ local_path }),type = api_urlwith both auth fields (PUT +postApiV1BetaRegistryAuthLogin+invalidateQueries),type = api_urlwith onlyclient_id(partialauth),type = api_urlwith neither field (noauth, login skipped), and the post-successremoveQueriesforregistry-name-serversputRegistryerror branches:api_url+ OIDC pattern →REGISTRY_WRONG_ISSUER_TOAST,api_url+ auth-required pattern →REGISTRY_AUTH_FIELDS_REQUIRED_TOAST,api_url+ non-matching string →throw e(line 59 via path A),url+ JSON error →throw e(line 59 via path B)authenticateWithRegistryerror branch: PUT succeeds, login fails →mutateAsyncrejects withREGISTRY_WRONG_AUTH_TOAST,invalidateQueriesfor the registry key was called, fire-and-forget logout POST was mademockedPutApiV1BetaRegistryByName,mockedPostApiV1BetaRegistryAuthLogin,mockedPostApiV1BetaRegistryAuthLogout) — no new infrastructureWhy this removes the jitter
v8 records per-line hit counts. Once line 59 is hit deterministically by an explicit assertion, it stays at
coveredon every run, so base and head SHAs report identical coverage for this file. Verified locally across three back-to-backpnpm run test:coverageruns on the relevant files — the lcov block foruse-registry-update-mutation.tsis byte-identical, andDA:59is pinned at hit-count 3.Not changed in this PR (deliberate, follow-up)
.github/workflows/_unit-tests.yml,.github/workflows/on-pr.yml, orvitest.config.ts— the workflow still runs on every PR and uploads to Coveralls, it just stops producing a non-deterministic deltacoverage/coverallsstatus post (two identical entries on the same(sha, context)pair, ~2.5 minutes apart) is orthogonal to the flake and left low-up: one-linegithub-token: ''oncoverallsapp/github-actionin_unit-tests.yml, or disabling the Coveralls GitHub App's PR-status integration in repo settings. After this PR the single remaining status would already be green.