Conform more of the codebase to strictNullChecks + noImplicitAny (#11179)
This commit is contained in:
parent
7c211b0587
commit
a294ba2ad4
17 changed files with 104 additions and 88 deletions
|
@ -418,7 +418,11 @@ describe("<MatrixChat />", () => {
|
|||
// this is used to create a temporary client during login
|
||||
jest.spyOn(MatrixJs, "createClient").mockReturnValue(loginClient);
|
||||
|
||||
loginClient.login.mockClear().mockResolvedValue({});
|
||||
loginClient.login.mockClear().mockResolvedValue({
|
||||
access_token: "TOKEN",
|
||||
device_id: "IMADEVICE",
|
||||
user_id: userId,
|
||||
});
|
||||
loginClient.loginFlows.mockClear().mockResolvedValue({ flows: [{ type: "m.login.password" }] });
|
||||
|
||||
loginClient.getProfileInfo.mockResolvedValue({
|
||||
|
|
|
@ -54,7 +54,11 @@ describe("Login", function () {
|
|||
disable_custom_urls: true,
|
||||
oidc_static_client_ids: oidcStaticClientsConfig,
|
||||
});
|
||||
mockClient.login.mockClear().mockResolvedValue({});
|
||||
mockClient.login.mockClear().mockResolvedValue({
|
||||
access_token: "TOKEN",
|
||||
device_id: "IAMADEVICE",
|
||||
user_id: "@user:server",
|
||||
});
|
||||
mockClient.loginFlows.mockClear().mockResolvedValue({ flows: [{ type: "m.login.password" }] });
|
||||
mocked(createClient).mockImplementation((opts) => {
|
||||
mockClient.idBaseUrl = opts.idBaseUrl;
|
||||
|
|
|
@ -19,6 +19,7 @@ import React from "react";
|
|||
import { fireEvent, render, screen, act } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { mocked } from "jest-mock";
|
||||
import { MatrixError } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
import InteractiveAuthDialog from "../../../../src/components/views/dialogs/InteractiveAuthDialog";
|
||||
import { clearAllModals, flushPromises, getMockClientWithEventEmitter, unmockClientPeg } from "../../../test-utils";
|
||||
|
@ -130,7 +131,7 @@ describe("InteractiveAuthDialog", function () {
|
|||
const successfulResult = { test: 1 };
|
||||
const makeRequest = jest
|
||||
.fn()
|
||||
.mockRejectedValueOnce({ httpStatus: 401, data: { flows: [{ stages: ["m.login.sso"] }] } })
|
||||
.mockRejectedValueOnce(new MatrixError({ data: { flows: [{ stages: ["m.login.sso"] }] } }, 401))
|
||||
.mockResolvedValue(successfulResult);
|
||||
|
||||
mockClient.credentials = { userId: "@user:id" };
|
||||
|
|
|
@ -332,16 +332,18 @@ describe("<RoomPreviewBar />", () => {
|
|||
{ medium: "not-email", address: "address 2" },
|
||||
];
|
||||
|
||||
const testJoinButton = (props: ComponentProps<typeof RoomPreviewBar>) => async () => {
|
||||
const onJoinClick = jest.fn();
|
||||
const onRejectClick = jest.fn();
|
||||
const component = getComponent({ ...props, onJoinClick, onRejectClick });
|
||||
await new Promise(setImmediate);
|
||||
expect(getPrimaryActionButton(component)).toBeTruthy();
|
||||
expect(getSecondaryActionButton(component)).toBeFalsy();
|
||||
fireEvent.click(getPrimaryActionButton(component)!);
|
||||
expect(onJoinClick).toHaveBeenCalled();
|
||||
};
|
||||
const testJoinButton =
|
||||
(props: ComponentProps<typeof RoomPreviewBar>, expectSecondaryButton = false) =>
|
||||
async () => {
|
||||
const onJoinClick = jest.fn();
|
||||
const onRejectClick = jest.fn();
|
||||
const component = getComponent({ ...props, onJoinClick, onRejectClick });
|
||||
await new Promise(setImmediate);
|
||||
expect(getPrimaryActionButton(component)).toBeTruthy();
|
||||
if (expectSecondaryButton) expect(getSecondaryActionButton(component)).toBeFalsy();
|
||||
fireEvent.click(getPrimaryActionButton(component)!);
|
||||
expect(onJoinClick).toHaveBeenCalled();
|
||||
};
|
||||
|
||||
describe("when client fails to get 3PIDs", () => {
|
||||
beforeEach(() => {
|
||||
|
@ -399,7 +401,7 @@ describe("<RoomPreviewBar />", () => {
|
|||
});
|
||||
|
||||
it("renders email mismatch message when invite email mxid doesnt match", async () => {
|
||||
MatrixClientPeg.safeGet().lookupThreePid = jest.fn().mockReturnValue("not userid");
|
||||
MatrixClientPeg.safeGet().lookupThreePid = jest.fn().mockReturnValue({ mxid: "not userid" });
|
||||
const component = getComponent({ inviterName, invitedEmail });
|
||||
await new Promise(setImmediate);
|
||||
|
||||
|
@ -413,12 +415,12 @@ describe("<RoomPreviewBar />", () => {
|
|||
});
|
||||
|
||||
it("renders invite message when invite email mxid match", async () => {
|
||||
MatrixClientPeg.safeGet().lookupThreePid = jest.fn().mockReturnValue(userId);
|
||||
MatrixClientPeg.safeGet().lookupThreePid = jest.fn().mockReturnValue({ mxid: userId });
|
||||
const component = getComponent({ inviterName, invitedEmail });
|
||||
await new Promise(setImmediate);
|
||||
|
||||
expect(getMessage(component)).toMatchSnapshot();
|
||||
await testJoinButton({ inviterName, invitedEmail })();
|
||||
await testJoinButton({ inviterName, invitedEmail }, false)();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -116,10 +116,40 @@ exports[`<RoomPreviewBar /> with an invite with an invited email when client has
|
|||
class="mx_RoomPreviewBar_message"
|
||||
>
|
||||
<h3>
|
||||
This invite to RoomPreviewBar-test-room was sent to test@test.com
|
||||
Do you want to join RoomPreviewBar-test-room?
|
||||
</h3>
|
||||
<p>
|
||||
Share this email in Settings to receive invites directly in Element.
|
||||
<span
|
||||
class="mx_BaseAvatar"
|
||||
role="presentation"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
class="mx_BaseAvatar_initial"
|
||||
style="font-size: 23.400000000000002px; width: 36px; line-height: 36px;"
|
||||
>
|
||||
R
|
||||
</span>
|
||||
<img
|
||||
alt=""
|
||||
aria-hidden="true"
|
||||
class="mx_BaseAvatar_image"
|
||||
data-testid="avatar-img"
|
||||
loading="lazy"
|
||||
src="data:image/png;base64,00"
|
||||
style="width: 36px; height: 36px;"
|
||||
/>
|
||||
</span>
|
||||
</p>
|
||||
<p>
|
||||
<span>
|
||||
<span
|
||||
class="mx_RoomPreviewBar_inviter"
|
||||
>
|
||||
@inviter:test.com
|
||||
</span>
|
||||
invited you
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
`;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue