[#311] preserve input on unfocus in peopleSearch (#346)

Co-authored-by: Camille Moussu <cmoussu@linagora.com>
This commit is contained in:
Camille Moussu
2025-11-19 16:09:09 +01:00
committed by GitHub
parent ca2e8a479a
commit 8e7b6e18eb
2 changed files with 38 additions and 1 deletions
+31
View File
@@ -216,4 +216,35 @@ describe("PeopleSearch", () => {
await searchPromise;
});
});
it("retains input value when field loses focus (blur)", async () => {
let resolveSearch: (value: User[]) => void;
const searchPromise = new Promise<User[]>((resolve) => {
resolveSearch = resolve;
});
mockedSearchUsers.mockReturnValueOnce(searchPromise);
await act(async () => {
setup();
});
const input = screen.getByRole("combobox");
await act(async () => {
userEvent.type(input, "Test");
});
await waitFor(() => {
expect(mockedSearchUsers).toHaveBeenCalledWith("Test", ["user"]);
});
expect(input).toHaveValue("Test");
await act(async () => {
input.blur();
});
await waitFor(() => {
expect(input).toHaveValue("Test");
});
});
});