bito-code-review[bot] commented on code in PR #35876:
URL: https://github.com/apache/superset/pull/35876#discussion_r2471157675


##########
superset-frontend/plugins/plugin-chart-echarts/test/Waterfall/transformProps.test.ts:
##########
@@ -39,107 +39,129 @@ const extractSeriesName = (props: 
WaterfallChartTransformedProps) => {
   return series.map(item => item.name);
 };
 
-describe('Waterfall tranformProps', () => {
-  const data = [
-    { year: '2019', name: 'Sylvester', sum: 10 },
-    { year: '2019', name: 'Arnold', sum: 3 },
-    { year: '2020', name: 'Sylvester', sum: -10 },
-    { year: '2020', name: 'Arnold', sum: 5 },
-  ];
+const data = [
+  { year: '2019', name: 'Sylvester', sum: 10 },
+  { year: '2019', name: 'Arnold', sum: 3 },
+  { year: '2020', name: 'Sylvester', sum: -10 },
+  { year: '2020', name: 'Arnold', sum: 5 },
+];
 
-  const formData = {
-    colorScheme: 'bnbColors',
-    datasource: '3__table',
-    x_axis: 'year',
-    metric: 'sum',
-    increaseColor: { r: 0, b: 0, g: 0 },
-    decreaseColor: { r: 0, b: 0, g: 0 },
-    totalColor: { r: 0, b: 0, g: 0 },
-  };
+const formData = {
+  colorScheme: 'bnbColors',
+  datasource: '3__table',
+  x_axis: 'year',
+  metric: 'sum',
+  increaseColor: { r: 0, b: 0, g: 0 },
+  decreaseColor: { r: 0, b: 0, g: 0 },
+  totalColor: { r: 0, b: 0, g: 0 },
+  showTotal: true,
+};
 
-  it('should tranform chart props for viz when breakdown not exist', () => {
-    const chartProps = new ChartProps({
-      formData: { ...formData, series: 'bar' },
-      width: 800,
-      height: 600,
-      queriesData: [
-        {
-          data,
-        },
-      ],
-      theme: supersetTheme,
-    });
-    const transformedProps = transformProps(
-      chartProps as unknown as EchartsWaterfallChartProps,
-    );
-    expect(extractSeries(transformedProps)).toEqual([
-      [0, 8, '-'],
-      [13, '-', '-'],
-      ['-', 5, '-'],
-      ['-', '-', 8],
-    ]);
+test('should tranform chart props for viz when breakdown not exist', () => {
+  const chartProps = new ChartProps({
+    formData: { ...formData, series: 'bar' },
+    width: 800,
+    height: 600,
+    queriesData: [
+      {
+        data,
+      },
+    ],
+    theme: supersetTheme,
   });
+  const transformedProps = transformProps(
+    chartProps as unknown as EchartsWaterfallChartProps,
+  );
+  expect(extractSeries(transformedProps)).toEqual([
+    [0, 8, '-'],
+    [13, '-', '-'],
+    ['-', 5, '-'],
+    ['-', '-', 8],
+  ]);
+});
 
-  it('should tranform chart props for viz when breakdown exist', () => {
-    const chartProps = new ChartProps({
-      formData: { ...formData, groupby: 'name' },
-      width: 800,
-      height: 600,
-      queriesData: [
-        {
-          data,
-        },
-      ],
-      theme: supersetTheme,
-    });
-    const transformedProps = transformProps(
-      chartProps as unknown as EchartsWaterfallChartProps,
-    );
-    expect(extractSeries(transformedProps)).toEqual([
-      [0, 10, '-', 3, 3, '-'],
-      [10, 3, '-', '-', 5, '-'],
-      ['-', '-', '-', 10, '-', '-'],
-      ['-', '-', 13, '-', '-', 8],
-    ]);
+test('should tranform chart props for viz when breakdown exist', () => {
+  const chartProps = new ChartProps({
+    formData: { ...formData, groupby: 'name' },
+    width: 800,
+    height: 600,
+    queriesData: [
+      {
+        data,
+      },
+    ],
+    theme: supersetTheme,
   });
+  const transformedProps = transformProps(
+    chartProps as unknown as EchartsWaterfallChartProps,
+  );
+  expect(extractSeries(transformedProps)).toEqual([
+    [0, 10, '-', 3, 3, '-'],
+    [10, 3, '-', '-', 5, '-'],
+    ['-', '-', '-', 10, '-', '-'],
+    ['-', '-', 13, '-', '-', 8],
+  ]);
+});
 
-  it('renaming series names, checking legend and X axis labels', () => {
-    const chartProps = new ChartProps({
-      formData: {
-        ...formData,
-        increaseLabel: 'sale increase',
-        decreaseLabel: 'sale decrease',
-        totalLabel: 'sale total',
+test('renaming series names, checking legend and X axis labels', () => {
+  const chartProps = new ChartProps({
+    formData: {
+      ...formData,
+      increaseLabel: 'sale increase',
+      decreaseLabel: 'sale decrease',
+      totalLabel: 'sale total',
+    },
+    width: 800,
+    height: 600,
+    queriesData: [
+      {
+        data,
       },
-      width: 800,
-      height: 600,
-      queriesData: [
-        {
-          data,
-        },
-      ],
-      theme: supersetTheme,
-    });
-    const transformedProps = transformProps(
-      chartProps as unknown as EchartsWaterfallChartProps,
-    );
-    expect((transformedProps.echartOptions.legend as any).data).toEqual([
-      'sale increase',
-      'sale decrease',
-      'sale total',
-    ]);
+    ],
+    theme: supersetTheme,
+  });
+  const transformedProps = transformProps(
+    chartProps as unknown as EchartsWaterfallChartProps,
+  );
+  expect((transformedProps.echartOptions.legend as any).data).toEqual([
+    'sale increase',
+    'sale decrease',
+    'sale total',
+  ]);
 
-    expect((transformedProps.echartOptions.xAxis as any).data).toEqual([
-      '2019',
-      '2020',
-      'sale total',
-    ]);
+  expect((transformedProps.echartOptions.xAxis as any).data).toEqual([
+    '2019',
+    '2020',
+    'sale total',
+  ]);
 
-    expect(extractSeriesName(transformedProps)).toEqual([
-      'Assist',
-      'sale increase',
-      'sale decrease',
-      'sale total',
-    ]);
+  expect(extractSeriesName(transformedProps)).toEqual([
+    'Assist',
+    'sale increase',
+    'sale decrease',
+    'sale total',
+  ]);
+});
+
+test('hide totals', () => {
+  const chartProps = new ChartProps({
+    formData: { ...formData, series: 'bar', show_total: false },

Review Comment:
   
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Wrong property name in test override</b></div>
   <div id="fix">
   
   The new test 'hide totals' uses `show_total: false` to override the 
formData, but the actual property name in the transformProps function is 
`showTotal` (camelCase). This mismatch means the override won't work, causing 
the test to fail since totals will still be shown. The `transformProps` 
function relies on `showTotal` from formData to control whether total columns 
are included in the chart data, and with this incorrect property name, the 
test's expectation of hiding totals won't be met.
   </div>
   
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ````suggestion
       formData: { ...formData, series: 'bar', showTotal: false },
   ````
   
   </div>
   </details>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run <a 
href=https://github.com/apache/superset/pull/35876#issuecomment-3458589427>#4ed9b7</a></i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



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