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


##########
superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberPeriodOverPeriod/PopKPI.test.tsx:
##########
@@ -0,0 +1,106 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { render, screen } from 'spec/helpers/testing-library';
+import PopKPI from './PopKPI';
+import { PopKPIProps } from './types';
+
+const baseProps: PopKPIProps = {
+  height: 200,
+  width: 400,
+  data: [],
+  metrics: [],
+  metricName: 'Sales',
+  showMetricName: true,
+  headerText: '',
+  boldText: true,
+  bigNumber: '120',
+  prevNumber: '100',
+  valueDifference: '20',
+  percentDifferenceFormattedString: '20%',
+  compType: 'r',
+  percentDifferenceNumber: 0.2,
+  subtitleFontSize: 0.15,
+  shift: '',
+  headerFontSize: 'l',
+  subheaderFontSize: 'm',
+  comparisonColorEnabled: true,
+};
+
+test('renders the up arrow and metric values when the metric increased', () => 
{
+  render(<PopKPI {...baseProps} />);
+
+  expect(screen.getByText('↑')).toBeInTheDocument();
+  expect(screen.getByText('120')).toBeInTheDocument();
+  expect(screen.getByText('Sales')).toBeInTheDocument();
+});
+
+test('renders the down arrow when the metric decreased', () => {
+  render(
+    <PopKPI
+      {...baseProps}
+      percentDifferenceNumber={-0.2}
+      valueDifference="-20"
+    />,
+  );
+
+  expect(screen.getByText('↓')).toBeInTheDocument();
+});

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Unused test prop unasserted</b></div>
   <div id="fix">
   
   The down-arrow test passes `valueDifference="-20"` but never asserts it 
renders, so a regression dropping the delta value would still pass. `PopKPI` 
renders each `symbol_with_value.value` (PopKPI.tsx `SYMBOLS_WITH_VALUES`); add 
`expect(screen.getByText('-20')).toBeInTheDocument()` beside the arrow 
assertion. The value fixtures in `baseProps` ('100', '20%') are likewise never 
asserted.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #1279fd</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



##########
superset-frontend/src/explore/components/controls/BulletRangeColorsControl/index.tsx:
##########
@@ -0,0 +1,114 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { t } from '@apache-superset/core/translation';
+import { styled } from '@apache-superset/core/theme';
+import { Button } from '@superset-ui/core/components';
+import ControlHeader from '../../ControlHeader';
+import ColorPickerControl from '../ColorPickerControl';
+import type { ColorPickerValue } from '../ColorPickerControl';
+import { BulletRangeColorsControlProps } from './types';
+
+const RangeRow = styled.div`
+  display: flex;
+  align-items: center;
+  gap: ${({ theme }) => theme.sizeUnit * 2}px;
+  margin-bottom: ${({ theme }) => theme.sizeUnit}px;
+`;
+
+const RangeLabel = styled.span`
+  min-width: 90px;
+  color: ${({ theme }) => theme.colorTextSecondary};
+  font-size: ${({ theme }) => theme.fontSizeSM}px;
+`;
+
+const parseRanges = (ranges?: string): number[] =>
+  (ranges ?? '')
+    .split(',')
+    .map(part => part.trim())
+    .filter(part => part !== '')
+    .map(Number)
+    .filter(range => Number.isFinite(range));

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Duplicated range parsing</b></div>
   <div id="fix">
   
   `parseRanges` re-implements `tokenizeToNumericArray` in `Bullet/utils.ts` 
(same split/trim/Number/isFinite pipeline). That util's comment explicitly 
requires the two to stay in sync because colors are matched positionally 
against this tokenized list — a divergence would silently misalign 
`range_colors` to thresholds. Consider sharing one tokenizer.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #1279fd</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