Skip to content

test(web): provide a default Apollo client in vitest setup#2034

Merged
elibosley merged 1 commit into
mainfrom
fix/web-test-default-apollo-client
Jun 23, 2026
Merged

test(web): provide a default Apollo client in vitest setup#2034
elibosley merged 1 commit into
mainfrom
fix/web-test-default-apollo-client

Conversation

@elibosley

@elibosley elibosley commented Jun 23, 2026

Copy link
Copy Markdown
Member

Full web vitest suite emits ~22 Apollo client with id default not found unhandled rejections, attributed to unrelated files (Modals.test.ts, DowngradeOs.test.ts). They don't fail the build but add noise and risk false positives.

They appear only in the full suite (not in isolation): some components/generated composables resolve the default Apollo client asynchronously (during teardown, after the triggering test finished), when no client is in scope; the useQuery mock doesn't cover those paths.

Fix: provide a no-op default Apollo client in web/vitest.setup.ts (InMemoryCache + a terminating ApolloLink emitting an empty result) so resolveClient always succeeds. No network calls; useQuery stays mocked.

Verification: full web suite locally — 64 files / 641 tests pass, zero unhandled rejections (was 22).

Test-harness only; no runtime changes. Split out of #2033, where these were noticed (pre-existing on main, unrelated to that feature).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Improved test setup configuration to prevent unhandled errors during test execution and ensure proper test environment initialization.

No user-facing changes in this release.

Some components and generated composables resolve the default Apollo
client asynchronously (e.g. during teardown, after the triggering test
has finished). Even with useQuery mocked, this surfaced ~22 "Apollo
client with id default not found" unhandled rejections in the full web
suite — reported against unrelated files like Modals.test.ts and
DowngradeOs.test.ts — adding noise and risking false positives.

Provide a no-op default client (InMemoryCache + a terminating link that
emits an empty result) in the global vitest setup so resolveClient never
throws, regardless of timing. No network calls; useQuery stays mocked.

Full web suite: 64 files / 641 tests pass, zero unhandled rejections.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 4f8ffd7b-8e8d-4ddb-876c-a55c59942cea

📥 Commits

Reviewing files that changed from the base of the PR and between 3e8f61f and 4b4ab27.

📒 Files selected for processing (1)
  • web/vitest.setup.ts

Walkthrough

web/vitest.setup.ts adds imports for Apollo client primitives and a global provideApolloClient call that registers a default Apollo client backed by InMemoryCache and an ApolloLink returning empty { data: {} } payloads, suppressing unhandled "default client not found" rejections across the test suite.

Changes

Apollo Client Stub in Vitest Setup

Layer / File(s) Summary
Global Apollo client stub registration
web/vitest.setup.ts
Imports provideApolloClient, ApolloClient, ApolloLink, InMemoryCache, and Observable; calls provideApolloClient with a client whose terminating link emits { data: {} }, suppressing missing-default-client unhandled rejections for the entire test run.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

A bunny hops through tests with glee,
No Apollo errors, wild and free! 🐇
A stub of data, empty and bright,
Keeps rejections away from sight.
Cache in memory, links aligned—
The test suite runs, peace of mind! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: providing a default Apollo client in the vitest setup file to resolve unhandled rejection errors.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/web-test-default-apollo-client

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 52.78%. Comparing base (3e8f61f) to head (4b4ab27).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2034   +/-   ##
=======================================
  Coverage   52.77%   52.78%           
=======================================
  Files        1035     1035           
  Lines       72060    72060           
  Branches     8293     8298    +5     
=======================================
+ Hits        38027    38034    +7     
+ Misses      33907    33900    -7     
  Partials      126      126           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

Copy link
Copy Markdown
Contributor

This plugin has been deployed to Cloudflare R2 and is available for testing.
Download it at this URL:

https://preview.dl.unraid.net/unraid-api/tag/PR2034/dynamix.unraid.net.plg

@elibosley elibosley merged commit 2679fda into main Jun 23, 2026
13 checks passed
@elibosley elibosley deleted the fix/web-test-default-apollo-client branch June 23, 2026 16:40
@github-actions

Copy link
Copy Markdown
Contributor

🔄 PR Merged - Plugin Redirected to Staging

This PR has been merged and the preview plugin has been updated to redirect to the staging version.

For users testing this PR:

  • Your plugin will automatically update to the staging version on the next update check
  • The staging version includes all merged changes from this PR
  • No manual intervention required

Staging URL:

https://preview.dl.unraid.net/unraid-api/dynamix.unraid.net.plg

Thank you for testing! 🚀

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.

1 participant