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

Commit 5cdd435

Browse files
committed
Fix tests
Signed-off-by: Michael Telatynski <[email protected]>
1 parent a3fa53c commit 5cdd435

38 files changed

+135
-91
lines changed

src/components/structures/LeftPanel.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { HEADER_HEIGHT } from "../views/rooms/RoomSublist";
2626
import { Action } from "../../dispatcher/actions";
2727
import RoomSearch from "./RoomSearch";
2828
import ResizeNotifier from "../../utils/ResizeNotifier";
29+
import AccessibleTooltipButton from "../views/elements/AccessibleTooltipButton";
2930
import SpaceStore from "../../stores/spaces/SpaceStore";
3031
import { MetaSpace, SpaceKey, UPDATE_SELECTED_SPACE } from "../../stores/spaces";
3132
import { getKeyBindingsManager } from "../../KeyBindingsManager";
@@ -40,7 +41,7 @@ import RoomBreadcrumbs from "../views/rooms/RoomBreadcrumbs";
4041
import { KeyBindingAction } from "../../accessibility/KeyboardShortcuts";
4142
import { shouldShowComponent } from "../../customisations/helpers/UIComponents";
4243
import { UIComponent } from "../../settings/UIFeature";
43-
import AccessibleButton, { ButtonEvent } from "../views/elements/AccessibleButton";
44+
import { ButtonEvent } from "../views/elements/AccessibleButton";
4445
import PosthogTrackers from "../../PosthogTrackers";
4546
import PageType from "../../PageTypes";
4647
import { UserOnboardingButton } from "../views/user-onboarding/UserOnboardingButton";
@@ -332,7 +333,7 @@ export default class LeftPanel extends React.Component<IProps, IState> {
332333
// to start a new call
333334
if (LegacyCallHandler.instance.getSupportsPstnProtocol()) {
334335
dialPadButton = (
335-
<AccessibleButton
336+
<AccessibleTooltipButton
336337
className={classNames("mx_LeftPanel_dialPadButton", {})}
337338
onClick={this.onDialPad}
338339
title={_t("left_panel|open_dial_pad")}
@@ -343,7 +344,7 @@ export default class LeftPanel extends React.Component<IProps, IState> {
343344
let rightButton: JSX.Element | undefined;
344345
if (this.state.activeSpace === MetaSpace.Home && shouldShowComponent(UIComponent.ExploreRooms)) {
345346
rightButton = (
346-
<AccessibleButton
347+
<AccessibleTooltipButton
347348
className="mx_LeftPanel_exploreButton"
348349
onClick={this.onExplore}
349350
title={_t("action|explore_rooms")}

src/components/structures/SpaceHierarchy.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ const Tile: React.FC<ITileProps> = ({
145145
let button: ReactElement;
146146
if (busy) {
147147
button = (
148-
<AccessibleButton
148+
<AccessibleTooltipButton
149149
disabled={true}
150150
onClick={onJoinClick}
151151
kind="primary_outline"
@@ -154,7 +154,7 @@ const Tile: React.FC<ITileProps> = ({
154154
title={_t("space|joining_space")}
155155
>
156156
<Spinner w={24} h={24} />
157-
</AccessibleButton>
157+
</AccessibleTooltipButton>
158158
);
159159
} else if (joinedRoom) {
160160
button = (

src/components/views/dialogs/spotlight/TooltipOption.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import React, { ComponentProps, ReactNode } from "react";
1919

2020
import { RovingAccessibleTooltipButton } from "../../../../accessibility/roving/RovingAccessibleTooltipButton";
2121
import { useRovingTabIndex } from "../../../../accessibility/RovingTabIndex";
22-
import AccessibleButton from "../../elements/AccessibleButton";
22+
import AccessibleTooltipButton from "../../elements/AccessibleTooltipButton";
2323

2424
interface TooltipOptionProps extends ComponentProps<typeof RovingAccessibleTooltipButton> {
2525
endAdornment?: ReactNode;
@@ -28,7 +28,7 @@ interface TooltipOptionProps extends ComponentProps<typeof RovingAccessibleToolt
2828
export const TooltipOption: React.FC<TooltipOptionProps> = ({ inputRef, className, ...props }) => {
2929
const [onFocus, isActive, ref] = useRovingTabIndex(inputRef);
3030
return (
31-
<AccessibleButton
31+
<AccessibleTooltipButton
3232
{...props}
3333
className={classNames(className, "mx_SpotlightDialog_option")}
3434
onFocus={onFocus}

src/components/views/rooms/LegacyRoomHeader.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import SettingsStore from "../../../settings/SettingsStore";
3232
import RoomHeaderButtons from "../right_panel/LegacyRoomHeaderButtons";
3333
import E2EIcon from "./E2EIcon";
3434
import DecoratedRoomAvatar from "../avatars/DecoratedRoomAvatar";
35-
import AccessibleButton, { ButtonEvent } from "../elements/AccessibleButton";
35+
import { ButtonEvent } from "../elements/AccessibleButton";
3636
import AccessibleTooltipButton from "../elements/AccessibleTooltipButton";
3737
import RoomTopic from "../elements/RoomTopic";
3838
import RoomName from "../elements/RoomName";
@@ -654,7 +654,7 @@ export default class RoomHeader extends React.Component<IProps, IState> {
654654
if (this.props.viewingCall && !isVideoRoom) {
655655
if (this.props.activeCall === null) {
656656
endButtons.push(
657-
<AccessibleButton
657+
<AccessibleTooltipButton
658658
className="mx_LegacyRoomHeader_button mx_LegacyRoomHeader_closeButton"
659659
onClick={this.onHideCallClick}
660660
title={_t("room|header|close_call_button")}

src/components/views/settings/devices/DeviceExpandDetailsButton.tsx

+6-5
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ import React, { ComponentProps } from "react";
1919

2020
import { Icon as CaretIcon } from "../../../../../res/img/feather-customised/dropdown-arrow.svg";
2121
import { _t } from "../../../../languageHandler";
22-
import AccessibleButton from "../../elements/AccessibleButton";
22+
import AccessibleTooltipButton from "../../elements/AccessibleTooltipButton";
2323

2424
type Props<T extends keyof JSX.IntrinsicElements> = Omit<
25-
ComponentProps<typeof AccessibleButton<T>>,
26-
"title" | "kind" | "className" | "onClick"
25+
ComponentProps<typeof AccessibleTooltipButton<T>>,
26+
"aria-label" | "title" | "kind" | "className" | "onClick"
2727
> & {
2828
isExpanded: boolean;
2929
onClick: () => void;
@@ -36,8 +36,9 @@ export const DeviceExpandDetailsButton = <T extends keyof JSX.IntrinsicElements>
3636
}: Props<T>): JSX.Element => {
3737
const label = isExpanded ? _t("settings|sessions|hide_details") : _t("settings|sessions|show_details");
3838
return (
39-
<AccessibleButton
39+
<AccessibleTooltipButton
4040
{...rest}
41+
aria-label={label}
4142
title={label}
4243
kind="icon"
4344
className={classNames("mx_DeviceExpandDetailsButton", {
@@ -46,6 +47,6 @@ export const DeviceExpandDetailsButton = <T extends keyof JSX.IntrinsicElements>
4647
onClick={onClick}
4748
>
4849
<CaretIcon className="mx_DeviceExpandDetailsButton_icon" />
49-
</AccessibleButton>
50+
</AccessibleTooltipButton>
5051
);
5152
};

src/i18n/strings/en_EN.json

-1
Original file line numberDiff line numberDiff line change
@@ -3203,7 +3203,6 @@
32033203
"download_action_decrypting": "Decrypting",
32043204
"download_action_downloading": "Downloading",
32053205
"edits": {
3206-
"tooltip_label": "Edited at %(date)s. Click to view edits.",
32073206
"tooltip_sub": "Click to view edits",
32083207
"tooltip_title": "Edited at %(date)s"
32093208
},

src/toasts/IncomingCallToast.tsx

+12-7
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,14 @@ import defaultDispatcher from "../dispatcher/dispatcher";
2828
import { ViewRoomPayload } from "../dispatcher/payloads/ViewRoomPayload";
2929
import { Action } from "../dispatcher/actions";
3030
import ToastStore from "../stores/ToastStore";
31+
import AccessibleTooltipButton from "../components/views/elements/AccessibleTooltipButton";
3132
import {
3233
LiveContentSummary,
3334
LiveContentSummaryWithCall,
3435
LiveContentType,
3536
} from "../components/views/rooms/LiveContentSummary";
3637
import { useCall, useJoinCallButtonDisabledTooltip } from "../hooks/useCall";
37-
import AccessibleButton, { ButtonEvent } from "../components/views/elements/AccessibleButton";
38+
import { ButtonEvent } from "../components/views/elements/AccessibleButton";
3839
import { useDispatcher } from "../hooks/useDispatcher";
3940
import { ActionPayload } from "../dispatcher/payloads";
4041
import { Call } from "../models/Call";
@@ -53,15 +54,15 @@ function JoinCallButtonWithCall({ onClick, call }: JoinCallButtonWithCallProps):
5354
const disabledTooltip = useJoinCallButtonDisabledTooltip(call);
5455

5556
return (
56-
<AccessibleButton
57+
<AccessibleTooltipButton
5758
className="mx_IncomingCallToast_joinButton"
5859
onClick={onClick}
5960
disabled={disabledTooltip !== null}
60-
title={disabledTooltip ?? undefined}
61+
tooltip={disabledTooltip ?? undefined}
6162
kind="primary"
6263
>
6364
{_t("action|join")}
64-
</AccessibleButton>
65+
</AccessibleTooltipButton>
6566
);
6667
}
6768

@@ -177,12 +178,16 @@ export function IncomingCallToast({ notifyEvent }: Props): JSX.Element {
177178
{call ? (
178179
<JoinCallButtonWithCall onClick={onJoinClick} call={call} />
179180
) : (
180-
<AccessibleButton className="mx_IncomingCallToast_joinButton" onClick={onJoinClick} kind="primary">
181+
<AccessibleTooltipButton
182+
className="mx_IncomingCallToast_joinButton"
183+
onClick={onJoinClick}
184+
kind="primary"
185+
>
181186
{_t("action|join")}
182-
</AccessibleButton>
187+
</AccessibleTooltipButton>
183188
)}
184189
</div>
185-
<AccessibleButton
190+
<AccessibleTooltipButton
186191
className="mx_IncomingCallToast_closeButton"
187192
onClick={onCloseClick}
188193
title={_t("action|close")}

test/components/structures/LeftPanel-test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ limitations under the License.
1616
*/
1717

1818
import React from "react";
19-
import { render, RenderResult, screen } from "@testing-library/react";
2019
import { mocked } from "jest-mock";
2120

21+
import { render, RenderResult, screen } from "../..";
2222
import LeftPanel from "../../../src/components/structures/LeftPanel";
2323
import PageType from "../../../src/PageTypes";
2424
import ResizeNotifier from "../../../src/utils/ResizeNotifier";

test/components/structures/UserMenu-test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ limitations under the License.
1515
*/
1616

1717
import React from "react";
18-
import { act, render, RenderResult } from "@testing-library/react";
1918
import { MatrixClient, MatrixEvent } from "matrix-js-sdk/src/matrix";
2019

20+
import { act, render, RenderResult } from "../..";
2121
import UnwrappedUserMenu from "../../../src/components/structures/UserMenu";
2222
import { stubClient, wrapInSdkContext } from "../../test-utils";
2323
import {

test/components/structures/__snapshots__/RoomView-test.tsx.snap

+6-6
Original file line numberDiff line numberDiff line change
@@ -462,20 +462,20 @@ exports[`RoomView for a local room in state NEW should match the snapshot 1`] =
462462
class="mx_MessageComposer_actions"
463463
>
464464
<div
465-
aria-label="Emoji"
466465
class="mx_AccessibleButton mx_EmojiButton mx_MessageComposer_button mx_EmojiButton_icon"
466+
data-state="closed"
467467
role="button"
468468
tabindex="0"
469469
/>
470470
<div
471-
aria-label="Attachment"
472471
class="mx_AccessibleButton mx_MessageComposer_button mx_MessageComposer_upload"
472+
data-state="closed"
473473
role="button"
474474
tabindex="0"
475475
/>
476476
<div
477-
aria-label="More options"
478477
class="mx_AccessibleButton mx_MessageComposer_button mx_MessageComposer_buttonMenu"
478+
data-state="closed"
479479
role="button"
480480
tabindex="0"
481481
/>
@@ -709,20 +709,20 @@ exports[`RoomView for a local room in state NEW that is encrypted should match t
709709
class="mx_MessageComposer_actions"
710710
>
711711
<div
712-
aria-label="Emoji"
713712
class="mx_AccessibleButton mx_EmojiButton mx_MessageComposer_button mx_EmojiButton_icon"
713+
data-state="closed"
714714
role="button"
715715
tabindex="0"
716716
/>
717717
<div
718-
aria-label="Attachment"
719718
class="mx_AccessibleButton mx_MessageComposer_button mx_MessageComposer_upload"
719+
data-state="closed"
720720
role="button"
721721
tabindex="0"
722722
/>
723723
<div
724-
aria-label="More options"
725724
class="mx_AccessibleButton mx_MessageComposer_button mx_MessageComposer_buttonMenu"
725+
data-state="closed"
726726
role="button"
727727
tabindex="0"
728728
/>

test/components/structures/__snapshots__/UserMenu-test.tsx.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ exports[`<UserMenu> when rendered should render as expected 1`] = `
1010
aria-haspopup="true"
1111
aria-label="User menu"
1212
class="mx_AccessibleButton mx_UserMenu_contextMenuButton"
13+
data-state="closed"
1314
role="button"
1415
tabindex="0"
15-
title="User menu"
1616
>
1717
<div
1818
class="mx_UserMenu_userAvatar"

test/components/views/audio_messages/RecordingPlayback-test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ limitations under the License.
1717
import React from "react";
1818
import { mocked } from "jest-mock";
1919
import { logger } from "matrix-js-sdk/src/logger";
20-
import { fireEvent, render, RenderResult } from "@testing-library/react";
2120

21+
import { fireEvent, render, RenderResult } from "../../..";
2222
import RecordingPlayback, { PlaybackLayout } from "../../../../src/components/views/audio_messages/RecordingPlayback";
2323
import { Playback } from "../../../../src/audio/Playback";
2424
import RoomContext, { TimelineRenderingType } from "../../../../src/contexts/RoomContext";

test/components/views/location/LocationViewDialog-test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ limitations under the License.
1515
*/
1616

1717
import React from "react";
18-
import { render, RenderResult } from "@testing-library/react";
1918
import { RoomMember, LocationAssetType } from "matrix-js-sdk/src/matrix";
2019

20+
import { render, RenderResult } from "../../..";
2121
import LocationViewDialog from "../../../../src/components/views/location/LocationViewDialog";
2222
import { TILE_SERVER_WK_KEY } from "../../../../src/utils/WellKnownUtils";
2323
import { getMockClientWithEventEmitter, makeLocationEvent } from "../../../test-utils";

test/components/views/location/ZoomButtons-test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ limitations under the License.
1616

1717
import React from "react";
1818
import * as maplibregl from "maplibre-gl";
19-
import { render, screen } from "@testing-library/react";
2019

20+
import { render, screen } from "../../..";
2121
import ZoomButtons from "../../../../src/components/views/location/ZoomButtons";
2222

2323
describe("<ZoomButtons />", () => {

test/components/views/location/__snapshots__/LocationViewDialog-test.tsx.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,21 @@ exports[`<LocationViewDialog /> renders map correctly 1`] = `
2424
>
2525
<div
2626
class="mx_AccessibleButton mx_ZoomButtons_button"
27+
data-state="closed"
2728
data-testid="map-zoom-in-button"
2829
role="button"
2930
tabindex="0"
30-
title="Zoom in"
3131
>
3232
<div
3333
class="mx_ZoomButtons_icon"
3434
/>
3535
</div>
3636
<div
3737
class="mx_AccessibleButton mx_ZoomButtons_button"
38+
data-state="closed"
3839
data-testid="map-zoom-out-button"
3940
role="button"
4041
tabindex="0"
41-
title="Zoom out"
4242
>
4343
<div
4444
class="mx_ZoomButtons_icon"

test/components/views/location/__snapshots__/ZoomButtons-test.tsx.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@ exports[`<ZoomButtons /> renders buttons 1`] = `
77
>
88
<div
99
class="mx_AccessibleButton mx_ZoomButtons_button"
10+
data-state="closed"
1011
data-testid="map-zoom-in-button"
1112
role="button"
1213
tabindex="0"
13-
title="Zoom in"
1414
>
1515
<div
1616
class="mx_ZoomButtons_icon"
1717
/>
1818
</div>
1919
<div
2020
class="mx_AccessibleButton mx_ZoomButtons_button"
21+
data-state="closed"
2122
data-testid="map-zoom-out-button"
2223
role="button"
2324
tabindex="0"
24-
title="Zoom out"
2525
>
2626
<div
2727
class="mx_ZoomButtons_icon"

test/components/views/right_panel/UserInfo-test.tsx

+10-8
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ limitations under the License.
1515
*/
1616

1717
import React from "react";
18-
import { fireEvent, render, screen, waitFor, cleanup, act, within } from "@testing-library/react";
18+
import { fireEvent, render, screen, waitFor, cleanup, act } from "@testing-library/react";
1919
import userEvent from "@testing-library/user-event";
2020
import { Mocked, mocked } from "jest-mock";
2121
import {
@@ -288,7 +288,8 @@ describe("<UserInfo />", () => {
288288

289289
it("renders close button correctly when encryption panel with a pending verification request", () => {
290290
renderComponent({ phase: RightPanelPhases.EncryptionPanel, verificationRequest });
291-
expect(screen.getByTestId("base-card-close-button")).toHaveAttribute("title", "Cancel");
291+
screen.getByTestId("base-card-close-button").focus();
292+
expect(screen.getByRole("tooltip")).toHaveTextContent("Cancel");
292293
});
293294
});
294295

@@ -355,11 +356,8 @@ describe("<UserInfo />", () => {
355356
// click it
356357
await userEvent.click(devicesButton);
357358

358-
// there should now be a button with the device id ...
359-
const deviceButton = screen.getByRole("button", { description: "d1" });
360-
361-
// ... which should contain the device name
362-
expect(within(deviceButton).getByText("my device")).toBeInTheDocument();
359+
// there should now be a button with the device id which should contain the device name
360+
expect(screen.getByRole("button", { name: "my device" })).toBeInTheDocument();
363361
});
364362

365363
it("renders <BasicUserInfo />", async () => {
@@ -460,7 +458,11 @@ describe("<DeviceItem />", () => {
460458

461459
const renderComponent = (props = {}) => {
462460
const Wrapper = (wrapperProps = {}) => {
463-
return <MatrixClientContext.Provider value={mockClient} {...wrapperProps} />;
461+
return (
462+
<TooltipProvider>
463+
<MatrixClientContext.Provider value={mockClient} {...wrapperProps} />
464+
</TooltipProvider>
465+
);
464466
};
465467

466468
return render(<DeviceItem {...defaultProps} {...props} />, {

0 commit comments

Comments
 (0)