EnxDev commented on code in PR #44068:
URL: https://github.com/apache/superset/pull/44068#discussion_r4131204035
##########
superset-frontend/src/components/Chart/DrillBy/useResultsTableView.test.ts:
##########
@@ -104,3 +104,43 @@ test('Displays results for 2 queries', async () => {
});
expect(screen.getByText('boy')).toBeInTheDocument();
});
+
+const MOCK_CHART_DATA_RESULT_WITH_ROWCOUNTS = [
+ { ...MOCK_CHART_DATA_RESULT[0], rowcount: 4, sql_rowcount: 57 },
+ { ...MOCK_CHART_DATA_RESULT[1], rowcount: 2, sql_rowcount: 42 },
+];
+
+test('Uses rowcount instead of sql_rowcount for 1 query', () => {
+ const { result } = renderHook(() =>
+ useResultsTableView(
+ MOCK_CHART_DATA_RESULT_WITH_ROWCOUNTS.slice(0, 1),
+ '1__table',
+ true,
+ ),
+ );
+ render(result.current, { useRedux: true });
+
+ expect(screen.getByText('4 rows')).toBeInTheDocument();
+ expect(screen.queryByText('57 rows')).not.toBeInTheDocument();
+});
+
+test('Uses rowcount instead of sql_rowcount for each of multiple queries',
async () => {
+ const { result } = renderHook(() =>
+ useResultsTableView(
+ MOCK_CHART_DATA_RESULT_WITH_ROWCOUNTS,
+ '1__table',
+ true,
+ ),
+ );
+ render(result.current, { useRedux: true });
+
+ expect(screen.getByText('4 rows')).toBeInTheDocument();
+ expect(screen.queryByText('57 rows')).not.toBeInTheDocument();
+
+ userEvent.click(screen.getByText('Results 2'));
Review Comment:
Nit, take it or leave it. The click isn't awaited here, unlike the test
above.
`waitFor` covers it so it passes, but user-event v14 returns a promise and a
floating one tends to leave act() warnings behind.
```suggestion
await userEvent.click(screen.getByText('Results 2'));
```
--
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]