geido commented on code in PR #35277:
URL: https://github.com/apache/superset/pull/35277#discussion_r2379417009
##########
superset-frontend/packages/superset-ui-core/src/components/TableCollection/TableCollection.test.tsx:
##########
@@ -206,3 +206,67 @@ test('Bulk selection should work with pagination', () => {
const checkboxes = screen.getAllByRole('checkbox');
expect(checkboxes.length).toBeGreaterThan(0);
});
+
+test('handleTableChange should convert array field to dot notation for nested
fields', () => {
+ const setSortBy = jest.fn();
+ const sortingProps = {
+ ...defaultProps,
+ setSortBy,
+ };
+
+ const component = render(<TableCollection {...sortingProps} />);
+
+ // Get the Table component instance
+ const table = component.container.querySelector('.ant-table');
Review Comment:
Can we use roles wherever possible? See
[wiki](https://github.com/apache/superset/wiki/Testing-Guidelines-and-Best-Practices#be-specific-when-using-byrole)
##########
superset-frontend/packages/superset-ui-core/src/components/TableCollection/TableCollection.test.tsx:
##########
@@ -206,3 +206,67 @@ test('Bulk selection should work with pagination', () => {
const checkboxes = screen.getAllByRole('checkbox');
expect(checkboxes.length).toBeGreaterThan(0);
});
+
+test('handleTableChange should convert array field to dot notation for nested
fields', () => {
+ const setSortBy = jest.fn();
+ const sortingProps = {
+ ...defaultProps,
+ setSortBy,
+ };
+
+ const component = render(<TableCollection {...sortingProps} />);
+
+ // Get the Table component instance
+ const table = component.container.querySelector('.ant-table');
+ expect(table).toBeInTheDocument();
+
+ // Simulate the handleTableChange function behavior directly
+ // This tests the logic without requiring actual table interaction
+ const mockSorter = {
+ field: ['database', 'database_name'], // Array format from AntD
+ order: 'descend',
+ };
+
+ // Get the component instance to test the callback logic
+ const handleTableChange = (_pagination: any, _filters: any, sorter: any) => {
Review Comment:
```suggestion
const handleTableChange = (_pagination: any, _filters: any, sorter:
SorterResult) => {
```
--
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]