From e6bb0f34d4c1dcd1d340f70f11224c67164b8502 Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Thu, 1 Aug 2024 15:29:35 +0100
Subject: [PATCH] Iterate
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
---
.../dialogs/MessageEditHistoryDialog-test.tsx | 3 +-
.../__snapshots__/LogoutDialog-test.tsx.snap | 2 -
.../SpellCheckLanguagesDropdown-test.tsx | 5 +-
.../pollHistory/PollListItemEnded-test.tsx | 4 +-
.../LegacyRoomHeaderButtons-test.tsx | 24 ++++---
.../LayoutSwitcher-test.tsx.snap | 20 +++---
.../ThemeChoicePanel-test.tsx.snap | 72 +++++++++----------
.../SecurityUserSettingsTab-test.tsx.snap | 1 -
.../__snapshots__/SpacePanel-test.tsx.snap | 6 +-
test/test-utils/utilities.ts | 2 +-
10 files changed, 71 insertions(+), 68 deletions(-)
diff --git a/test/components/views/dialogs/MessageEditHistoryDialog-test.tsx b/test/components/views/dialogs/MessageEditHistoryDialog-test.tsx
index 2bd388103d..f306c856f6 100644
--- a/test/components/views/dialogs/MessageEditHistoryDialog-test.tsx
+++ b/test/components/views/dialogs/MessageEditHistoryDialog-test.tsx
@@ -15,7 +15,7 @@ limitations under the License.
*/
import React from "react";
-import { render, RenderResult } from "@testing-library/react";
+import { render, RenderResult, waitForElementToBeRemoved } from "@testing-library/react";
import { EventType, MatrixEvent } from "matrix-js-sdk/src/matrix";
import type { MatrixClient } from "matrix-js-sdk/src/matrix";
@@ -39,6 +39,7 @@ describe("", () => {
async function renderComponent(): Promise {
const result = render();
+ await waitForElementToBeRemoved(() => result.queryByRole("progressbar"));
await flushPromises();
return result;
}
diff --git a/test/components/views/dialogs/__snapshots__/LogoutDialog-test.tsx.snap b/test/components/views/dialogs/__snapshots__/LogoutDialog-test.tsx.snap
index 9d5fd55154..c5db254cb2 100644
--- a/test/components/views/dialogs/__snapshots__/LogoutDialog-test.tsx.snap
+++ b/test/components/views/dialogs/__snapshots__/LogoutDialog-test.tsx.snap
@@ -73,7 +73,6 @@ exports[`LogoutDialog Prompts user to connect backup if there is a backup on the
", () => {
it("renders as expected", async () => {
- const platform: any = { getAvailableSpellCheckLanguages: jest.fn().mockResolvedValue(["en", "de", "qq"]) };
+ const platform: any = {
+ getAvailableSpellCheckLanguages: jest.fn().mockResolvedValue(["en", "de", "qq"]),
+ supportsSetting: jest.fn(),
+ };
PlatformPeg.set(platform);
const { asFragment } = render(
diff --git a/test/components/views/polls/pollHistory/PollListItemEnded-test.tsx b/test/components/views/polls/pollHistory/PollListItemEnded-test.tsx
index 7bf27ee447..8efd0df52a 100644
--- a/test/components/views/polls/pollHistory/PollListItemEnded-test.tsx
+++ b/test/components/views/polls/pollHistory/PollListItemEnded-test.tsx
@@ -15,7 +15,7 @@ limitations under the License.
*/
import React from "react";
-import { render } from "@testing-library/react";
+import { render, waitFor } from "@testing-library/react";
import { MatrixEvent, Poll, Room, M_TEXT } from "matrix-js-sdk/src/matrix";
import { PollListItemEnded } from "../../../../../src/components/views/polls/pollHistory/PollListItemEnded";
@@ -174,7 +174,7 @@ describe("", () => {
]);
// updated with more responses
- expect(getByText("Final result based on 3 votes")).toBeInTheDocument();
+ await waitFor(() => expect(getByText("Final result based on 3 votes")).toBeInTheDocument());
expect(getByText("Nissan Silvia S15")).toBeInTheDocument();
expect(queryByText("Mitsubishi Lancer Evolution IX")).not.toBeInTheDocument();
});
diff --git a/test/components/views/right_panel/LegacyRoomHeaderButtons-test.tsx b/test/components/views/right_panel/LegacyRoomHeaderButtons-test.tsx
index ef42956217..8f352d0fd5 100644
--- a/test/components/views/right_panel/LegacyRoomHeaderButtons-test.tsx
+++ b/test/components/views/right_panel/LegacyRoomHeaderButtons-test.tsx
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-import { render } from "@testing-library/react";
+import { render, waitFor } from "@testing-library/react";
import {
MatrixEvent,
MsgType,
@@ -79,21 +79,23 @@ describe("LegacyRoomHeaderButtons-test.tsx", function () {
expect(container.querySelector(".mx_RightPanel_threadsButton .mx_Indicator")).toBeNull();
});
- it("thread notification does change the thread button", () => {
+ it("thread notification does change the thread button", async () => {
const { container } = getComponent(room);
expect(getThreadButton(container)!.className.includes("mx_LegacyRoomHeader_button--unread")).toBeFalsy();
room.setThreadUnreadNotificationCount("$123", NotificationCountType.Total, 1);
- expect(getThreadButton(container)!.className.includes("mx_LegacyRoomHeader_button--unread")).toBeTruthy();
- expect(isIndicatorOfType(container, "notification")).toBe(true);
+ await waitFor(() => {
+ expect(getThreadButton(container)!.className.includes("mx_LegacyRoomHeader_button--unread")).toBeTruthy();
+ expect(isIndicatorOfType(container, "notification")).toBe(true);
+ });
room.setThreadUnreadNotificationCount("$123", NotificationCountType.Highlight, 1);
- expect(isIndicatorOfType(container, "highlight")).toBe(true);
+ await waitFor(() => expect(isIndicatorOfType(container, "highlight")).toBe(true));
room.setThreadUnreadNotificationCount("$123", NotificationCountType.Total, 0);
room.setThreadUnreadNotificationCount("$123", NotificationCountType.Highlight, 0);
- expect(container.querySelector(".mx_RightPanel_threadsButton .mx_Indicator")).toBeNull();
+ await waitFor(() => expect(container.querySelector(".mx_RightPanel_threadsButton .mx_Indicator")).toBeNull());
});
it("thread activity does change the thread button", async () => {
@@ -122,7 +124,7 @@ describe("LegacyRoomHeaderButtons-test.tsx", function () {
},
});
room.addReceipt(receipt);
- expect(isIndicatorOfType(container, "activity")).toBe(true);
+ await waitFor(() => expect(isIndicatorOfType(container, "activity")).toBe(true));
// Sending the last event should clear the notification.
let event = mkEvent({
@@ -140,7 +142,7 @@ describe("LegacyRoomHeaderButtons-test.tsx", function () {
},
});
room.addLiveEvents([event]);
- expect(container.querySelector(".mx_RightPanel_threadsButton .mx_Indicator")).toBeNull();
+ await waitFor(() => expect(container.querySelector(".mx_RightPanel_threadsButton .mx_Indicator")).toBeNull());
// Mark it as unread again.
event = mkEvent({
@@ -158,7 +160,7 @@ describe("LegacyRoomHeaderButtons-test.tsx", function () {
},
});
room.addLiveEvents([event]);
- expect(isIndicatorOfType(container, "activity")).toBe(true);
+ await waitFor(() => expect(isIndicatorOfType(container, "activity")).toBe(true));
// Sending a read receipt on an earlier event shouldn't do anything.
receipt = new MatrixEvent({
@@ -173,7 +175,7 @@ describe("LegacyRoomHeaderButtons-test.tsx", function () {
},
});
room.addReceipt(receipt);
- expect(isIndicatorOfType(container, "activity")).toBe(true);
+ await waitFor(() => expect(isIndicatorOfType(container, "activity")).toBe(true));
// Sending a receipt on the latest event should clear the notification.
receipt = new MatrixEvent({
@@ -188,6 +190,6 @@ describe("LegacyRoomHeaderButtons-test.tsx", function () {
},
});
room.addReceipt(receipt);
- expect(container.querySelector(".mx_RightPanel_threadsButton .mx_Indicator")).toBeNull();
+ await waitFor(() => expect(container.querySelector(".mx_RightPanel_threadsButton .mx_Indicator")).toBeNull());
});
});
diff --git a/test/components/views/settings/__snapshots__/LayoutSwitcher-test.tsx.snap b/test/components/views/settings/__snapshots__/LayoutSwitcher-test.tsx.snap
index 6c7bec7cf1..9df169a133 100644
--- a/test/components/views/settings/__snapshots__/LayoutSwitcher-test.tsx.snap
+++ b/test/components/views/settings/__snapshots__/LayoutSwitcher-test.tsx.snap
@@ -27,7 +27,7 @@ exports[` should render 1`] = `