Skip to content

test(dashboard-filter): RTL coverage for horizontal filter bar#40782

Open
sadpandajoe wants to merge 4 commits into
masterfrom
horizontal-filter-bar-layout-rtl
Open

test(dashboard-filter): RTL coverage for horizontal filter bar#40782
sadpandajoe wants to merge 4 commits into
masterfrom
horizontal-filter-bar-layout-rtl

Conversation

@sadpandajoe
Copy link
Copy Markdown
Member

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 when filterValues is non-empty.
  • FilterControls/FilterControls.overflow.test.tsx (new) — 5 cases that drive overflow behavior by mocking the @superset-ui/core/components/DropdownContainer subpath and invoking onOverflowingStateChange directly: 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 in dropdownContent.
  • FilterBar.test.tsx — 2 cases asserting that FilterBarOrientation.Horizontal mounts Horizontal.tsx (settings gear present, vertical heading absent) and FilterBarOrientation.Vertical mounts the vertical control.

Implementation notes

  • DropdownContainer uses react-resize-detector, which reports width 0 in jsdom. Driving the real overflow math is unstable, so the overflow tests mock the DropdownContainer subpath (not the @superset-ui/core/components barrel — the barrel mock triggers a circular re-export chain via LabeledErrorBoundInput / ActionButton).
  • Reload-persistence of orientation is integration-level (server-side 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

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.tsx with horizontal-mode assertions for actions slot, settings gear, filter rendering, and empty-state behavior.
  • Adds a new FilterControls.overflow.test.tsx suite that mocks DropdownContainer to deterministically drive overflow state and assert computed trigger count/content behavior.
  • Extends FilterBar.test.tsx to 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
Copy link
Copy Markdown

codecov Bot commented Jun 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.24%. Comparing base (0984839) to head (8dbc0c8).
⚠️ Report is 1 commits behind head on master.

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              
Flag Coverage Δ
javascript 67.97% <ø> (+0.10%) ⬆️

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.

sadpandajoe and others added 4 commits June 5, 2026 13:41
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>
@sadpandajoe sadpandajoe force-pushed the horizontal-filter-bar-layout-rtl branch from 790505a to 8dbc0c8 Compare June 5, 2026 20:41
@sadpandajoe sadpandajoe marked this pull request as ready for review June 5, 2026 20:41
@dosubot dosubot Bot added the dashboard:native-filters Related to the native filters of the Dashboard label Jun 5, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented Jun 5, 2026

Code Review Agent Run #b1e108

Actionable Suggestions - 0
Review Details
  • Files reviewed - 3 · Commit Range: a3eb8ee..8dbc0c8
    • superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterBar.test.tsx
    • superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterControls.overflow.test.tsx
    • superset-frontend/src/dashboard/components/nativeFilters/FilterBar/HorizontalFilterBar.test.tsx
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

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

Labels

dashboard:native-filters Related to the native filters of the Dashboard review:draft size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants