Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Update to React 18 #10314

Closed
wants to merge 23 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Iterate
Signed-off-by: Michael Telatynski <[email protected]>
  • Loading branch information
t3chguy committed Aug 1, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 07670a75ced314bed7242c73bb478e14be9587ca
23 changes: 14 additions & 9 deletions src/components/structures/auth/Registration.tsx
Original file line number Diff line number Diff line change
@@ -248,15 +248,20 @@ export default class Registration extends React.Component<IProps, IState> {
logger.error("Failed to get login flows to check for SSO support", e);
}

this.setState(({ flows }) => ({
matrixClient: cli,
ssoFlow,
oidcNativeFlow,
// if we are using oidc native we won't continue with flow discovery on HS
// so set an empty array to indicate flows are no longer loading
flows: oidcNativeFlow ? [] : flows,
busy: false,
}));
await new Promise<void>((resolve) => {
this.setState(
({ flows }) => ({
matrixClient: cli,
ssoFlow,
oidcNativeFlow,
// if we are using oidc native we won't continue with flow discovery on HS
// so set an empty array to indicate flows are no longer loading
flows: oidcNativeFlow ? [] : flows,
busy: false,
}),
resolve,
);
});

// don't need to check with homeserver for login flows
// since we are going to use OIDC native flow
6 changes: 3 additions & 3 deletions test/components/structures/UserMenu-test.tsx
Original file line number Diff line number Diff line change
@@ -128,7 +128,7 @@ describe("<UserMenu>", () => {

const spy = jest.spyOn(defaultDispatcher, "dispatch");
screen.getByRole("button", { name: /User menu/i }).click();
screen.getByRole("menuitem", { name: /Sign out/i }).click();
await waitFor(() => screen.getByRole("menuitem", { name: /Sign out/i }).click());
await waitFor(() => {
expect(spy).toHaveBeenCalledWith({ action: "logout" });
});
@@ -152,7 +152,7 @@ describe("<UserMenu>", () => {

const spy = jest.spyOn(defaultDispatcher, "dispatch");
screen.getByRole("button", { name: /User menu/i }).click();
screen.getByRole("menuitem", { name: /Sign out/i }).click();
await waitFor(() => screen.getByRole("menuitem", { name: /Sign out/i }).click());
await waitFor(() => {
expect(spy).toHaveBeenCalledWith({ action: "logout" });
});
@@ -178,7 +178,7 @@ describe("<UserMenu>", () => {

const spy = jest.spyOn(Modal, "createDialog");
screen.getByRole("button", { name: /User menu/i }).click();
screen.getByRole("menuitem", { name: /Sign out/i }).click();
await waitFor(() => screen.getByRole("menuitem", { name: /Sign out/i }).click());

await waitFor(() => {
expect(spy).toHaveBeenCalledWith(LogoutDialog);
2 changes: 1 addition & 1 deletion test/components/structures/auth/ForgotPassword-test.tsx
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@

import React from "react";
import { mocked } from "jest-mock";
import { act, render, RenderResult, screen } from "@testing-library/react";
import { act, render, RenderResult, screen, waitFor } from "@testing-library/react";

Check failure on line 19 in test/components/structures/auth/ForgotPassword-test.tsx

GitHub Actions / ESLint

'waitFor' is defined but never used

Check failure on line 19 in test/components/structures/auth/ForgotPassword-test.tsx

GitHub Actions / Typescript Syntax Check

'waitFor' is declared but its value is never read.
import userEvent from "@testing-library/user-event";
import { MatrixClient, createClient } from "matrix-js-sdk/src/matrix";

6 changes: 3 additions & 3 deletions test/components/views/dialogs/UserSettingsDialog-test.tsx
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ limitations under the License.
*/

import React, { ReactElement } from "react";
import { render, screen } from "@testing-library/react";
import { render, screen, waitFor } from "@testing-library/react";
import { mocked, MockedObject } from "jest-mock";
import { MatrixClient } from "matrix-js-sdk/src/matrix";

@@ -238,7 +238,7 @@ describe("<UserSettingsDialog />", () => {
expect(getByTestId(`settings-tab-${UserTab.Labs}`)).toBeTruthy();
});

it("watches settings", () => {
it("watches settings", async () => {
const watchSettingCallbacks: Record<string, CallbackFn> = {};

mockSettingsStore.watchSetting.mockImplementation((settingName, roomId, callback) => {
@@ -257,7 +257,7 @@ describe("<UserSettingsDialog />", () => {
watchSettingCallbacks["feature_mjolnir"]("feature_mjolnir", "", SettingLevel.ACCOUNT, true, true);

// tab is rendered now
expect(queryByTestId(`settings-tab-${UserTab.Mjolnir}`)).toBeTruthy();
await waitFor(() => expect(queryByTestId(`settings-tab-${UserTab.Mjolnir}`)).toBeTruthy());

unmount();

5 changes: 3 additions & 2 deletions test/components/views/messages/MPollEndBody-test.tsx
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ limitations under the License.
*/

import React from "react";
import { render } from "@testing-library/react";
import { render, waitForElementToBeRemoved } from "@testing-library/react";
import { EventTimeline, MatrixEvent, Room, M_TEXT } from "matrix-js-sdk/src/matrix";
import { logger } from "matrix-js-sdk/src/logger";

@@ -129,13 +129,14 @@ describe("<MPollEndBody />", () => {
describe("when poll start event does not exist in current timeline", () => {
it("fetches the related poll start event and displays a poll tile", async () => {
await setupRoomWithEventsTimeline(pollEndEvent);
const { container, getByTestId } = getComponent();
const { container, getByTestId, queryByRole } = getComponent();

// while fetching event, only icon is shown
expect(container).toMatchSnapshot();

// flush the fetch event promise
await flushPromises();
await waitForElementToBeRemoved(() => queryByRole("progressbar"));

expect(mockClient.fetchRoomEvent).toHaveBeenCalledWith(roomId, pollStartEvent.getId());

Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@ import {
getMockClientWithEventEmitter,
makePollEndEvent,
makePollStartEvent,
mockClientMethodsRooms,
mockClientMethodsUser,
mockIntlDateTimeFormat,
setupRoomWithPollEvents,
@@ -41,7 +42,7 @@ describe("<PollHistory />", () => {
const roomId = "!room:domain.org";
const mockClient = getMockClientWithEventEmitter({
...mockClientMethodsUser(userId),
getRoom: jest.fn(),
...mockClientMethodsRooms([]),
relations: jest.fn(),
decryptEventIfNeeded: jest.fn(),
getOrCreateFilter: jest.fn(),
Original file line number Diff line number Diff line change
@@ -133,7 +133,7 @@ exports[`<RoomSummaryCard /> has button to edit topic 1`] = `
</svg>
<label
class="_typography_yh5dq_162 _font-body-md-medium_yh5dq_69 _label_1gwvj_53"
for=":r3:"
for=":r2:"
>
Favourite
</label>
@@ -142,7 +142,7 @@ exports[`<RoomSummaryCard /> has button to edit topic 1`] = `
>
<input
class="_input_qnvru_32"
id=":r3:"
id=":r2:"
type="checkbox"
/>
<div
@@ -525,7 +525,7 @@ exports[`<RoomSummaryCard /> renders the room summary 1`] = `
</svg>
<label
class="_typography_yh5dq_162 _font-body-md-medium_yh5dq_69 _label_1gwvj_53"
for=":r1:"
for=":r0:"
>
Favourite
</label>
@@ -534,7 +534,7 @@ exports[`<RoomSummaryCard /> renders the room summary 1`] = `
>
<input
class="_input_qnvru_32"
id=":r1:"
id=":r0:"
type="checkbox"
/>
<div
@@ -944,7 +944,7 @@ exports[`<RoomSummaryCard /> renders the room topic in the summary 1`] = `
</svg>
<label
class="_typography_yh5dq_162 _font-body-md-medium_yh5dq_69 _label_1gwvj_53"
for=":r2:"
for=":r1:"
>
Favourite
</label>
@@ -953,7 +953,7 @@ exports[`<RoomSummaryCard /> renders the room topic in the summary 1`] = `
>
<input
class="_input_qnvru_32"
id=":r2:"
id=":r1:"
type="checkbox"
/>
<div
16 changes: 7 additions & 9 deletions test/components/views/rooms/RoomPreviewBar-test.tsx
Original file line number Diff line number Diff line change
@@ -15,10 +15,9 @@ limitations under the License.
*/

import React, { ComponentProps } from "react";
import { render, fireEvent, RenderResult, waitFor } from "@testing-library/react";
import { render, fireEvent, RenderResult, waitFor, waitForElementToBeRemoved } from "@testing-library/react";
import { Room, RoomMember, MatrixError, IContent } from "matrix-js-sdk/src/matrix";
import { KnownMembership } from "matrix-js-sdk/src/types";
import { sleep } from "matrix-js-sdk/src/utils";

import { withClientContextRenderOptions, stubClient } from "../../../test-utils";
import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
@@ -374,8 +373,7 @@ describe("<RoomPreviewBar />", () => {
const onJoinClick = jest.fn();
const onRejectClick = jest.fn();
const component = getComponent({ ...props, onJoinClick, onRejectClick });
await sleep(0);
expect(getPrimaryActionButton(component)).toBeTruthy();
await waitFor(() => expect(getPrimaryActionButton(component)).toBeTruthy());
if (expectSecondaryButton) expect(getSecondaryActionButton(component)).toBeFalsy();
fireEvent.click(getPrimaryActionButton(component)!);
expect(onJoinClick).toHaveBeenCalled();
@@ -388,7 +386,7 @@ describe("<RoomPreviewBar />", () => {

it("renders error message", async () => {
const component = getComponent({ inviterName, invitedEmail });
await sleep(0);
await waitForElementToBeRemoved(() => component.queryByRole("progressbar"));

expect(getMessage(component)).toMatchSnapshot();
});
@@ -405,7 +403,7 @@ describe("<RoomPreviewBar />", () => {

it("renders invite message with invited email", async () => {
const component = getComponent({ inviterName, invitedEmail });
await sleep(0);
await waitForElementToBeRemoved(() => component.queryByRole("progressbar"));

expect(getMessage(component)).toMatchSnapshot();
});
@@ -421,7 +419,7 @@ describe("<RoomPreviewBar />", () => {

it("renders invite message with invited email", async () => {
const component = getComponent({ inviterName, invitedEmail });
await sleep(0);
await waitForElementToBeRemoved(() => component.queryByRole("progressbar"));

expect(getMessage(component)).toMatchSnapshot();
});
@@ -439,7 +437,7 @@ describe("<RoomPreviewBar />", () => {
it("renders email mismatch message when invite email mxid doesnt match", async () => {
MatrixClientPeg.safeGet().lookupThreePid = jest.fn().mockReturnValue({ mxid: "not userid" });
const component = getComponent({ inviterName, invitedEmail });
await sleep(0);
await waitForElementToBeRemoved(() => component.queryByRole("progressbar"));

expect(getMessage(component)).toMatchSnapshot();
expect(MatrixClientPeg.safeGet().lookupThreePid).toHaveBeenCalledWith(
@@ -453,7 +451,7 @@ describe("<RoomPreviewBar />", () => {
it("renders invite message when invite email mxid match", async () => {
MatrixClientPeg.safeGet().lookupThreePid = jest.fn().mockReturnValue({ mxid: userId });
const component = getComponent({ inviterName, invitedEmail });
await sleep(0);
await waitForElementToBeRemoved(() => component.queryByRole("progressbar"));

expect(getMessage(component)).toMatchSnapshot();
await testJoinButton({ inviterName, invitedEmail }, false)();
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ limitations under the License.
*/

import React from "react";
import { fireEvent, render, screen, within } from "@testing-library/react";
import { fireEvent, render, screen, waitFor, within } from "@testing-library/react";
import { logger } from "matrix-js-sdk/src/logger";

import MatrixClientContext from "../../../../src/contexts/MatrixClientContext";
@@ -99,6 +99,6 @@ describe("SetIntegrationManager", () => {

expect(logger.error).toHaveBeenCalledWith("Error changing integration manager provisioning");
expect(logger.error).toHaveBeenCalledWith("oups");
expect(within(integrationSection).getByRole("switch")).not.toBeChecked();
await waitFor(() => expect(within(integrationSection).getByRole("switch")).not.toBeChecked());
});
});
Loading
Loading