rabumaabraham commented on code in PR #44803:
URL: https://github.com/apache/superset/pull/44803#discussion_r4161396085
##########
superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterBar.test.tsx:
##########
@@ -1411,3 +1413,73 @@ test('FilterBar with orientation=Vertical renders
Vertical layout (sanity counte
screen.queryByRole('img', { name: 'setting' }),
).not.toBeInTheDocument();
});
+
+test('FilterBar keeps a configured filter selected when its applied data mask
is removed', async () => {
+ fetchMock.post(
+ 'glob:*/api/v1/chart/data',
+ {
+ result: [
+ {
+ data: [{ region: 'East' }, { region: 'West' }],
+ colnames: ['region'],
+ coltypes: [1],
+ applied_filters: [],
+ },
+ ],
+ },
+ { name: 'configured-filter-selected-chart-data' },
+ );
+
+ const filterId = 'NATIVE_FILTER-keep-selected';
+ const filter = createFilter({
+ id: filterId,
+ name: 'Region',
+ filterType: 'filter_select',
+ targets: [{ datasetId: 7, column: { name: 'region' } }],
+ chartsInScope: [18],
+ });
+
+ const state = createStateWithFilter(
+ filter,
+ createDataMask(filterId, ['East'], {
+ filters: [{ col: 'region', op: 'IN', val: ['East'] }],
+ }),
+ {
+ filterBarOrientation: FilterBarOrientation.Vertical,
+ metadata: {
+ native_filter_configuration: [filter],
+ chart_configuration: {},
+ },
+ },
+ );
+
+ const store = createStore(state, reducerIndex);
+
+ render(
+ <FilterBar
+ orientation={FilterBarOrientation.Vertical}
+ verticalConfig={{
+ width: 280,
+ height: 400,
+ offset: 0,
+ ...createOpenedBarProps(),
+ }}
+ />,
+ { store, useDnd: true, useRouter: true },
+ );
+
+ await act(async () => {
+ jest.advanceTimersByTime(1000);
+ });
+
+ expect(screen.getByText('Region')).toBeInTheDocument();
+ expect(screen.getByTitle('East')).toBeInTheDocument();
+
+ await act(async () => {
Review Comment:
Updated the test to cover the actual time-filter flow you mentioned.
It now selects **Current month** from the time filter, checks that Apply is
enabled, verifies the applied Redux state and displayed label, and also covers
Clear All.
I also checked it against the base commit. It fails on base and passes with
the fix. The full FilterBar test suite passes 31/31.
This is included in `7b37b916d2`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]