From 10bacb4e2b98ea8d75fb8c2b00efba011dc0886d Mon Sep 17 00:00:00 2001 From: Joe Li Date: Tue, 9 Jun 2026 16:30:50 -0700 Subject: [PATCH] test(dashboard-filter): assert horizontal default actions render with no filters Covers the second half of sc-107387 task #107390 ("show all default actions in horizontal mode") by asserting the empty-state copy, settings gear, and filterbar-action-buttons all render when FilterBar is horizontal with no filters. Dropdown contents are already exercised by FilterBarSettings.test.tsx; reload-persistence remains queued for Playwright. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../FilterBar/FilterBar.test.tsx | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterBar.test.tsx b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterBar.test.tsx index 1e9bffd8e8c..e7b8506c090 100644 --- a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterBar.test.tsx +++ b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterBar.test.tsx @@ -992,6 +992,51 @@ test('FilterBar with orientation=Horizontal routes to Horizontal layout instead expect(screen.getByRole('img', { name: 'setting' })).toBeInTheDocument(); }); +test('FilterBar with orientation=Horizontal and no filters shows empty state alongside default actions', async () => { + // Covers the second half of sc-107387 task #107390 ("show all default + // actions in horizontal mode"). The original Cypress spec asserted four + // affordances render when the bar is horizontal with no filters: the + // empty-state copy, the settings gear, the action-buttons block, and the + // create-filter entry inside the gear menu. The dropdown contents are + // already covered by FilterBarSettings.test.tsx; here we keep scope to + // the layout-level affordances that are exclusive to Horizontal.tsx. + // Reload-persistence (the rest of #107390) is out of RTL scope and stays + // queued for Playwright. + const state = { + ...stateWithoutNativeFilters, + dashboardInfo: { + id: 1, + dash_edit_perm: true, + metadata: { + native_filter_configuration: [], + filterBarOrientation: FilterBarOrientation.Horizontal, + }, + }, + dashboardState: { + ...stateWithoutNativeFilters.dashboardState, + activeTabs: ['ROOT_ID'], + }, + nativeFilters: { filters: {}, filtersState: {} }, + }; + + render(, { + initialState: state, + useDnd: true, + useRedux: true, + useRouter: true, + }); + + await act(async () => { + jest.runAllTimers(); + }); + + expect(screen.getByTestId('horizontal-filterbar-empty')).toHaveTextContent( + 'No filters are currently added to this dashboard.', + ); + expect(screen.getByRole('img', { name: 'setting' })).toBeInTheDocument(); + expect(screen.getByTestId('filterbar-action-buttons')).toBeInTheDocument(); +}); + test('FilterBar with orientation=Vertical renders Vertical layout (sanity counterpart to the horizontal routing test)', () => { // Paired control for the routing test above: with Vertical orientation, // the settings gear must NOT be present (Vertical.tsx does not render