mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-11 22:51:28 +00:00
test(ui): await handleSearch completion in SearchToolTester tests
Wait for the async search operation to fully settle before ending tests that fire handleSearch without checking downstream results. The finally block's setIsLoading(false) was racing with test-file JSDOM teardown, leaking a 'window is not defined' error from React's requestUpdateLane after the environment was gone and failing the whole UI Unit Tests job. Co-authored-by: Krrish Dholakia <krrish-berri-2@users.noreply.github.com>
This commit is contained in:
parent
40a418440c
commit
8d139fe706
1 changed files with 4 additions and 0 deletions
|
|
@ -93,6 +93,7 @@ describe("SearchToolTester", () => {
|
|||
const searchButton = screen.getByRole("button", { name: /search/i });
|
||||
await user.click(searchButton);
|
||||
expect(networking.searchToolQueryCall).toHaveBeenCalledWith("test-token", "test-search-tool", "test query");
|
||||
await waitFor(() => expect(searchButton).not.toBeDisabled());
|
||||
});
|
||||
|
||||
it("should call searchToolQueryCall when Enter is pressed in input", async () => {
|
||||
|
|
@ -101,6 +102,7 @@ describe("SearchToolTester", () => {
|
|||
const input = screen.getByPlaceholderText("Enter your search query...");
|
||||
await user.type(input, "test query{Enter}");
|
||||
expect(networking.searchToolQueryCall).toHaveBeenCalledWith("test-token", "test-search-tool", "test query");
|
||||
await waitFor(() => expect(input).not.toBeDisabled());
|
||||
});
|
||||
|
||||
it("should not call searchToolQueryCall when Shift+Enter is pressed", async () => {
|
||||
|
|
@ -123,6 +125,7 @@ describe("SearchToolTester", () => {
|
|||
const searchButton = screen.getByRole("button", { name: /search/i });
|
||||
await user.click(searchButton);
|
||||
expect(screen.getByText("Searching...")).toBeInTheDocument();
|
||||
await waitFor(() => expect(screen.queryByText("Searching...")).not.toBeInTheDocument());
|
||||
});
|
||||
|
||||
it("should display search results after successful search", async () => {
|
||||
|
|
@ -407,6 +410,7 @@ describe("SearchToolTester", () => {
|
|||
await user.click(searchButton);
|
||||
expect(input).toBeDisabled();
|
||||
expect(searchButton).toBeDisabled();
|
||||
await waitFor(() => expect(input).not.toBeDisabled());
|
||||
});
|
||||
|
||||
it("should display result links that open in new tab", async () => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue