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


##########
superset-frontend/plugins/plugin-chart-echarts/src/Pie/transformProps.ts:
##########
@@ -180,6 +194,7 @@ export default function transformProps(
   const contributionLabel = getContributionLabel(metricLabel);
   const groupbyLabels = groupby.map(getColumnLabel);
   const minShowLabelAngle = (showLabelsThreshold || 0) * 3.6;
+  const half = sweptAngle <= 180 && startAngle === 180;

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Missing tests for half-mode</b></div>
   <div id="fix">
   
   The new half-mode functionality for pie charts lacks test coverage. Per 
BITO.md rule 6262, tests should verify the actual business logic they claim to 
support. The `half` variable (line 197) controls center positioning and total 
padding, but no tests validate this behavior.
   </div>
   
   
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ```
    --- 
a/superset-frontend/plugins/plugin-chart-echarts/test/Pie/transformProps.test.ts
    +++ 
b/superset-frontend/plugins/plugin-chart-echarts/test/Pie/transformProps.test.ts
    @@ -591,3 +591,58 @@ describe('legend sorting', () => {
         ]);
       });
     });
    +
    +describe('Half pie mode with startAngle and sweptAngle', () => {
    +  const defaultFormData: SqlaFormData = {
    +    colorScheme: 'bnbColors',
    +    datasource: '3__table',
    +    granularity_sqla: 'ds',
    +    metric: 'metric',
    +    groupby: ['category'],
    +    viz_type: 'pie',
    +  };
    +
    +  const getChartProps = (formData: Partial<SqlaFormData>) =>
    +    new ChartProps({
    +      formData: {
    +        ...defaultFormData,
    +        ...formData,
    +      },
    +      width: 800,
    +      height: 600,
    +      queriesData: [{
    +        data: [{ category: 'A', metric: 100 }],
    +      }],
    +      theme: supersetTheme,
    +    });
    +
    +  test('activates half-mode when startAngle=180 and sweptAngle<=180', () 
=> {
    +    const props = getChartProps({ startAngle: 180, sweptAngle: 180 });
    +    const transformed = transformProps(props as EchartsPieChartProps);
    +    const series = transformed.echartOptions.series as PieSeriesOption[];
    +
    +    expect(series[0].center).toEqual(['50%', '70%']);
    +    expect(series[0].startAngle).toBe(180);
    +    expect(series[0].endAngle).toBe(0);
    +  });
    +
    +  test('does not activate half-mode when startAngle=90 with 
sweptAngle=180', () => {
    +    const props = getChartProps({ startAngle: 90, sweptAngle: 180 });
    +    const transformed = transformProps(props as EchartsPieChartProps);
    +    const series = transformed.echartOptions.series as PieSeriesOption[];
    +
    +    expect(series[0].center).toEqual(['50%', '50%']);
    +  });
    +
    +  test('adjusts total value padding in half-mode', () => {
    +    const props = getChartProps({
    +      startAngle: 180,
    +      sweptAngle: 180,
    +      showTotal: true,
    +      donut: true,
    +    });
    +    const transformed = transformProps(props as EchartsPieChartProps);
    +
    +    expect(transformed.echartOptions.graphic).toEqual(
    +      expect.objectContaining({
    +        top: expect.not.stringEqual('middle'),
    +      }),
    +    );
    +  });
    +});
   ```
   
   </div>
   </details>
   
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #762e83</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