sadpandajoe commented on code in PR #38865:
URL: https://github.com/apache/superset/pull/38865#discussion_r4349808274
##########
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:
This edit-mode assertion passes even if edit mode wrongly shows the
filter-resolved title. The filter is cleared a few lines above (line 171), so
`displayTitle` and `baseTitle` are both "Revenue" here and nothing
distinguishes them. Could the test keep Portugal applied, switch to `editMode`,
and assert the header reads exactly "Revenue" (then "Revenue in Portugal" after
leaving edit mode)?
--
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]