dashboard: restore unit testing suite (fixes #10235) - #10246
Conversation
|
Warning Review limit reached
Next review available in: 51 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe dashboard spec was replaced with an active Vitest suite. The suite mocks Angular dependencies and tests initialization, data loading, errors, UI state, responsive behavior, and cleanup. Vitest no longer excludes the dashboard spec. ChangesDashboard testing
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/app/dashboard/dashboard.component.spec.ts (1)
84-115: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDestroy each fixture after the test.
The suite creates fixtures in
beforeEachand, in two tests, creates a second fixture without destroying the first. The component constructor subscribes touserServiceMock.shelfChange$, which is a module-levelSubject. Undestroyed components keep those subscriptions, soshelfChange$.next()at line 321 also re-runsngOnIniton stale instances and re-issues mocked service calls. Add anafterEachteardown.♻️ Proposed fix: add fixture teardown
fixture = TestBed.createComponent(DashboardComponent); component = fixture.componentInstance; }); + + afterEach(() => { + fixture?.destroy(); + });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/app/dashboard/dashboard.component.spec.ts` around lines 84 - 115, Add an afterEach teardown for the fixture created in beforeEach, destroying it when present so component subscriptions are released after every test. Also ensure any tests that create an additional DashboardComponent fixture destroy that fixture as well, preventing stale shelfChange$ subscribers from receiving later emissions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/app/dashboard/dashboard.component.spec.ts`:
- Around line 149-159: Update the throwError usage in the login activity mock
and the corresponding mock around the second referenced test to pass the Error
instance directly, matching RxJS 6.5.4; preserve the existing error message and
test behavior.
- Around line 71-74: Recreate or reset the module-level BehaviorSubject
instances before each test in the setup around deviceTypeSubject and
userServiceMock.profileBanner, before TestBed.configureTestingModule runs.
Ensure each test starts with DeviceType.DESKTOP and the profile banner’s default
visible value, while preserving the existing service mock observables and
component behavior.
---
Nitpick comments:
In `@src/app/dashboard/dashboard.component.spec.ts`:
- Around line 84-115: Add an afterEach teardown for the fixture created in
beforeEach, destroying it when present so component subscriptions are released
after every test. Also ensure any tests that create an additional
DashboardComponent fixture destroy that fixture as well, preventing stale
shelfChange$ subscribers from receiving later emissions.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 97431c4e-b3bc-4635-ad05-c9ba989b68d0
📒 Files selected for processing (2)
src/app/dashboard/dashboard.component.spec.tsvite.config.mts
💤 Files with no reviewable changes (1)
- vite.config.mts
Fixes #10235
Summary
This PR restores and modernizes the
dashboard.component.spec.tsunit testing suite, updating it to Angular 19 and Vitest standards, and removes the file fromvite.config.mtstest exclusions.Changes & Justifications
Restored Unit Test Suite (
dashboard.component.spec.ts):TestBedand Vitest mocks (vi.fn()).DashboardComponentand ensures stability across future updates.Test Runner Inclusion (
vite.config.mts):'src/**/dashboard.component.spec.ts'fromtest.exclude.dashboard.component.spec.tsin CI and local test runs.Summary by CodeRabbit