joaopedroab commented on code in PR #38865:
URL: https://github.com/apache/superset/pull/38865#discussion_r4350094924
##########
superset-frontend/src/dashboard/components/gridComponents/ChartHolder/ChartHolder.test.tsx:
##########
@@ -118,6 +130,170 @@ describe('ChartHolder', () => {
store,
});
+ test('updates display titles from applied filters and preserves the editable
base title', async () => {
+ const filter = createSelectNativeFilter('country-filter', 'Country');
+ const store = createMockStore({
+ dashboardInfo: {
+ ...mockState.dashboardInfo,
+ metadata: { native_filter_configuration: [filter] },
+ },
+ dashboardLayout: {
+ ...mockState.dashboardLayout,
+ present: {
+ ...mockState.dashboardLayout.present,
+ 'CHART-ID': defaultProps.component,
+ },
+ },
+ dataMask: {
+ [filter.id]: { id: filter.id, filterState: { value: ['Brazil'] } },
+ },
+ });
+ const component = {
+ ...defaultProps.component,
+ meta: {
+ ...defaultProps.component.meta,
+ sliceName: 'Revenue',
+ dynamicTitle: {
+ template: '{{chart_title}} in {{country}}',
+ tokenMappings: { country: filter.id },
+ },
+ },
+ };
+ const { rerender } = renderWrapper(store, { component, isInView: true });
+ expect(screen.getByText('Revenue in Brazil')).toBeVisible();
+ act(() =>
+ store.dispatch(
+ updateDataMask(filter.id, { filterState: { value: ['Portugal'] } }),
+ ),
+ );
+ expect(screen.getByText('Revenue in Portugal')).toBeVisible();
+ act(() =>
+ store.dispatch(updateDataMask(filter.id, { filterState: { value: [] }
})),
+ );
+ expect(screen.getByText('Revenue')).toBeVisible();
+ rerender(
+ <Provider store={store}>
+ <ChartHolder
+ {...defaultProps}
+ component={component}
+ editMode
+ isInView
+ />
+ </Provider>,
+ );
+ expect(screen.getByText('Revenue')).toBeVisible();
Review Comment:
Good catch, thanks! Fixed in 8da0f971ab. The test now keeps Portugal applied
when switching in and out of edit mode, then checks the fallback after clearing
the filter. I also confirmed it catches the regression you described.
--
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]