Skip to content

test(dashboard): add regression guards for duplicate widget renders#2840

Open
Honey-pg wants to merge 1 commit into
Priyanshu-byte-coder:mainfrom
Honey-pg:test/dashboard-no-duplicate-widgets
Open

test(dashboard): add regression guards for duplicate widget renders#2840
Honey-pg wants to merge 1 commit into
Priyanshu-byte-coder:mainfrom
Honey-pg:test/dashboard-no-duplicate-widgets

Conversation

@Honey-pg

Copy link
Copy Markdown
Contributor

The duplicate inline widgets bug was fixed in aba0430; these tests prevent reintroduction via a static page.tsx guard and E2E DOM/API assertions.

Summary

Adds regression tests to ensure dashboard analytics widgets are not rendered twice in page.tsx. The duplicate inline widgets bug was already fixed in aba0430; this PR adds a static guard on page.tsx and E2E DOM/API assertions so the issue cannot be reintroduced.

Closes #2535


Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that changes existing behavior)
  • 📝 Documentation update
  • ♻️ Refactor / code cleanup (no functional change)
  • ⚡ Performance improvement
  • 🔒 Security fix
  • 🧪 Tests only

What Changed

  • Added test/dashboard-page-no-duplicate-widgets.test.ts — asserts src/app/dashboard/page.tsx delegates to CustomizableDashboard and does not directly import or render RepoAnalyticsExplorer, PRMetrics, PRBreakdownChart, or PRReviewTrendChart
  • Added E2E test in e2e/dashboard.spec.ts — verifies each analytics widget region/heading renders once and metrics API calls stay within expected bounds
  • Updated e2e/helpers/dashboard-mocks.js — added /api/metrics/pr-review-time stub (used by PRReviewTrendChart, not pr-review-trend)
  • Tightened e2e/dashboard-widgets.spec.js — replaced .first() with .toHaveCount(1) for PR Analytics heading

How to Test

  1. Run the static guard: npm test test/dashboard-page-no-duplicate-widgets.test.ts
  2. Run the E2E regression test: npm run test:e2e -- e2e/dashboard.spec.ts -g "duplicate"
  3. Optionally load /dashboard in the browser, open DevTools → Network, filter /api/metrics/, and scroll through the Analytics section

Expected result: All tests pass. Each analytics widget appears once in the DOM, and metrics endpoints are not called excessively (duplicate inline widgets would produce extra regions and API calls).


Checklist

  • Linked the related issue above
  • Self-reviewed my own diff
  • No unnecessary console.log, debug code, or commented-out blocks
  • npm run lint passes locally
  • No TypeScript errors (npm run type-check)
  • Added or updated tests where applicable
  • Updated documentation / comments if behavior changed

Additional Context

No production code changes. The original bug was fixed in aba0430, which removed inline dashboard widgets from page.tsx in favor of CustomizableDashboard.

The E2E API assertions use min/max bounds rather than exactly-one call per endpoint because:

  • React Strict Mode in dev can double-invoke effects
  • /api/metrics/pr-review-time is legitimately called by both MiniPRTrendChart (inside PR Metrics) and the PR Review Trend widget

The duplicate inline widgets bug was fixed in aba0430; these tests prevent
reintroduction via a static page.tsx guard and E2E DOM/API assertions.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions github-actions Bot added type:testing GSSoC type bonus: tests (+10 pts) gssoc26 GSSoC 2026 contribution type:feature GSSoC type bonus: new feature labels Jun 27, 2026
@github-actions

Copy link
Copy Markdown

GSSoC Label Checklist 🏷️

@Priyanshu-byte-coder — please apply the appropriate labels before merging:

Difficulty (pick one):

  • level:beginner — 20 pts
  • level:intermediate — 35 pts
  • level:advanced — 55 pts
  • level:critical — 80 pts

Quality (optional):

  • quality:clean — ×1.2 multiplier
  • quality:exceptional — ×1.5 multiplier

Validation (required to score):

  • gssoc:approved — counts for points
  • gssoc:invalid / gssoc:spam / gssoc:ai-slop — does not score

Type labels (type:*) are auto-detected from files and title. Review and adjust if needed.
Points formula: (difficulty × quality_multiplier) + type_bonus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc26 GSSoC 2026 contribution type:feature GSSoC type bonus: new feature type:testing GSSoC type bonus: tests (+10 pts)

Projects

None yet

1 participant