From 3c5f07201e3ef122cd56442cb8996fe1a48409a6 Mon Sep 17 00:00:00 2001 From: Ronan <33596237+RonanQuigley@users.noreply.github.com> Date: Tue, 18 Jun 2024 08:20:06 +0100 Subject: [PATCH] Tempo: Virtualized search dropdowns for attribute values (#88569) * TraceQL: Make the search field component use the virtualized prop for performance gains * Use act on timers to eliminate warningsd * Update more timers to use act to fix testing library warnings * Fix linting failure * Run make commands --------- Co-authored-by: Joey Tawadrous --- public/api-merged.json | 2 -- .../SearchTraceQLEditor/SearchField.test.tsx | 18 ++++++++--- .../tempo/SearchTraceQLEditor/SearchField.tsx | 6 ++++ .../TraceQLSearch.test.tsx | 32 ++++++++++++++----- public/openapi3.json | 2 -- 5 files changed, 44 insertions(+), 16 deletions(-) diff --git a/public/api-merged.json b/public/api-merged.json index 26cf2ef2017..a0d78eb6f2d 100644 --- a/public/api-merged.json +++ b/public/api-merged.json @@ -19970,7 +19970,6 @@ } }, "State": { - "description": "+enum", "type": "string" }, "Status": { @@ -20730,7 +20729,6 @@ } }, "Type": { - "description": "+enum", "type": "string" }, "TypeMeta": { diff --git a/public/app/plugins/datasource/tempo/SearchTraceQLEditor/SearchField.test.tsx b/public/app/plugins/datasource/tempo/SearchTraceQLEditor/SearchField.test.tsx index dd56e52bd09..6870c0533e0 100644 --- a/public/app/plugins/datasource/tempo/SearchTraceQLEditor/SearchField.test.tsx +++ b/public/app/plugins/datasource/tempo/SearchTraceQLEditor/SearchField.test.tsx @@ -1,4 +1,4 @@ -import { render, screen, waitFor } from '@testing-library/react'; +import { act, render, screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import React from 'react'; @@ -86,20 +86,30 @@ describe('SearchField', () => { if (select) { // Add first value await user.click(select); - jest.advanceTimersByTime(1000); + await act(async () => { + jest.advanceTimersByTime(1000); + }); const driverVal = await screen.findByText('driver'); - await user.click(driverVal); + + await act(async () => { + await user.click(driverVal); + }); expect(updateFilter).toHaveBeenCalledWith({ ...filter, value: ['driver'] }); // Add a second value await user.click(select); - jest.advanceTimersByTime(1000); + + await act(async () => { + jest.advanceTimersByTime(1000); + }); const customerVal = await screen.findByText('customer'); + await user.click(customerVal); expect(updateFilter).toHaveBeenCalledWith({ ...filter, value: ['driver', 'customer'] }); // Remove the first value const firstValRemove = await screen.findAllByLabelText('Remove'); + await user.click(firstValRemove[0]); expect(updateFilter).toHaveBeenCalledWith({ ...filter, value: ['customer'] }); } diff --git a/public/app/plugins/datasource/tempo/SearchTraceQLEditor/SearchField.tsx b/public/app/plugins/datasource/tempo/SearchTraceQLEditor/SearchField.tsx index 59cbb7ef57c..fc558e0c581 100644 --- a/public/app/plugins/datasource/tempo/SearchTraceQLEditor/SearchField.tsx +++ b/public/app/plugins/datasource/tempo/SearchTraceQLEditor/SearchField.tsx @@ -183,6 +183,12 @@ const SearchField = ({ /> {!hideValue && (