rusackas commented on code in PR #32958:
URL: https://github.com/apache/superset/pull/32958#discussion_r3717354383
##########
superset-frontend/src/dashboard/components/gridComponents/Chart/Chart.test.tsx:
##########
@@ -145,17 +145,80 @@ test('should render a ChartContainer', () => {
expect(getByTestId('chart-container')).toBeInTheDocument();
});
-test('should render a description if it has one and isExpanded=true', () => {
- const { container } = setup(
- {},
- {
- dashboardState: {
- ...defaultState.dashboardState,
- expandedSlices: { [props.id]: true },
- },
- },
- );
- expect(container.querySelector('.slice_description')).toBeInTheDocument();
+describe('no description set', () => {
+ for (const sliceExpanded of [undefined, false, true]) {
+ for (const allExpanded of [undefined, false, true]) {
+ test(`should not render a description, expandedSlices=${sliceExpanded}
and expandAllSlices=${allExpanded}`, () => {
+ const { container } = setup(
+ {},
+ {
+ dashboardState: {
+ ...defaultState.dashboardState,
+ expandedSlices: { [props.id]: sliceExpanded },
+ expandAllSlices: allExpanded,
+ },
+ sliceEntities: {
+ ...sliceEntities,
+ slices: {
+ [queryId]: {
+ ...sliceEntities.slices[queryId],
+ description_markeddown: undefined,
+ owners: [],
+ viz_type: VizType.Table,
+ },
+ },
+ },
+ },
+ );
+ expect(
+ container.querySelector('.slice_description'),
+ ).not.toBeInTheDocument();
+ });
+ }
+ }
+});
+
+describe('description set', () => {
+ const chartDescriptionRenderInputs = [
+ { expandSlice: undefined, expandAllSlices: undefined, result: false },
+ { expandSlice: undefined, expandAllSlices: false, result: false },
+ { expandSlice: undefined, expandAllSlices: true, result: true },
+ { expandSlice: false, expandAllSlices: undefined, result: false },
+ { expandSlice: false, expandAllSlices: false, result: false },
+ { expandSlice: false, expandAllSlices: true, result: false },
+ { expandSlice: true, expandAllSlices: undefined, result: true },
+ { expandSlice: true, expandAllSlices: false, result: true },
+ { expandSlice: true, expandAllSlices: true, result: true },
+ ];
+
+ for (const {
+ expandSlice,
+ expandAllSlices,
+ result,
+ } of chartDescriptionRenderInputs) {
+ test(`should ${result ? '' : 'not '}render a description if it has one,
expandedSlices=${expandSlice} and expandAllSlices=${expandAllSlices}`, () => {
+ const { container } = setup(
+ {},
+ {
+ dashboardState: {
+ ...defaultState.dashboardState,
+ expandedSlices: { [props.id]: expandSlice },
+ expandAllSlices,
+ },
+ },
+ );
+
+ if (result) {
+ expect(
+ container.querySelector('.slice_description'),
+ ).toBeInTheDocument();
+ } else {
+ expect(
+ container.querySelector('.slice_description'),
+ ).not.toBeInTheDocument();
+ }
+ });
+ }
});
Review Comment:
Same fix covers this one too.
--
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]