bito-code-review[bot] commented on code in PR #37555:
URL: https://github.com/apache/superset/pull/37555#discussion_r2843289184
##########
superset-frontend/src/components/Datasource/components/DatasourceEditor/components/DatasetUsageTab/DatasetUsageTab.test.tsx:
##########
@@ -547,3 +547,136 @@ test('handles AbortError without setState after unmount',
async () => {
consoleErrorSpy.mockRestore();
});
+
+test('can search charts by chart name', async () => {
+ setupTest();
+
+ await waitFor(() => {
+ expect(screen.getByText('Test Chart 1')).toBeInTheDocument();
+ expect(screen.getByText('Test Chart 2')).toBeInTheDocument();
+ });
+
+ const searchInput = screen.getByPlaceholderText(
+ 'Search charts by name, owner, or dashboard',
+ );
+ expect(searchInput).toBeInTheDocument();
+
+ await userEvent.type(searchInput, 'Chart 1');
+
+ await waitFor(() => {
+ expect(screen.getByText('Test Chart 1')).toBeInTheDocument();
+ expect(screen.queryByText('Test Chart 2')).not.toBeInTheDocument();
+ });
+
+ await userEvent.clear(searchInput);
+
+ await waitFor(() => {
+ expect(screen.getByText('Test Chart 1')).toBeInTheDocument();
+ expect(screen.getByText('Test Chart 2')).toBeInTheDocument();
+ });
+});
+
+test('can search charts by owner name', async () => {
+ setupTest();
+
+ await waitFor(() => {
+ expect(screen.getByText('Test Chart 1')).toBeInTheDocument();
+ });
+
+ const searchInput = screen.getByPlaceholderText(
+ 'Search charts by name, owner, or dashboard',
+ );
+
+ await userEvent.type(searchInput, 'Bob');
+
+ await waitFor(() => {
+ expect(screen.queryByText('Test Chart 1')).not.toBeInTheDocument();
+ expect(screen.getByText('Test Chart 2')).toBeInTheDocument();
+ });
+});
+
+test('can search charts by dashboard title', async () => {
+ setupTest();
+
+ await waitFor(() => {
+ expect(screen.getByText('Test Chart 1')).toBeInTheDocument();
+ });
+
+ const searchInput = screen.getByPlaceholderText(
+ 'Search charts by name, owner, or dashboard',
+ );
+
+ await userEvent.type(searchInput, 'Test Dashboard');
+
+ await waitFor(() => {
+ expect(screen.getByText('Test Chart 1')).toBeInTheDocument();
+ expect(screen.queryByText('Test Chart 2')).not.toBeInTheDocument();
+ });
+});
+
+test('chart search is case-insensitive', async () => {
+ setupTest();
+
+ await waitFor(() => {
+ expect(screen.getByText('Test Chart 1')).toBeInTheDocument();
+ });
+
+ const searchInput = screen.getByPlaceholderText(
+ 'Search charts by name, owner, or dashboard',
+ );
+
+ await userEvent.type(searchInput, 'CHART 1');
+
+ await waitFor(() => {
+ expect(screen.getByText('Test Chart 1')).toBeInTheDocument();
+ expect(screen.queryByText('Test Chart 2')).not.toBeInTheDocument();
+ });
+});
+
+test('shows No items when search has no results', async () => {
+ setupTest();
+
+ await waitFor(() => {
+ expect(screen.getByText('Test Chart 1')).toBeInTheDocument();
+ });
+
+ const searchInput = screen.getByPlaceholderText(
+ 'Search charts by name, owner, or dashboard',
+ );
+
+ await userEvent.type(searchInput, 'nonexistent chart');
+
+ await waitFor(() => {
+ expect(screen.queryByText('Test Chart 1')).not.toBeInTheDocument();
+ expect(screen.queryByText('Test Chart 2')).not.toBeInTheDocument();
+ expect(screen.getByText('No items')).toBeInTheDocument();
+ });
+});
+
+test('updates pagination total when filtering', async () => {
+ setupTest();
+
+ await waitFor(() => {
+ expect(screen.getByText('Test Chart 1')).toBeInTheDocument();
+ });
+
+ const searchInput = screen.getByPlaceholderText(
+ 'Search charts by name, owner, or dashboard',
+ );
+
+ await userEvent.type(searchInput, 'Chart 1');
+
+ // When searching, pagination should reflect filtered count
+ await waitFor(() => {
+ const paginationText = screen.getByText(/1 \/ 1/);
+ expect(paginationText).toBeInTheDocument();
+ });
+
+ await userEvent.clear(searchInput);
+
+ // When not searching, pagination should show total count
+ await waitFor(() => {
+ const paginationText = screen.getByText(/1 \/ 1/);
+ expect(paginationText).toBeInTheDocument();
+ });
+});
Review Comment:
<!-- Bito Reply -->
The comment about the inadequate 'updates pagination total when filtering'
test hasn't been addressed. The PR adds new search tests but doesn't modify the
existing pagination test.
--
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]