test(dashboard-filter): RTL coverage for horizontal filter bar#40782
test(dashboard-filter): RTL coverage for horizontal filter bar#40782sadpandajoe wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds React Testing Library coverage for the dashboard native filters horizontal filter bar, focusing on layout/orientation routing and overflow behavior that was previously only covered by a disabled Cypress spec—supporting the ongoing Cypress → RTL/Playwright migration.
Changes:
- Extends
HorizontalFilterBar.test.tsxwith horizontal-mode assertions for actions slot, settings gear, filter rendering, and empty-state behavior. - Adds a new
FilterControls.overflow.test.tsxsuite that mocksDropdownContainerto deterministically drive overflow state and assert computed trigger count/content behavior. - Extends
FilterBar.test.tsxto assert orientation routing (Horizontal mounts Horizontal subtree; Vertical mounts Vertical subtree).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| superset-frontend/src/dashboard/components/nativeFilters/FilterBar/HorizontalFilterBar.test.tsx | Adds RTL tests and preset registration to cover horizontal filter bar rendering and empty-state behavior. |
| superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterControls.overflow.test.tsx | New RTL tests for overflow behavior using a targeted DropdownContainer subpath mock to avoid jsdom layout instability. |
| superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterBar.test.tsx | Adds orientation routing assertions to ensure Horizontal vs Vertical layouts mount the intended subtree. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #40782 +/- ##
==========================================
+ Coverage 64.19% 64.24% +0.05%
==========================================
Files 2666 2666
Lines 143991 143991
Branches 33108 33108
==========================================
+ Hits 92428 92512 +84
+ Misses 49950 49866 -84
Partials 1613 1613
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Adds React Testing Library coverage for the horizontal filter bar's layout, overflow, and orientation routing — behavior previously only covered by a disabled Cypress spec. Part of the ongoing Cypress → RTL/Playwright migration. - HorizontalFilterBar.test.tsx: 3 new cases (default-actions slot, all-filters render, empty-message flip-off). - FilterControls/FilterControls.overflow.test.tsx (new): 5 cases driving overflow via a mock of the DropdownContainer subpath and onOverflowingStateChange — items pass-through, no-overflow, overflow with/without active values, all 12 overflowed filters reachable. - FilterBar.test.tsx: 2 cases for FilterBarOrientation.Horizontal vs Vertical mounting. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Import act from spec/helpers/testing-library instead of react, matching sibling FilterBar.test.tsx convention. - Type renderWrapper/renderWithFilters overrideProps as Partial<HorizontalBarProps> instead of Record<string, any>; type the createSelectFilter helper as Filter and cast the inline filterValues literal so the tightened signature type-checks. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…helper
createSelectFilter's literal already declares every required Filter field,
so the trailing `as unknown as Filter` was a no-op the `: Filter` return
annotation already covered. Drop it; pre-commit Type-Checking (Frontend)
is clean. Also document why the intentionally minimal `{id, type}` cast in
the "should not render the empty message" test is sound (Horizontal only
reads filterValues.length there).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
CI prettier broke the single-line createSelectFilter signature across lines after the prior cast-cleanup commit. Reflow locally. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
790505a to
8dbc0c8
Compare
Code Review Agent Run #b1e108Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
SUMMARY
Adds React Testing Library coverage for the horizontal filter bar's layout, overflow, and orientation routing — behavior that was previously only covered by a disabled Cypress spec. Part of the ongoing Cypress → RTL/Playwright migration.
Three test files are touched:
HorizontalFilterBar.test.tsx— 3 new cases covering the default-actions slot, all-filters rendering, and the empty-state message flipping off whenfilterValuesis non-empty.FilterControls/FilterControls.overflow.test.tsx(new) — 5 cases that drive overflow behavior by mocking the@superset-ui/core/components/DropdownContainersubpath and invokingonOverflowingStateChangedirectly: items pass-through, no-overflow (trigger count 0), overflow with active filter values (trigger count reflects active values), overflow with no active values (trigger 0 but content rendered), and all 12 overflowed filters reachable indropdownContent.FilterBar.test.tsx— 2 cases asserting thatFilterBarOrientation.HorizontalmountsHorizontal.tsx(settings gear present, vertical heading absent) andFilterBarOrientation.Verticalmounts the vertical control.Implementation notes
DropdownContainerusesreact-resize-detector, which reports width 0 in jsdom. Driving the real overflow math is unstable, so the overflow tests mock theDropdownContainersubpath (not the@superset-ui/core/componentsbarrel — the barrel mock triggers a circular re-export chain viaLabeledErrorBoundInput/ActionButton).json_metadata, not localStorage) and is not RTL-testable; it remains out of scope for this change.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — test-only change.
TESTING INSTRUCTIONS
```bash
cd superset-frontend
npx jest \
src/dashboard/components/nativeFilters/FilterBar/FilterBar.test.tsx \
src/dashboard/components/nativeFilters/FilterBar/HorizontalFilterBar.test.tsx \
src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterControls.test.tsx \
src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterControls.overflow.test.tsx
```
Expected: 49 passing tests across the four files.
ADDITIONAL INFORMATION