Fix flaky Jest test: RoomView search results (#31785)

Signed-off-by: aditya-cherukuru <cherukuru.aditya01@gmail.com>
This commit is contained in:
Aditya Cherukuru 2026-01-19 19:01:48 +05:30 committed by GitHub
parent 3b08b5c582
commit 93a8b67ed0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -24,16 +24,7 @@ import {
} from "matrix-js-sdk/src/matrix";
import { type CryptoApi, CryptoEvent, UserVerificationStatus } from "matrix-js-sdk/src/crypto-api";
import { KnownMembership } from "matrix-js-sdk/src/types";
import {
act,
cleanup,
fireEvent,
render,
type RenderResult,
screen,
waitFor,
waitForElementToBeRemoved,
} from "jest-matrix-react";
import { act, cleanup, fireEvent, render, type RenderResult, screen, waitFor } from "jest-matrix-react";
import userEvent from "@testing-library/user-event";
import {
@ -872,12 +863,13 @@ describe("RoomView", () => {
await waitFor(() => {
expect(container.querySelector(".mx_RoomView_searchResultsPanel")).toBeVisible();
});
const prom = waitForElementToBeRemoved(() => container.querySelector(".mx_RoomView_searchResultsPanel"));
await userEvent.hover(getByText("search term"));
await userEvent.click(await findByLabelText("Edit"));
await prom;
await waitFor(() => {
expect(container.querySelector(".mx_RoomView_searchResultsPanel")).not.toBeInTheDocument();
});
});
it("should switch rooms when edit is clicked on a search result for a different room", async () => {