rebenitez1802 commented on code in PR #35277:
URL: https://github.com/apache/superset/pull/35277#discussion_r2393277757


##########
superset-frontend/packages/superset-ui-core/src/components/TableCollection/TableCollection.test.tsx:
##########
@@ -206,3 +215,32 @@ test('Bulk selection should work with pagination', () => {
   const checkboxes = screen.getAllByRole('checkbox');
   expect(checkboxes.length).toBeGreaterThan(0);
 });
+
+test('should call setSortBy when clicking sortable column header', () => {
+  const setSortBy = jest.fn();
+  const sortingProps = {
+    ...defaultProps,
+    setSortBy,
+  };
+
+  render(<TableCollection {...sortingProps} />);
+
+  // Target the nested field column (the column that needs the array-to-dot 
conversion)
+  const nestedFieldHeader = screen.getByText('Nested Field');
+  expect(nestedFieldHeader).toBeInTheDocument();
+
+  // Click on the nested field column header to trigger sorting
+  fireEvent.click(nestedFieldHeader);
+
+  // Verify setSortBy was called immediately
+  expect(setSortBy).toHaveBeenCalled();
+
+  const sortCallArgs = setSortBy.mock.calls[0][0];
+  expect(Array.isArray(sortCallArgs)).toBe(true);
+  expect(sortCallArgs[0]).toHaveProperty('id');
+  expect(sortCallArgs[0]).toHaveProperty('desc');
+
+  // Verify the nested field array was converted to dot notation
+  expect(sortCallArgs[0].id).toBe('parent.child');
+  expect(typeof sortCallArgs[0].desc).toBe('boolean');

Review Comment:
   fixed



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