bito-code-review[bot] commented on code in PR #42053:
URL: https://github.com/apache/superset/pull/42053#discussion_r3686781851
##########
superset-frontend/packages/superset-ui-chart-controls/test/utils/getColorFormatters.test.ts:
##########
@@ -952,3 +952,76 @@ test('correct column boolean config', () => {
expect(colorFormatters[3].getColorFromValue(true)).toEqual('#FF0000FF');
expect(colorFormatters[3].getColorFromValue(false)).toEqual('#FF0000FF');
});
+
+test('should return hex color when colorScheme is an RGB object', () => {
+ const colorFunction = getColorFunction(
+ {
+ operator: Comparator.None,
+ colorScheme: { r: 255, g: 128, b: 0, a: 1 },
+ column: 'name',
+ },
+ strValues,
+ );
+ expect(colorFunction('Diana')).toEqual('#ff8000FF');
+ expect(colorFunction('Carlos')).toEqual('#ff8000FF');
+ expect(colorFunction('Brian')).toEqual('#ff8000FF');
+});
+
+test('should return token name as-is when colorScheme is a string token', ()
=> {
+ const colorFunction = getColorFunction(
+ {
+ operator: Comparator.None,
+ colorScheme: 'Green',
+ column: 'name',
+ },
+ strValues,
+ );
+ expect(colorFunction('Diana')).toEqual('Green');
+ expect(colorFunction('Carlos')).toEqual('Green');
+ expect(colorFunction('Brian')).toEqual('Green');
+});
+
+test('should return solid hex color when useGradient is false or true', () => {
+ const columnConfig = [
+ {
+ operator: Comparator.GreaterThan,
+ targetValue: 50,
+ colorScheme: { r: 0, g: 47, b: 255, a: 1 },
+ column: 'count',
+ useGradient: false,
+ },
+ {
+ operator: Comparator.GreaterThan,
+ targetValue: 50,
+ colorScheme: { r: 255, g: 166, b: 0, a: 1 },
+ column: 'count',
+ useGradient: true,
+ },
+ ];
+ const colorFormatters = getColorFormatters(columnConfig, mockData);
+ expect(colorFormatters.length).toEqual(2);
+
+ // First formatter with useGradient: false should return solid color
+ expect(colorFormatters[0].column).toEqual('count');
+ expect(colorFormatters[0].getColorFromValue(100)).toEqual('#002fff');
+
+ // Second formatter with useGradient: true should return gradient color
+ expect(colorFormatters[1].column).toEqual('count');
+ expect(colorFormatters[1].getColorFromValue(100)).toEqual('#ffa600FF');
+});
+
+test('should return hex color when colorScheme is an RGB object', () => {
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Duplicate test name</b></div>
<div id="fix">
Duplicate test name at lines 956 and 1013. Both tests share the description
'should return hex color when colorScheme is an RGB object' but test different
code paths (line 956: `getColorFunction` with `None` operator; line 1013:
`getColorFunction` with `GreaterThan` and `alpha=false`). Rename the line 1013
test to avoid confusion.
</div>
</div>
<small><i>Code Review Run #7fd17c</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]