Migrate to React 18 createRoot API (#28256)
* Migrate to React 18 createRoot API Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Discard changes to src/components/views/settings/devices/DeviceDetails.tsx * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Attempt to stabilise test Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * legacyRoot? Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix tests Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Improve coverage Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Update snapshots Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Improve coverage Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
48fd330dd9
commit
ca33d9165a
44 changed files with 719 additions and 731 deletions
|
@ -11,7 +11,7 @@ Please see LICENSE files in the repository root for full details.
|
|||
import "core-js/stable/structured-clone";
|
||||
import "fake-indexeddb/auto";
|
||||
import React, { ComponentProps } from "react";
|
||||
import { fireEvent, render, RenderResult, screen, waitFor, within } from "jest-matrix-react";
|
||||
import { fireEvent, render, RenderResult, screen, waitFor, within, act } from "jest-matrix-react";
|
||||
import fetchMock from "fetch-mock-jest";
|
||||
import { Mocked, mocked } from "jest-mock";
|
||||
import { ClientEvent, MatrixClient, MatrixEvent, Room, SyncState } from "matrix-js-sdk/src/matrix";
|
||||
|
@ -163,7 +163,7 @@ describe("<MatrixChat />", () => {
|
|||
let initPromise: Promise<void> | undefined;
|
||||
let defaultProps: ComponentProps<typeof MatrixChat>;
|
||||
const getComponent = (props: Partial<ComponentProps<typeof MatrixChat>> = {}) =>
|
||||
render(<MatrixChat {...defaultProps} {...props} />);
|
||||
render(<MatrixChat {...defaultProps} {...props} />, { legacyRoot: true });
|
||||
|
||||
// make test results readable
|
||||
filterConsole(
|
||||
|
@ -201,7 +201,7 @@ describe("<MatrixChat />", () => {
|
|||
// we are logged in, but are still waiting for the /sync to complete
|
||||
await screen.findByText("Syncing…");
|
||||
// initial sync
|
||||
client.emit(ClientEvent.Sync, SyncState.Prepared, null);
|
||||
await act(() => client.emit(ClientEvent.Sync, SyncState.Prepared, null));
|
||||
}
|
||||
|
||||
// let things settle
|
||||
|
@ -263,7 +263,7 @@ describe("<MatrixChat />", () => {
|
|||
|
||||
// emit a loggedOut event so that all of the Store singletons forget about their references to the mock client
|
||||
// (must be sync otherwise the next test will start before it happens)
|
||||
defaultDispatcher.dispatch({ action: Action.OnLoggedOut }, true);
|
||||
act(() => defaultDispatcher.dispatch({ action: Action.OnLoggedOut }, true));
|
||||
|
||||
localStorage.clear();
|
||||
});
|
||||
|
@ -328,7 +328,7 @@ describe("<MatrixChat />", () => {
|
|||
|
||||
expect(within(dialog).getByText(errorMessage)).toBeInTheDocument();
|
||||
// just check we're back on welcome page
|
||||
await expect(await screen.findByTestId("mx_welcome_screen")).toBeInTheDocument();
|
||||
await expect(screen.findByTestId("mx_welcome_screen")).resolves.toBeInTheDocument();
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
|
@ -956,9 +956,11 @@ describe("<MatrixChat />", () => {
|
|||
await screen.findByText("Powered by Matrix");
|
||||
|
||||
// go to login page
|
||||
defaultDispatcher.dispatch({
|
||||
action: "start_login",
|
||||
});
|
||||
act(() =>
|
||||
defaultDispatcher.dispatch({
|
||||
action: "start_login",
|
||||
}),
|
||||
);
|
||||
|
||||
await flushPromises();
|
||||
|
||||
|
@ -1126,9 +1128,11 @@ describe("<MatrixChat />", () => {
|
|||
|
||||
await getComponentAndLogin();
|
||||
|
||||
bootstrapDeferred.resolve();
|
||||
act(() => bootstrapDeferred.resolve());
|
||||
|
||||
await expect(await screen.findByRole("heading", { name: "You're in", level: 1 })).toBeInTheDocument();
|
||||
await expect(
|
||||
screen.findByRole("heading", { name: "You're in", level: 1 }),
|
||||
).resolves.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1397,7 +1401,9 @@ describe("<MatrixChat />", () => {
|
|||
|
||||
function simulateSessionLockClaim() {
|
||||
localStorage.setItem("react_sdk_session_lock_claimant", "testtest");
|
||||
window.dispatchEvent(new StorageEvent("storage", { key: "react_sdk_session_lock_claimant" }));
|
||||
act(() =>
|
||||
window.dispatchEvent(new StorageEvent("storage", { key: "react_sdk_session_lock_claimant" })),
|
||||
);
|
||||
}
|
||||
|
||||
it("after a session is restored", async () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue