1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-08-07 21:23:00 +03:00
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski
2024-08-01 15:29:35 +01:00
parent 6f2dd10873
commit e6bb0f34d4
10 changed files with 71 additions and 68 deletions

View File

@@ -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("<MessageEditHistory />", () => {
async function renderComponent(): Promise<RenderResult> {
const result = render(<MessageEditHistoryDialog mxEvent={event} onFinished={jest.fn()} />);
await waitForElementToBeRemoved(() => result.queryByRole("progressbar"));
await flushPromises();
return result;
}

View File

@@ -73,7 +73,6 @@ exports[`LogoutDialog Prompts user to connect backup if there is a backup on the
</details>
</div>
<div
aria-describedby=":r22:"
aria-label="Close dialog"
class="mx_AccessibleButton mx_Dialog_cancelButton"
role="button"
@@ -161,7 +160,6 @@ exports[`LogoutDialog Prompts user to set up backup if there is no backup on the
</details>
</div>
<div
aria-describedby=":r28:"
aria-label="Close dialog"
class="mx_AccessibleButton mx_Dialog_cancelButton"
role="button"

View File

@@ -22,7 +22,10 @@ import PlatformPeg from "../../../../src/PlatformPeg";
describe("<SpellCheckLanguagesDropdown />", () => {
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(

View File

@@ -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("<PollListItemEnded />", () => {
]);
// 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();
});

View File

@@ -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);
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());
});
});

View File

@@ -27,7 +27,7 @@ exports[`<LayoutSwitcher /> should render 1`] = `
<label
aria-label="Modern"
class="_label_dgy0u_67"
for="radix-0"
for="radix-:r0:"
>
<div
class="mxLayoutSwitcher_LayoutSelector_LayoutRadio_inline"
@@ -38,7 +38,7 @@ exports[`<LayoutSwitcher /> should render 1`] = `
<input
checked=""
class="_input_1vw5h_26"
id="radix-0"
id="radix-:r0:"
name="layout"
title=""
type="radio"
@@ -144,7 +144,7 @@ exports[`<LayoutSwitcher /> should render 1`] = `
<label
aria-label="Message bubbles"
class="_label_dgy0u_67"
for="radix-1"
for="radix-:r9:"
>
<div
class="mxLayoutSwitcher_LayoutSelector_LayoutRadio_inline"
@@ -154,7 +154,7 @@ exports[`<LayoutSwitcher /> should render 1`] = `
>
<input
class="_input_1vw5h_26"
id="radix-1"
id="radix-:r9:"
name="layout"
title=""
type="radio"
@@ -260,7 +260,7 @@ exports[`<LayoutSwitcher /> should render 1`] = `
<label
aria-label="IRC (experimental)"
class="_label_dgy0u_67"
for="radix-2"
for="radix-:ri:"
>
<div
class="mxLayoutSwitcher_LayoutSelector_LayoutRadio_inline"
@@ -270,7 +270,7 @@ exports[`<LayoutSwitcher /> should render 1`] = `
>
<input
class="_input_1vw5h_26"
id="radix-2"
id="radix-:ri:"
name="layout"
title=""
type="radio"
@@ -384,9 +384,9 @@ exports[`<LayoutSwitcher /> should render 1`] = `
class="_container_qnvru_18"
>
<input
aria-describedby="radix-3"
aria-describedby="radix-:rs:"
class="_input_qnvru_32"
id="radix-4"
id="radix-:rr:"
name="compactLayout"
title=""
type="checkbox"
@@ -401,13 +401,13 @@ exports[`<LayoutSwitcher /> should render 1`] = `
>
<label
class="_label_dgy0u_67"
for="radix-4"
for="radix-:rr:"
>
Show compact text and messages
</label>
<span
class="_message_dgy0u_98 _help-message_dgy0u_104"
id="radix-3"
id="radix-:rs:"
>
Modern layout must be selected to use this feature.
</span>

View File

