Skip to content

dashboard: restore unit testing suite (fixes #10235) - #10246

Open
RyanS4 wants to merge 2 commits into
masterfrom
10235-restore-dashboard-tests
Open

dashboard: restore unit testing suite (fixes #10235)#10246
RyanS4 wants to merge 2 commits into
masterfrom
10235-restore-dashboard-tests

Conversation

@RyanS4

@RyanS4 RyanS4 commented Aug 5, 2026

Copy link
Copy Markdown
Member

Fixes #10235

Summary

This PR restores and modernizes the dashboard.component.spec.ts unit testing suite, updating it to Angular 19 and Vitest standards, and removes the file from vite.config.mts test exclusions.

Changes & Justifications

  1. Restored Unit Test Suite (dashboard.component.spec.ts):

    • Replaced commented-out legacy code with 21 unit tests using Angular TestBed and Vitest mocks (vi.fn()).
    • Covered component creation, display name calculations, role parsing, shelf item loading, survey/exam badge counts, certification grouping, dialog interaction, banner dismissal, mobile layout responsiveness, and edge cases.
    • Justification: Re-establishes automated test coverage for DashboardComponent and ensures stability across future updates.
  2. Test Runner Inclusion (vite.config.mts):

    • Removed 'src/**/dashboard.component.spec.ts' from test.exclude.
    • Justification: Enables automated test discovery and execution for dashboard.component.spec.ts in CI and local test runs.

Summary by CodeRabbit

  • Tests
    • Added comprehensive dashboard test coverage for initialization, data loading, errors, shelf states, badges, teams, dialogs, banners, responsive behavior, and cleanup.
    • Enabled the dashboard test suite to run as part of the standard Vitest test process.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@RyanS4, you've reached your PR review limit, so we couldn't start this review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7774e37f-b176-4f68-839a-11464f9c0c47

📥 Commits

Reviewing files that changed from the base of the PR and between a214ea5 and 472af82.

📒 Files selected for processing (1)
  • src/app/dashboard/dashboard.component.spec.ts
📝 Walkthrough

Walkthrough

The 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.

Changes

Dashboard testing

Layer / File(s) Summary
Dashboard component test coverage
src/app/dashboard/dashboard.component.spec.ts, vite.config.mts
Added mocked TestBed setup and functional, edge-case, and lifecycle tests for DashboardComponent. Removed the spec from the Vitest exclusion list.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: paulbert

🚥 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 clearly identifies the dashboard unit testing change and references issue #10235.
Linked Issues check ✅ Passed The PR restores the commented dashboard test suite and enables its discovery, satisfying issue #10235.
Out of Scope Changes check ✅ Passed All changes support restoring and running the dashboard unit tests described in issue #10235.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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 10235-restore-dashboard-tests

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.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/app/dashboard/dashboard.component.spec.ts (1)

84-115: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Destroy each fixture after the test.

The suite creates fixtures in beforeEach and, in two tests, creates a second fixture without destroying the first. The component constructor subscribes to userServiceMock.shelfChange$, which is a module-level Subject. Undestroyed components keep those subscriptions, so shelfChange$.next() at line 321 also re-runs ngOnInit on stale instances and re-issues mocked service calls. Add an afterEach teardown.

♻️ 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

📥 Commits

Reviewing files that changed from the base of the PR and between 6c3ea09 and a214ea5.

📒 Files selected for processing (2)
  • src/app/dashboard/dashboard.component.spec.ts
  • vite.config.mts
💤 Files with no reviewable changes (1)
  • vite.config.mts

Comment thread src/app/dashboard/dashboard.component.spec.ts Outdated
Comment thread src/app/dashboard/dashboard.component.spec.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dashboard: dead code in dashboard.component.spec.ts

1 participant