rusackas commented on code in PR #37625:
URL: https://github.com/apache/superset/pull/37625#discussion_r2770120513
##########
superset-frontend/src/explore/components/ExploreChartHeader/ExploreChartHeader.test.tsx:
##########
@@ -56,90 +55,99 @@ const mockExportCurrentViewBehavior = () => {
} as any);
};
-const createProps = (additionalProps = {}) => ({
- chart: {
- id: 1,
- latestQueryFormData: {
- viz_type: VizType.Histogram,
- datasource: '49__table',
- slice_id: 318,
- url_params: {},
- granularity_sqla: 'time_start',
- time_range: 'No filter',
- all_columns_x: ['age'],
- adhoc_filters: [],
- row_limit: 10000,
- groupby: null,
- color_scheme: 'supersetColors',
- label_colors: {},
- link_length: '25',
- x_axis_label: 'age',
- y_axis_label: 'count',
- server_pagination: false as any,
+const createProps = (additionalProps = {}) =>
+ ({
+ chart: {
+ id: 1,
+ latestQueryFormData: {
+ viz_type: VizType.Histogram,
+ datasource: '49__table',
+ slice_id: 318,
+ url_params: {},
+ granularity_sqla: 'time_start',
+ time_range: 'No filter',
+ all_columns_x: ['age'],
+ adhoc_filters: [],
+ row_limit: 10000,
+ groupby: null,
+ color_scheme: 'supersetColors',
+ label_colors: {},
+ link_length: '25',
+ x_axis_label: 'age',
+ y_axis_label: 'count',
+ server_pagination: false,
+ },
+ chartStatus: 'rendered' as const,
+ chartAlert: null,
+ chartUpdateEndTime: null,
+ chartUpdateStartTime: 0,
+ lastRendered: 0,
+ sliceFormData: null,
+ queryController: null,
+ queriesResponse: null,
+ triggerQuery: false,
},
- chartStatus: 'rendered',
- },
- slice: {
- cache_timeout: null,
- changed_on: '2021-03-19T16:30:56.750230',
- changed_on_humanized: '7 days ago',
- datasource: 'FCC 2018 Survey',
- description: 'Simple description',
- description_markeddown: '',
- edit_url: '/chart/edit/318',
- form_data: {
- adhoc_filters: [],
- all_columns_x: ['age'],
- color_scheme: 'supersetColors',
- datasource: '49__table',
- granularity_sqla: 'time_start',
- groupby: null,
- label_colors: {},
- link_length: '25',
- queryFields: { groupby: 'groupby' },
- row_limit: 10000,
+ slice: {
+ cache_timeout: null,
+ changed_on: '2021-03-19T16:30:56.750230',
+ changed_on_humanized: '7 days ago',
+ datasource: 'FCC 2018 Survey',
+ description: 'Simple description',
+ description_markeddown: '',
+ edit_url: '/chart/edit/318',
+ form_data: {
+ adhoc_filters: [],
+ all_columns_x: ['age'],
+ color_scheme: 'supersetColors',
+ datasource: '49__table',
+ granularity_sqla: 'time_start',
+ groupby: null,
+ label_colors: {},
+ link_length: '25',
+ queryFields: { groupby: 'groupby' },
+ row_limit: 10000,
+ slice_id: 318,
+ time_range: 'No filter',
+ url_params: {},
+ viz_type: VizType.Histogram,
+ x_axis_label: 'age',
+ y_axis_label: 'count',
+ },
+ modified: '<span class="no-wrap">7 days ago</span>',
+ owners: [
+ {
+ text: 'Superset Admin',
+ value: 1,
+ },
+ ],
slice_id: 318,
- time_range: 'No filter',
- url_params: {},
- viz_type: VizType.Histogram,
- x_axis_label: 'age',
- y_axis_label: 'count',
+ slice_name: 'Age distribution of respondents',
+ slice_url: '/explore/?form_data=%7B%22slice_id%22%3A%20318%7D',
},
- modified: '<span class="no-wrap">7 days ago</span>',
- owners: [
- {
- text: 'Superset Admin',
- value: 1,
- },
- ],
- slice_id: 318,
- slice_name: 'Age distribution of respondents',
- slice_url: '/explore/?form_data=%7B%22slice_id%22%3A%20318%7D',
- },
- slice_name: 'Age distribution of respondents',
- actions: {
- postChartFormData: jest.fn(),
- updateChartTitle: jest.fn(),
- fetchFaveStar: jest.fn(),
- saveFaveStar: jest.fn(),
- redirectSQLLab: jest.fn(),
- },
- user: {
- userId: 1,
- },
- metadata: {
- created_on_humanized: 'a week ago',
- changed_on_humanized: '2 days ago',
- owners: ['John Doe'],
- created_by: 'John Doe',
- changed_by: 'John Doe',
- dashboards: [{ id: 1, dashboard_title: 'Test' }],
- },
- canOverwrite: false,
- canDownload: false,
- isStarred: false,
- ...additionalProps,
-});
+ sliceName: 'Age distribution of respondents',
+ actions: {
+ postChartFormData: jest.fn(),
+ updateChartTitle: jest.fn(),
+ fetchFaveStar: jest.fn(),
+ saveFaveStar: jest.fn(),
+ redirectSQLLab: jest.fn(),
+ },
+ user: {
+ userId: 1,
+ },
+ metadata: {
+ created_on_humanized: 'a week ago',
+ changed_on_humanized: '2 days ago',
+ owners: ['John Doe'],
+ created_by: 'John Doe',
+ changed_by: 'John Doe',
+ dashboards: [{ id: 1, dashboard_title: 'Test' }],
+ },
+ canOverwrite: false,
+ canDownload: false,
+ isStarred: false,
+ ...additionalProps,
+ }) as unknown as ExploreChartHeaderProps;
Review Comment:
Same pattern — the test factory builds partial props and uses `as unknown as
ExploreChartHeaderProps` because constructing a fully valid props object would
require many deeply nested objects (chart state, datasource, actions, etc.)
that aren't relevant to the tests being run.
##########
superset-frontend/src/explore/components/ExploreChartHeader/index.tsx:
##########
@@ -155,23 +176,23 @@ export const ExploreChartHeader = ({
};
const updateSlice = useCallback(
- slice => {
- dispatch(sliceUpdated(slice));
+ (updatedSlice: Slice) => {
+ dispatch(sliceUpdated(updatedSlice));
},
[dispatch],
);
- const handleReportDelete = async report => {
- await dispatch(deleteActiveReport(report));
+ const handleReportDelete = async (report: AlertObject) => {
+ await dispatch(deleteActiveReport(report as unknown as ReportObject));
Review Comment:
The `as unknown as ReportObject` cast is needed because `AlertObject` and
`ReportObject` have overlapping but not identical interfaces. The
`deleteActiveReport` action expects `ReportObject` while the component receives
`AlertObject`. Aligning these types would require updating the report/alert
type hierarchy, which is a broader refactor.
--
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]