rusackas commented on code in PR #34742:
URL: https://github.com/apache/superset/pull/34742#discussion_r3358052835


##########
superset-frontend/src/filters/components/Range/RangeFilterPlugin.test.tsx:
##########
@@ -320,4 +320,127 @@ describe('RangeFilterPlugin', () => {
       expect(sliders.length).toBeGreaterThan(0);
     });
   });
+
+  describe('Decimal value handling', () => {
+    test('should handle decimal ranges correctly (0.03 to 1.08)', () => {
+      const decimalProps = {
+        queriesData: [
+          {
+            rowcount: 1,
+            colnames: ['min', 'max'],
+            coltypes: [GenericDataType.Numeric, GenericDataType.Numeric],
+            data: [{ min: 0.03, max: 1.08 }],
+            applied_filters: [],
+            rejected_filters: [],
+          },
+        ],
+        filterState: { value: [0.5, 0.8] },
+      };
+      getWrapper(decimalProps);
+
+      const inputs = screen.getAllByRole('spinbutton');
+      expect(inputs).toHaveLength(2);
+      expect(inputs[0]).toHaveValue('0.5');
+      expect(inputs[1]).toHaveValue('0.8');
+
+      // Verify the slider exists and can handle decimal values
+      const sliders = screen.getAllByRole('slider');
+      expect(sliders.length).toBeGreaterThan(0);
+    });
+
+    test('should calculate appropriate step size for small decimal ranges', () 
=> {
+      const smallRangeProps = {
+        queriesData: [
+          {
+            rowcount: 1,
+            colnames: ['min', 'max'],
+            coltypes: [GenericDataType.Numeric, GenericDataType.Numeric],
+            data: [{ min: 0.001, max: 0.01 }],
+            applied_filters: [],
+            rejected_filters: [],
+          },
+        ],
+        filterState: { value: [0.005, 0.008] },
+      };
+      getWrapper(smallRangeProps);
+
+      const inputs = screen.getAllByRole('spinbutton');
+      expect(inputs[0]).toHaveValue('0.005');
+      expect(inputs[1]).toHaveValue('0.008');

Review Comment:
   Good call — I extracted `calculateStep` into a module-level exported pure 
function and added direct unit tests that assert its output (integer ranges, 
small/large decimal ranges, the `0.05`–`0.07` floating-point case, 
negative/offset ranges, the tiny-range non-zero guard, and the non-positive 
fallback). A regression in the step calculation will now be caught directly 
rather than relying on input-field assertions.



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