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

Commit c518d2c

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

32 files changed

+103
-66
lines changed

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
},

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__/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/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} />, {

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ exports[`<DeviceItem /> ambiguous display name 1`] = `
44
<div>
55
<div
66
class="mx_AccessibleButton mx_UserInfo_device mx_UserInfo_device_unverified"
7+
data-state="closed"
78
role="button"
89
tabindex="0"
9-
title="deviceId"
1010
>
1111
<div
1212
class="mx_E2EIcon mx_E2EIcon_normal"
@@ -27,9 +27,9 @@ exports[`<DeviceItem /> with display name 1`] = `
2727
<div>
2828
<div
2929
class="mx_AccessibleButton mx_UserInfo_device mx_UserInfo_device_unverified"
30+
data-state="closed"
3031
role="button"
3132
tabindex="0"
32-
title="deviceId"
3333
>
3434
<div
3535
class="mx_E2EIcon mx_E2EIcon_normal"
@@ -50,9 +50,9 @@ exports[`<DeviceItem /> without display name 1`] = `
5050
<div>
5151
<div
5252
class="mx_AccessibleButton mx_UserInfo_device mx_UserInfo_device_unverified"
53+
data-state="closed"
5354
role="button"
5455
tabindex="0"
55-
title="deviceId"
5656
>
5757
<div
5858
class="mx_E2EIcon mx_E2EIcon_normal"
@@ -79,10 +79,10 @@ exports[`<UserInfo /> with crypto enabled renders <BasicUserInfo /> 1`] = `
7979
>
8080
<div
8181
class="mx_AccessibleButton mx_BaseCard_close"
82+
data-state="closed"
8283
data-testid="base-card-close-button"
8384
role="button"
8485
tabindex="0"
85-
title="Close"
8686
/>
8787
<div
8888
class="mx_BaseCard_headerProp"

test/components/views/rooms/RoomPreviewCard-test.tsx

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

1717
import React from "react";
1818
import { mocked, Mocked } from "jest-mock";
19-
import { render, screen, act } from "@testing-library/react";
2019
import { PendingEventOrdering, Room, RoomStateEvent, RoomType } from "matrix-js-sdk/src/matrix";
2120

21+
import { render, screen, act } from "../../..";
2222
import type { MatrixClient, RoomMember } from "matrix-js-sdk/src/matrix";
2323
import { stubClient, wrapInMatrixClientContext, mkRoomMember } from "../../../test-utils";
2424
import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";

test/components/views/rooms/VoiceRecordComposerTile-test.tsx

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

1717
import React, { createRef, RefObject } from "react";
18-
import { render } from "@testing-library/react";
1918
import { MatrixClient, MsgType, Room } from "matrix-js-sdk/src/matrix";
2019
import { mocked } from "jest-mock";
2120

21+
import { render } from "../../..";
2222
import VoiceRecordComposerTile from "../../../../src/components/views/rooms/VoiceRecordComposerTile";
2323
import { doMaybeLocalRoomAction } from "../../../../src/utils/local-room";
2424
import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";

test/components/views/rooms/__snapshots__/MemberTile-test.tsx.snap

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ exports[`MemberTile should display an verified E2EIcon when the e2E status = Ver
55
<div>
66
<div
77
class="mx_AccessibleButton mx_EntityTile mx_EntityTile_offline_neveractive"
8+
data-state="closed"
89
role="button"
910
tabindex="0"
10-
title="@userId:matrix.org (power 0)"
1111
>
1212
<div
1313
class="mx_EntityTile_avatar"
@@ -58,9 +58,9 @@ exports[`MemberTile should display an warning E2EIcon when the e2E status = Warn
5858
<div>
5959
<div
6060
class="mx_AccessibleButton mx_EntityTile mx_EntityTile_offline_neveractive"
61+
data-state="closed"
6162
role="button"
6263
tabindex="0"
63-
title="@userId:matrix.org (power 0)"
6464
>
6565
<div
6666
class="mx_EntityTile_avatar"
@@ -111,9 +111,9 @@ exports[`MemberTile should not display an E2EIcon when the e2E status = normal 1
111111
<div>
112112
<div
113113
class="mx_AccessibleButton mx_EntityTile mx_EntityTile_offline_neveractive"
114+
data-state="closed"
114115
role="button"
115116
tabindex="0"
116-
title="@userId:matrix.org (power 0)"
117117
>
118118
<div
119119
class="mx_EntityTile_avatar"

test/components/views/settings/devices/CurrentDeviceSection-test.tsx

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

1717
import React from "react";
18-
import { act, fireEvent, render } from "@testing-library/react";
1918

19+
import { act, fireEvent, render } from "../../../..";
2020
import CurrentDeviceSection from "../../../../../src/components/views/settings/devices/CurrentDeviceSection";
2121
import { DeviceType } from "../../../../../src/utils/device/parseUserAgent";
2222

test/components/views/settings/devices/DeviceExpandDetailsButton-test.tsx

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

1717
import React from "react";
18-
import { fireEvent, render } from "@testing-library/react";
1918

19+
import { fireEvent, render } from "../../../..";
2020
import { DeviceExpandDetailsButton } from "../../../../../src/components/views/settings/devices/DeviceExpandDetailsButton";
2121

2222
describe("<DeviceExpandDetailsButton />", () => {

test/components/views/settings/devices/LoginWithQRFlow-test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";
1817
import React from "react";
1918
import { RendezvousFailureReason } from "matrix-js-sdk/src/rendezvous";
2019

20+
import { cleanup, fireEvent, render, screen, waitFor } from "../../../..";
2121
import LoginWithQRFlow from "../../../../../src/components/views/auth/LoginWithQRFlow";
2222
import {
2323
Click,

test/components/views/settings/devices/__snapshots__/CurrentDeviceSection-test.tsx.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,8 @@ exports[`<CurrentDeviceSection /> renders device and correct security card when
237237
class="mx_DeviceTile_actions"
238238
>
239239
<div
240-
aria-label="Show details"
241240
class="mx_AccessibleButton mx_DeviceExpandDetailsButton mx_AccessibleButton_hasKind mx_AccessibleButton_kind_icon"
241+
data-state="closed"
242242
data-testid="current-session-toggle-details"
243243
role="button"
244244
tabindex="0"
@@ -380,8 +380,8 @@ exports[`<CurrentDeviceSection /> renders device and correct security card when
380380
class="mx_DeviceTile_actions"
381381
>
382382
<div
383-
aria-label="Show details"
384383
class="mx_AccessibleButton mx_DeviceExpandDetailsButton mx_AccessibleButton_hasKind mx_AccessibleButton_kind_icon"
384+
data-state="closed"
385385
data-testid="current-session-toggle-details"
386386
role="button"
387387
tabindex="0"

test/components/views/settings/devices/__snapshots__/DeviceExpandDetailsButton-test.tsx.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ exports[`<DeviceExpandDetailsButton /> renders when expanded 1`] = `
44
{
55
"container": <div>
66
<div
7-
aria-label="Hide details"
87
class="mx_AccessibleButton mx_DeviceExpandDetailsButton mx_DeviceExpandDetailsButton_expanded mx_AccessibleButton_hasKind mx_AccessibleButton_kind_icon"
8+
data-state="closed"
99
role="button"
1010
tabindex="0"
1111
>
@@ -21,8 +21,8 @@ exports[`<DeviceExpandDetailsButton /> renders when not expanded 1`] = `
2121
{
2222
"container": <div>
2323
<div
24-
aria-label="Show details"
2524
class="mx_AccessibleButton mx_DeviceExpandDetailsButton mx_AccessibleButton_hasKind mx_AccessibleButton_kind_icon"
25+
data-state="closed"
2626
role="button"
2727
tabindex="0"
2828
>

0 commit comments

Comments
 (0)