VinayaKumar12 commented on code in PR #37517:
URL: https://github.com/apache/superset/pull/37517#discussion_r2744757315


##########
superset-frontend/src/explore/reducers/exploreReducer.test.js:
##########
@@ -43,3 +43,53 @@ test('skips updates when the field is already updated on 
SET_STASH_FORM_DATA', (
   const newState = exploreReducer(initialState, restoreAction);
   expect(newState).toBe(initialState);
 });
+
+test('normalizes server_page_length from string to number on SET_FIELD_VALUE', 
() => {
+  const initialState = {
+    form_data: { viz_type: 'table' },
+    controls: {},
+  };
+  
+  const action = setControlValue('server_page_length', '100');
+  const newState = exploreReducer(initialState, action);
+  
+  expect(newState.form_data.server_page_length).toBe(100);
+  expect(typeof newState.form_data.server_page_length).toBe('number');
+});
+
+test('preserves server_page_length when already numeric', () => {
+  const initialState = {
+    form_data: { viz_type: 'table' },
+    controls: {},
+  };
+  
+  const action = setControlValue('server_page_length', 100);
+  const newState = exploreReducer(initialState, action);
+  
+  expect(newState.form_data.server_page_length).toBe(100);
+});
+
+test('does not normalize other string control values', () => {
+  const initialState = {
+    form_data: { viz_type: 'table' },
+    controls: {},
+  };
+  
+  const action = setControlValue('row_limit', '50');
+  const newState = exploreReducer(initialState, action);
+  
+  expect(newState.form_data.row_limit).toBe('50');
+});
+
+test('normalizes server_page_length from string "0" to number 0', () => {
+  const initialState = {
+    form_data: { viz_type: 'table' },
+    controls: {},
+  };
+
+  const action = setControlValue('server_page_length', '0');
+  const newState = exploreReducer(initialState, action);
+
+  expect(newState.form_data.server_page_length).toBe(0);
+  expect(typeof newState.form_data.server_page_length).toBe('number');
+});

Review Comment:
   New test cases are added to cover the scenarios.



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