@@ -32,7 +32,7 @@ exports[`<ThemeChoicePanel /> custom theme should display custom theme 1`] = `
>
<input
class="_input_qnvru_32"
id="radix-48"
id="radix-:r20:"
name="systemTheme"
title=""
type="checkbox"
@@ -47,7 +47,7 @@ exports[`<ThemeChoicePanel /> custom theme should display custom theme 1`] = `
>
<label
class="_label_dgy0u_67"
for="radix-48"
for="radix-:r20:"
>
Match system theme
</label>
@@ -69,7 +69,7 @@ exports[`<ThemeChoicePanel /> custom theme should display custom theme 1`] = `
<input
checked=""
class="_input_1vw5h_26"
id="radix-49"
id="radix-:r21:"
name="themeSelector"
title=""
type="radio"
@@ -85,7 +85,7 @@ exports[`<ThemeChoicePanel /> custom theme should display custom theme 1`] = `
>
<label
class="_label_dgy0u_67 mx_ThemeChoicePanel_themeSelector_Label"
for="radix-49"
for="radix-:r21:"
>
Light
</label>
@@ -102,7 +102,7 @@ exports[`<ThemeChoicePanel /> custom theme should display custom theme 1`] = `
>
<input
class="_input_1vw5h_26"
id="radix-50"
id="radix-:r22:"
name="themeSelector"
title=""
type="radio"
@@ -118,7 +118,7 @@ exports[`<ThemeChoicePanel /> custom theme should display custom theme 1`] = `
>
<label
class="_label_dgy0u_67 mx_ThemeChoicePanel_themeSelector_Label"
for="radix-50"
for="radix-:r22:"
>
Dark
</label>
@@ -135,7 +135,7 @@ exports[`<ThemeChoicePanel /> custom theme should display custom theme 1`] = `
>
<input
class="_input_1vw5h_26"
id="radix-51"
id="radix-:r23:"
name="themeSelector"
title=""
type="radio"
@@ -151,7 +151,7 @@ exports[`<ThemeChoicePanel /> custom theme should display custom theme 1`] = `
>
<label
class="_label_dgy0u_67 mx_ThemeChoicePanel_themeSelector_Label"
for="radix-51"
for="radix-:r23:"
>
High contrast
</label>
@@ -168,7 +168,7 @@ exports[`<ThemeChoicePanel /> custom theme should display custom theme 1`] = `
>
<input
class="_input_1vw5h_26"
id="radix-52"
id="radix-:r24:"
name="themeSelector"
title=""
type="radio"
@@ -184,7 +184,7 @@ exports[`<ThemeChoicePanel /> custom theme should display custom theme 1`] = `
>
<label
class="_label_dgy0u_67 mx_ThemeChoicePanel_themeSelector_Label"
for="radix-52"
for="radix-:r24:"
>
Alice theme
</label>
@@ -202,7 +202,7 @@ exports[`<ThemeChoicePanel /> custom theme should display custom theme 1`] = `
>
<label
class="_label_dgy0u_67"
for="radix-54"
for="radix-:r25:"
>
Add custom theme
</label>
@@ -210,9 +210,9 @@ exports[`<ThemeChoicePanel /> custom theme should display custom theme 1`] = `
class="_controls_1h4nb_17"
>
<input
aria-describedby="radix-53"
aria-describedby="radix-:r26:"
class="_control_9gon8_18"
id="radix-54"
id="radix-:r25:"
name="input"
title=""
value=""
@@ -220,7 +220,7 @@ exports[`<ThemeChoicePanel /> custom theme should display custom theme 1`] = `
</div>
<span
class="_message_dgy0u_98 _help-message_dgy0u_104"
id="radix-53"
id="radix-:r26:"
>
Enter the URL of a custom theme you want to apply.
</span>
@@ -308,7 +308,7 @@ exports[`<ThemeChoicePanel /> custom theme should render the custom theme sectio
>
<input
class="_input_qnvru_32"
id="radix-32"
id="radix-:r10:"
name="systemTheme"
title=""
type="checkbox"
@@ -323,7 +323,7 @@ exports[`<ThemeChoicePanel /> custom theme should render the custom theme sectio
>
<label
class="_label_dgy0u_67"
for="radix-32"
for="radix-:r10:"
>
Match system theme
</label>
@@ -345,7 +345,7 @@ exports[`<ThemeChoicePanel /> custom theme should render the custom theme sectio
<input
checked=""
class="_input_1vw5h_26"
id="radix-33"
id="radix-:r11:"
name="themeSelector"
title=""
type="radio"
@@ -361,7 +361,7 @@ exports[`<ThemeChoicePanel /> custom theme should render the custom theme sectio
>
<label
class="_label_dgy0u_67 mx_ThemeChoicePanel_themeSelector_Label"
for="radix-33"
for="radix-:r11:"
>
Light
</label>
@@ -378,7 +378,7 @@ exports[`<ThemeChoicePanel /> custom theme should render the custom theme sectio
>
<input
class="_input_1vw5h_26"
id="radix-34"
id="radix-:r12:"
name="themeSelector"
title=""
type="radio"
@@ -394,7 +394,7 @@ exports[`<ThemeChoicePanel /> custom theme should render the custom theme sectio
>
<label
class="_label_dgy0u_67 mx_ThemeChoicePanel_themeSelector_Label"
for="radix-34"
for="radix-:r12:"
>
Dark
</label>
@@ -411,7 +411,7 @@ exports[`<ThemeChoicePanel /> custom theme should render the custom theme sectio
>
<input
class="_input_1vw5h_26"
id="radix-35"
id="radix-:r13:"
name="themeSelector"
title=""
type="radio"
@@ -427,7 +427,7 @@ exports[`<ThemeChoicePanel /> custom theme should render the custom theme sectio
>
<label
class="_label_dgy0u_67 mx_ThemeChoicePanel_themeSelector_Label"
for="radix-35"
for="radix-:r13:"
>
High contrast
</label>
@@ -444,7 +444,7 @@ exports[`<ThemeChoicePanel /> custom theme should render the custom theme sectio
>
<input
class="_input_1vw5h_26"
id="radix-36"
id="radix-:r14:"
name="themeSelector"
title=""
type="radio"
@@ -460,7 +460,7 @@ exports[`<ThemeChoicePanel /> custom theme should render the custom theme sectio
>
<label
class="_label_dgy0u_67 mx_ThemeChoicePanel_themeSelector_Label"
for="radix-36"
for="radix-:r14:"
>
Alice theme
</label>
@@ -478,7 +478,7 @@ exports[`<ThemeChoicePanel /> custom theme should render the custom theme sectio
>
<label
class="_label_dgy0u_67"
for="radix-38"
for="radix-:r15:"
>
Add custom theme
</label>
@@ -486,9 +486,9 @@ exports[`<ThemeChoicePanel /> custom theme should render the custom theme sectio
class="_controls_1h4nb_17"
>
<input
aria-describedby="radix-37"
aria-describedby="radix-:r16:"
class="_control_9gon8_18"
id="radix-38"
id="radix-:r15:"
name="input"
title=""
value=""
@@ -496,7 +496,7 @@ exports[`<ThemeChoicePanel /> custom theme should render the custom theme sectio
</div>
<span
class="_message_dgy0u_98 _help-message_dgy0u_104"
id="radix-37"
id="radix-:r16:"
>
Enter the URL of a custom theme you want to apply.
</span>
@@ -584,7 +584,7 @@ exports[`<ThemeChoicePanel /> renders the theme choice UI 1`] = `
>
<input
class="_input_qnvru_32"
id="radix-0"
id="radix-:r0:"
name="systemTheme"
title=""
type="checkbox"
@@ -599,7 +599,7 @@ exports[`<ThemeChoicePanel /> renders the theme choice UI 1`] = `
>
<label
class="_label_dgy0u_67"
for="radix-0"
for="radix-:r0:"
>
Match system theme
</label>
@@ -621,7 +621,7 @@ exports[`<ThemeChoicePanel /> renders the theme choice UI 1`] = `
<input
checked=""
class="_input_1vw5h_26"
id="radix-1"
id="radix-:r1:"
name="themeSelector"
title=""
type="radio"
@@ -637,7 +637,7 @@ exports[`<ThemeChoicePanel /> renders the theme choice UI 1`] = `
>
<label
class="_label_dgy0u_67 mx_ThemeChoicePanel_themeSelector_Label"
for="radix-1"
for="radix-:r1:"
>
Light
</label>
@@ -654,7 +654,7 @@ exports[`<ThemeChoicePanel /> renders the theme choice UI 1`] = `
>
<input
class="_input_1vw5h_26"
id="radix-2"
id="radix-:r2:"
name="themeSelector"
title=""
type="radio"
@@ -670,7 +670,7 @@ exports[`<ThemeChoicePanel /> renders the theme choice UI 1`] = `
>
<label
class="_label_dgy0u_67 mx_ThemeChoicePanel_themeSelector_Label"
for="radix-2"
for="radix-:r2:"
>
Dark
</label>
@@ -687,7 +687,7 @@ exports[`<ThemeChoicePanel /> renders the theme choice UI 1`] = `
>
<input
class="_input_1vw5h_26"
id="radix-3"
id="radix-:r3:"
name="themeSelector"
title=""
type="radio"
@@ -703,7 +703,7 @@ exports[`<ThemeChoicePanel /> renders the theme choice UI 1`] = `
>
<label
class="_label_dgy0u_67 mx_ThemeChoicePanel_themeSelector_Label"
for="radix-3"
for="radix-:r3:"
>
High contrast
</label>

View File

@@ -129,7 +129,6 @@ exports[`<SecurityUserSettingsTab /> renders security section 1`] = `
</th>
<td>
not found locally
</td>
</tr>
<tr>

View File

@@ -229,8 +229,8 @@ exports[`<SpacePanel /> should show all activated MetaSpaces in the correct orde
class="mx_ThreadsActivityCentre_container"
>
<button
aria-controls=":r39:"
aria-describedby=":r39:"
aria-controls=":r12:"
aria-describedby=":r12:"
aria-expanded="true"
aria-haspopup="dialog"
aria-label="Threads"
@@ -256,7 +256,7 @@ exports[`<SpacePanel /> should show all activated MetaSpaces in the correct orde
tabindex="0"
/>
<span
aria-owns="undefined"
aria-owns=":r18:"
style="border: 0px; height: 1px; margin: -1px; overflow: hidden; padding: 0px; position: fixed; white-space: nowrap; width: 1px; top: 0px; left: 0px;"
/>
<span

View File

@@ -127,7 +127,7 @@ export function untilEmission(
});
}
export const flushPromises = async () => await new Promise<void>((resolve) => window.setTimeout(resolve));
export const flushPromises = async () => await new Promise<void>((resolve) => window.setTimeout(resolve, 10));
// with jest's modern fake timers process.nextTick is also mocked,
// flushing promises in the normal way then waits for some advancement