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

Commit

Permalink
Fix typing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
florianduros committed Apr 15, 2024
1 parent 30d60bf commit 95c0ff9
Show file tree
Hide file tree
Showing 24 changed files with 36 additions and 121 deletions.
2 changes: 0 additions & 2 deletions test/components/structures/auth/ForgotPassword-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { mocked } from "jest-mock";
import { act, render, RenderResult, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { MatrixClient, createClient } from "matrix-js-sdk/src/matrix";
import { TooltipProvider } from "@vector-im/compound-web";

import ForgotPassword from "../../../../src/components/structures/auth/ForgotPassword";
import { ValidatedServerConfig } from "../../../../src/utils/ValidatedServerConfig";
Expand Down Expand Up @@ -103,7 +102,6 @@ describe("<ForgotPassword>", () => {
beforeEach(() => {
renderResult = render(
<ForgotPassword serverConfig={serverConfig} onComplete={onComplete} onLoginClick={onLoginClick} />,
,
);
});

Expand Down
5 changes: 1 addition & 4 deletions test/components/views/avatars/DecoratedRoomAvatar-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { mocked } from "jest-mock";
import { JoinRule, MatrixClient, PendingEventOrdering, Room } from "matrix-js-sdk/src/matrix";
import React from "react";
import userEvent from "@testing-library/user-event";
import { TooltipProvider } from "@vector-im/compound-web";

import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
import { stubClient } from "../../../test-utils";
Expand All @@ -39,9 +38,7 @@ describe("DecoratedRoomAvatar", () => {
let room: Room;

function renderComponent() {
return render(<DecoratedRoomAvatar room={room} size="32px" />, {
wrapper: TooltipProvider,
});
return render(<DecoratedRoomAvatar room={room} size="32px" />);
}

beforeEach(() => {
Expand Down
1 change: 0 additions & 1 deletion test/components/views/beacon/BeaconViewDialog-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { act, fireEvent, render, RenderResult } from "@testing-library/react";
import { MatrixClient, MatrixEvent, Room, RoomMember, getBeaconInfoIdentifier } from "matrix-js-sdk/src/matrix";
import * as maplibregl from "maplibre-gl";
import { mocked } from "jest-mock";
import { TooltipProvider } from "@vector-im/compound-web";

import BeaconViewDialog from "../../../../src/components/views/beacon/BeaconViewDialog";
import {
Expand Down
5 changes: 1 addition & 4 deletions test/components/views/beacon/DialogSidebar-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ limitations under the License.

import React, { ComponentProps } from "react";
import { act, fireEvent, render } from "@testing-library/react";
import { TooltipProvider } from "@vector-im/compound-web";

import DialogSidebar from "../../../../src/components/views/beacon/DialogSidebar";
import MatrixClientContext from "../../../../src/contexts/MatrixClientContext";
Expand Down Expand Up @@ -53,9 +52,7 @@ describe("<DialogSidebar />", () => {

const getComponent = (props = {}) => (
<MatrixClientContext.Provider value={client}>
<TooltipProvider>
<DialogSidebar {...defaultProps} {...props} />
</TooltipProvider>
<DialogSidebar {...defaultProps} {...props} />
</MatrixClientContext.Provider>
);

Expand Down
7 changes: 1 addition & 6 deletions test/components/views/dialogs/ShareDialog-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
import React from "react";
import { EventTimeline, MatrixEvent, Room, RoomMember } from "matrix-js-sdk/src/matrix";
import { render, RenderOptions } from "@testing-library/react";
import { TooltipProvider } from "@vector-im/compound-web";

import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
import SettingsStore from "../../../../src/settings/SettingsStore";
Expand All @@ -31,11 +30,7 @@ jest.mock("../../../../src/utils/ShieldUtils");
function getWrapper(): RenderOptions {
return {
wrapper: ({ children }) => (
<TooltipProvider>
<MatrixClientContext.Provider value={MatrixClientPeg.safeGet()}>
{children}
</MatrixClientContext.Provider>
</TooltipProvider>
<MatrixClientContext.Provider value={MatrixClientPeg.safeGet()}>{children}</MatrixClientContext.Provider>
),
};
}
Expand Down
5 changes: 1 addition & 4 deletions test/components/views/elements/InfoTooltip-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,12 @@ limitations under the License.
import React from "react";
import userEvent from "@testing-library/user-event";
import { render, waitFor } from "@testing-library/react";
import { TooltipProvider } from "@vector-im/compound-web";

import InfoTooltip from "../../../../src/components/views/elements/InfoTooltip";

describe("InfoTooltip", () => {
it("should show tooltip on hover", async () => {
const { getByText, asFragment } = render(<InfoTooltip tooltip="Tooltip text">Trigger text</InfoTooltip>, {
wrapper: TooltipProvider,
});
const { getByText, asFragment } = render(<InfoTooltip tooltip="Tooltip text">Trigger text</InfoTooltip>);

const trigger = getByText("Trigger text");
expect(trigger).toBeVisible();
Expand Down
2 changes: 0 additions & 2 deletions test/components/views/elements/Pill-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { act, render, RenderResult, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { mocked, Mocked } from "jest-mock";
import { MatrixClient, MatrixEvent, Room } from "matrix-js-sdk/src/matrix";
import { TooltipProvider } from "@vector-im/compound-web";

import dis from "../../../../src/dispatcher/dispatcher";
import { Pill, PillProps, PillType } from "../../../../src/components/views/elements/Pill";
Expand Down Expand Up @@ -65,7 +64,6 @@ describe("<Pill>", () => {
<div onClick={pillParentClickHandler}>
<Pill {...withDefault} />
</div>,
,
);
};

Expand Down
5 changes: 1 addition & 4 deletions test/components/views/elements/RoomFacePile-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ limitations under the License.

import { render } from "@testing-library/react";
import React from "react";
import { TooltipProvider } from "@vector-im/compound-web";
import { KnownMembership } from "matrix-js-sdk/src/types";

import { mkRoom, mkRoomMember, stubClient, withClientContextRenderOptions } from "../../../test-utils";
Expand All @@ -33,9 +32,7 @@ describe("<RoomFacePile />", () => {
]);

const { asFragment } = render(
<TooltipProvider>
<RoomFacePile onlyKnownUsers={false} room={room} />
</TooltipProvider>,
<RoomFacePile onlyKnownUsers={false} room={room} />,
withClientContextRenderOptions(MatrixClientPeg.get()!),
);

Expand Down
1 change: 0 additions & 1 deletion test/components/views/messages/CallEvent-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { render, screen, act, cleanup, fireEvent, waitFor } from "@testing-libra
import { mocked, Mocked } from "jest-mock";
import { Room, RoomStateEvent, MatrixClient, PendingEventOrdering } from "matrix-js-sdk/src/matrix";
import { ClientWidgetApi, Widget } from "matrix-widget-api";
import { TooltipProvider } from "@vector-im/compound-web";

import type { RoomMember } from "matrix-js-sdk/src/matrix";
import {
Expand Down
6 changes: 2 additions & 4 deletions test/components/views/messages/MessageTimestamp-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
import React from "react";
import { render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { TooltipProvider } from "@vector-im/compound-web";

import MessageTimestamp from "../../../../src/components/views/messages/MessageTimestamp";

Expand All @@ -31,7 +30,7 @@ describe("MessageTimestamp", () => {
const DAY_MS = HOUR_MS * 24;

it("should render HH:MM", () => {
const { asFragment } = render(<MessageTimestamp ts={nowDate.getTime()} />, );
const { asFragment } = render(<MessageTimestamp ts={nowDate.getTime()} />);
expect(asFragment()).toMatchInlineSnapshot(`
<DocumentFragment>
<span
Expand All @@ -47,15 +46,14 @@ describe("MessageTimestamp", () => {
});

it("should show full date & time on hover", async () => {
const { container } = render(<MessageTimestamp ts={nowDate.getTime()} />, );
const { container } = render(<MessageTimestamp ts={nowDate.getTime()} />);
await userEvent.hover(container.querySelector(".mx_MessageTimestamp")!);
expect((await screen.findByRole("tooltip")).textContent).toMatchInlineSnapshot(`"Fri, Dec 17, 2021, 08:09:00"`);
});

it("should show sent & received time on hover if passed", async () => {
const { container } = render(
<MessageTimestamp ts={nowDate.getTime()} receivedTs={nowDate.getTime() + DAY_MS} />,
,
);
await userEvent.hover(container.querySelector(".mx_MessageTimestamp")!);
expect((await screen.findByRole("tooltip")).textContent).toMatchInlineSnapshot(
Expand Down
5 changes: 1 addition & 4 deletions test/components/views/polls/pollHistory/PollHistory-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
import React from "react";
import { act, fireEvent, render } from "@testing-library/react";
import { Filter, EventTimeline, Room, MatrixEvent, M_POLL_START } from "matrix-js-sdk/src/matrix";
import { TooltipProvider } from "@vector-im/compound-web";

import { PollHistory } from "../../../../../src/components/views/polls/pollHistory/PollHistory";
import {
Expand Down Expand Up @@ -68,9 +67,7 @@ describe("<PollHistory />", () => {
const getComponent = () =>
render(<PollHistory {...defaultProps} />, {
wrapper: ({ children }) => (
<MatrixClientContext.Provider value={mockClient}>
<TooltipProvider>{children}</TooltipProvider>
</MatrixClientContext.Provider>
<MatrixClientContext.Provider value={mockClient}>{children}</MatrixClientContext.Provider>
),
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
import React from "react";
import { render } from "@testing-library/react";
import { MatrixEvent, Poll, Room, M_TEXT } from "matrix-js-sdk/src/matrix";
import { TooltipProvider } from "@vector-im/compound-web";

import { PollListItemEnded } from "../../../../../src/components/views/polls/pollHistory/PollListItemEnded";
import {
Expand Down
5 changes: 1 addition & 4 deletions test/components/views/right_panel/RoomSummaryCard-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { render, fireEvent, screen } from "@testing-library/react";
import { EventType, MatrixEvent, Room, MatrixClient, JoinRule } from "matrix-js-sdk/src/matrix";
import { KnownMembership } from "matrix-js-sdk/src/types";
import { mocked, MockedObject } from "jest-mock";
import { TooltipProvider } from "@vector-im/compound-web";

import DMRoomMap from "../../../../src/utils/DMRoomMap";
import RoomSummaryCard from "../../../../src/components/views/right_panel/RoomSummaryCard";
Expand Down Expand Up @@ -57,9 +56,7 @@ describe("<RoomSummaryCard />", () => {

return render(<RoomSummaryCard {...defaultProps} {...props} />, {
wrapper: ({ children }) => (
<MatrixClientContext.Provider value={mockClient}>
<TooltipProvider>{children}</TooltipProvider>
</MatrixClientContext.Provider>
<MatrixClientContext.Provider value={mockClient}>{children}</MatrixClientContext.Provider>
),
});
};
Expand Down
13 changes: 2 additions & 11 deletions test/components/views/right_panel/UserInfo-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import {
VerificationPhase as Phase,
VerificationRequestEvent,
} from "matrix-js-sdk/src/crypto-api";
import { TooltipProvider } from "@vector-im/compound-web";

import UserInfo, {
BanToggleButton,
Expand Down Expand Up @@ -206,11 +205,7 @@ describe("<UserInfo />", () => {

const renderComponent = (props = {}) => {
const Wrapper = (wrapperProps = {}) => {
return (
<TooltipProvider>
<MatrixClientContext.Provider value={mockClient} {...wrapperProps} />
</TooltipProvider>
);
return <MatrixClientContext.Provider value={mockClient} {...wrapperProps} />;
};

return render(<UserInfo {...defaultProps} {...props} />, {
Expand Down Expand Up @@ -454,11 +449,7 @@ describe("<UserInfoHeader />", () => {

const renderComponent = (props = {}) => {
const Wrapper = (wrapperProps = {}) => {
return (
<TooltipProvider>
<MatrixClientContext.Provider value={mockClient} {...wrapperProps} />
</TooltipProvider>
);
return <MatrixClientContext.Provider value={mockClient} {...wrapperProps} />;
};

return render(<UserInfoHeader {...defaultProps} {...props} />, {
Expand Down
13 changes: 5 additions & 8 deletions test/components/views/rooms/EventTile-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import {
TweakName,
} from "matrix-js-sdk/src/matrix";
import { EventEncryptionInfo, EventShieldColour, EventShieldReason } from "matrix-js-sdk/src/crypto-api";
import { TooltipProvider } from "@vector-im/compound-web";
import { mkEncryptedMatrixEvent } from "matrix-js-sdk/src/testing";

import EventTile, { EventTileProps } from "../../../../src/components/views/rooms/EventTile";
Expand Down Expand Up @@ -59,13 +58,11 @@ describe("EventTile", () => {
return (
<MatrixClientContext.Provider value={client}>
<RoomContext.Provider value={props.roomContext}>
<TooltipProvider>
<EventTile
mxEvent={mxEvent}
replacingEventId={mxEvent.replacingEventId()}
{...(props.eventTilePropertyOverrides ?? {})}
/>
</TooltipProvider>
<EventTile
mxEvent={mxEvent}
replacingEventId={mxEvent.replacingEventId()}
{...(props.eventTilePropertyOverrides ?? {})}
/>
</RoomContext.Provider>
</MatrixClientContext.Provider>
);
Expand Down
3 changes: 0 additions & 3 deletions test/components/views/rooms/LegacyRoomHeader-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import { ClientWidgetApi, Widget } from "matrix-widget-api";
import EventEmitter from "events";
import { setupJestCanvasMock } from "jest-canvas-mock";
import { ViewRoomOpts } from "@matrix-org/react-sdk-module-api/lib/lifecycles/RoomViewLifecycle";
import { TooltipProvider } from "@vector-im/compound-web";
// eslint-disable-next-line no-restricted-imports
import { MatrixRTCSessionManagerEvents } from "matrix-js-sdk/src/matrixrtc/MatrixRTCSessionManager";
// eslint-disable-next-line no-restricted-imports
Expand Down Expand Up @@ -226,7 +225,6 @@ describe("LegacyRoomHeader", () => {
{...props}
/>
</RoomContext.Provider>,
,
);
};

Expand Down Expand Up @@ -870,7 +868,6 @@ function mountHeader(room: Room, propsOverride = {}, roomContext?: Partial<IRoom
<RoomContext.Provider value={{ ...roomContext, room } as IRoomState}>
<RoomHeader {...props} />
</RoomContext.Provider>,
,
);
}

Expand Down
7 changes: 1 addition & 6 deletions test/components/views/rooms/RoomHeader-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import {
waitFor,
} from "@testing-library/react";
import { ViewRoomOpts } from "@matrix-org/react-sdk-module-api/lib/lifecycles/RoomViewLifecycle";
import { TooltipProvider } from "@vector-im/compound-web";

import { filterConsole, mkEvent, stubClient } from "../../../test-utils";
import RoomHeader from "../../../../src/components/views/rooms/RoomHeader";
Expand All @@ -67,11 +66,7 @@ jest.mock("../../../../src/utils/ShieldUtils");
function getWrapper(): RenderOptions {
return {
wrapper: ({ children }) => (
<TooltipProvider>
<MatrixClientContext.Provider value={MatrixClientPeg.safeGet()}>
{children}
</MatrixClientContext.Provider>
</TooltipProvider>
<MatrixClientContext.Provider value={MatrixClientPeg.safeGet()}>{children}</MatrixClientContext.Provider>
),
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ limitations under the License.
*/

import React from "react";
import { TooltipProvider } from "@vector-im/compound-web";
import { fireEvent, getByLabelText, getByText, render, screen, waitFor } from "@testing-library/react";
import { EventTimeline, JoinRule, Room } from "matrix-js-sdk/src/matrix";
import { KnownMembership } from "matrix-js-sdk/src/types";
Expand Down Expand Up @@ -75,11 +74,7 @@ describe("<CallGuestLinkButton />", () => {

const getComponent = (room: Room) =>
render(<CallGuestLinkButton room={room} />, {
wrapper: ({ children }) => (
<SDKContext.Provider value={sdkContext}>
<TooltipProvider>{children}</TooltipProvider>
</SDKContext.Provider>
),
wrapper: ({ children }) => <SDKContext.Provider value={sdkContext}>{children}</SDKContext.Provider>,
});

const oldGet = SdkConfig.get;
Expand Down Expand Up @@ -225,11 +220,7 @@ describe("<CallGuestLinkButton />", () => {

const getComponent = (room: Room, canInvite: boolean = true) =>
render(<JoinRuleDialog room={room} canInvite={canInvite} onFinished={onFinished} />, {
wrapper: ({ children }) => (
<SDKContext.Provider value={sdkContext}>
<TooltipProvider>{children}</TooltipProvider>
</SDKContext.Provider>
),
wrapper: ({ children }) => <SDKContext.Provider value={sdkContext}>{children}</SDKContext.Provider>,
});

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import React from "react";
import { MockedObject } from "jest-mock";
import { Room } from "matrix-js-sdk/src/matrix";
import { fireEvent, render, screen } from "@testing-library/react";
import { TooltipProvider } from "@vector-im/compound-web";

import { VideoRoomChatButton } from "../../../../../src/components/views/rooms/RoomHeader/VideoRoomChatButton";
import { SDKContext, SdkContextClass } from "../../../../../src/contexts/SDKContext";
Expand Down Expand Up @@ -57,11 +56,7 @@ describe("<VideoRoomChatButton />", () => {

const getComponent = (room: Room) =>
render(<VideoRoomChatButton room={room} />, {
wrapper: ({ children }) => (
<SDKContext.Provider value={sdkContext}>
<TooltipProvider>{children}</TooltipProvider>
</SDKContext.Provider>
),
wrapper: ({ children }) => <SDKContext.Provider value={sdkContext}>{children}</SDKContext.Provider>,
});

beforeEach(() => {
Expand Down
Loading

0 comments on commit 95c0ff9

Please sign in to comment.