Skip to content

test(statviz): add StockOverview dashboard section tests - #2872

Open
pylipp with Copilot wants to merge 5 commits into
masterfrom
copilot/test-coverage-dashboard-graphs
Open

test(statviz): add StockOverview dashboard section tests#2872
pylipp with Copilot wants to merge 5 commits into
masterfrom
copilot/test-coverage-dashboard-graphs

Conversation

Copilot AI commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Adds integration tests for the StockOverview section of the analytics Dashboard, covering the full pipeline from mocked GraphQL responses through client-side filtering to rendered chart output.

Approach

Chart mockingPieChart, BarChart, and CalendarChart (nivo) are replaced with lightweight DOM stubs that render their input data as text nodes and data-testid elements. This lets tests assert on filtered data values without SVG/ResizeObserver complexity in jsdom, while keeping all filter-container logic (the actual business logic under test) fully exercised.

Filter state via URL — Filters are pre-set through the initialUrl parameter (?sp=1, ?sg=Male, ?sc=1, ?sl=2, ?st=1, ?snt=1) rather than driving react-select UIs, matching how the real components work and making tests fast and deterministic.

Mock data

Query Facts
STOCK_QUERY 3× InStock (Shoes/Male/Cat1/Loc1/Tag1, Shirts/Female/Cat2/Loc2/Tag2, Pants/null/Cat3/Loc3/Tag3) + 1× Donated + 1× Lost
CREATED_BOXES_QUERY 1m ago (product 1), 5m ago (product 2), 10m ago (product 1), 15m ago (product 3 — outside 1-year default window)

Note: productName values in STOCK_QUERY facts are lowercase ("shoes", "shirts", "pants") to match the backend convention; the ring/bar filter logic lowercases p.name from the option list but not the raw productName fact field.

What is tested (14 tests)

  • No-filter baseline: ring/bar show only InStock data (Donated+Lost excluded); calendar shows only 3 of 4 facts (15-month fact outside 1-year window)
  • Per-filter verification: product, gender, category, location, include-tag, exclude-tag — each narrows ring slices, bar categories, and calendar days to the expected subset; location filter is confirmed to have no effect on the calendar
  • Filter chips: label text and chip close-button data-testid asserted for each filter type; excluded-tag chip verified to carry text-decoration: line-through
  • Clear filters: via individual chip ×, via "Clear filters (N)" button, and via the filter-panel drawer ("Clear filters" → Apply)
  • Boxes/items switch: native <select> (found by getByDisplayValue) switches chart values and headings between boxesCount and itemsCount

Co-authored-by: pylipp <10617122+pylipp@users.noreply.github.com>
@codecov

codecov Bot commented Aug 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.78%. Comparing base (f2a90ed) to head (3d0cc12).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2872      +/-   ##
==========================================
+ Coverage   73.71%   73.78%   +0.06%     
==========================================
  Files         330      330              
  Lines       25270    25090     -180     
  Branches     2479     2444      -35     
==========================================
- Hits        18628    18512     -116     
+ Misses       6591     6527      -64     
  Partials       51       51              
Flag Coverage Δ
backend 99.61% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@pylipp
pylipp force-pushed the copilot/test-coverage-dashboard-graphs branch from c60b3fe to 7a203a1 Compare August 20, 2026 11:20
@pylipp
pylipp requested a lite review from Copilot August 20, 2026 19:37
@pylipp
pylipp marked this pull request as ready for review August 20, 2026 19:37
@pylipp

pylipp commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds integration-style UI tests for the StockOverview section in the statviz analytics dashboard, validating URL-driven filter behavior and chart output using lightweight nivo chart stubs.

Changes:

  • Introduces StockOverview.test.tsx covering baseline rendering, per-filter narrowing, chip clearing flows, and boxes/items switching.
  • Mocks nivo chart primitives to assert on filtered data without relying on SVG rendering in jsdom.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread shared-components/statviz/dashboard/StockOverview.test.tsx Outdated
Comment thread shared-components/statviz/dashboard/StockOverview.test.tsx Outdated
@pylipp
pylipp force-pushed the copilot/test-coverage-dashboard-graphs branch from a1db454 to 1befc29 Compare August 20, 2026 20:40
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.

3 participants