SBIN2010 commented on code in PR #45680:
URL: https://github.com/apache/superset/pull/45680#discussion_r4406275600


##########
superset-frontend/plugins/plugin-chart-echarts/test/Waterfall/transformProps.test.ts:
##########
@@ -219,3 +222,65 @@ test('reclaims the left grid margin when the Y axis is 
hidden', () => {
   expect(hidden.left).toBeLessThan(shown.left);
   expect(hidden.bottom).toBe(shown.bottom);
 });
+
+test('renders an empty chart when the query result is missing', () => {
+  expect(() =>
+    transformProps(
+      new ChartProps({
+        formData: formData as unknown as SqlaFormData,
+        width: 800,
+        height: 600,
+        queriesData: [],
+        theme: supersetTheme,
+      }) as unknown as EchartsWaterfallChartProps,
+    ),
+  ).not.toThrow();
+});
+
+test('dims bars outside the selected period and uses a pointer cursor', () => {
+  const transformedProps = transformProps(
+    new ChartProps({
+      formData: formData as unknown as SqlaFormData,
+      width: 800,
+      height: 600,
+      queriesData: [{ data }],
+      filterState: { selectedValues: [JSON.stringify(['2019'])] },
+      emitCrossFilters: true,
+      theme: supersetTheme,
+    }) as unknown as EchartsWaterfallChartProps,
+  );
+  const series = transformedProps.echartOptions.series as BarSeriesOption[];
+  expect(series[0]?.cursor).toBe('pointer');
+  const increase = series[1]?.data as Array<{
+    value: number | string;
+    itemStyle?: { opacity?: number };
+  }>;
+  expect(transformedProps.categories[0]).toBeDefined();
+  expect(getWaterfallCrossFilterKey(transformedProps.categories[0]!)).toBe(
+    JSON.stringify(['2019']),
+  );
+  expect(increase[0]?.itemStyle?.opacity).toBeUndefined();
+  const decrease = series[2]?.data as Array<{
+    itemStyle?: { opacity?: number };
+  }>;
+  expect(decrease[1]?.itemStyle?.opacity).toBe(OpacityEnum.SemiTransparent);
+  const total = series[3]?.data as Array<{
+    itemStyle?: { opacity?: number };
+  }>;
+  expect(total[2]?.itemStyle?.opacity).toBe(OpacityEnum.SemiTransparent);
+});
+
+test('uses the default cursor when cross-filtering is off', () => {

Review Comment:
   Test Added – it passes `emitCrossFilters: false` and the selection `2019`. 
The `2019` column remains bright, while the `2020` column is set to an opacity 
of 0.3.



-- 
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]

Reply via email to