Files
element-call/src/tile/GridTile.test.tsx
T

69 lines
1.9 KiB
TypeScript
Raw Normal View History

2024-09-06 17:27:08 -04:00
/*
2024-09-10 17:46:40 -04:00
Copyright 2024 New Vector Ltd.
2024-09-06 17:27:08 -04:00
2024-09-10 17:46:40 -04:00
SPDX-License-Identifier: AGPL-3.0-only
Please see LICENSE in the repository root for full details.
2024-09-06 17:27:08 -04:00
*/
import { RemoteTrackPublication } from "livekit-client";
import { test, expect } from "vitest";
import { render, screen } from "@testing-library/react";
import { axe } from "vitest-axe";
2024-11-06 04:36:48 -05:00
import { of } from "rxjs";
2024-11-04 08:54:13 -01:00
import { MatrixRTCSession } from "matrix-js-sdk/src/matrixrtc/MatrixRTCSession";
2024-09-06 17:27:08 -04:00
import { GridTile } from "./GridTile";
import { withRemoteMedia } from "../utils/test";
2024-11-06 04:36:48 -05:00
import { GridTileViewModel } from "../state/TileViewModel";
2024-11-04 08:54:13 -01:00
import { ReactionsProvider } from "../useReactions";
2024-09-06 17:27:08 -04:00
2024-11-06 04:36:48 -05:00
global.IntersectionObserver = class MockIntersectionObserver {
public observe(): void {}
public unobserve(): void {}
public disconnect(): void {}
} as unknown as typeof IntersectionObserver;
2024-09-06 17:27:08 -04:00
test("GridTile is accessible", async () => {
await withRemoteMedia(
{
rawDisplayName: "Alice",
getMxcAvatarUrl: () => "mxc://adfsg",
},
{
setVolume() {},
getTrackPublication: () =>
({}) as Partial<RemoteTrackPublication> as RemoteTrackPublication,
},
async (vm) => {
2024-11-04 08:54:13 -01:00
const fakeRtcSession = {
on: () => {},
off: () => {},
room: {
on: () => {},
off: () => {},
client: {
getUserId: () => null,
2024-11-10 10:44:29 -05:00
on: () => {},
off: () => {},
2024-11-04 08:54:13 -01:00
},
},
memberships: [],
} as unknown as MatrixRTCSession;
2024-09-06 17:27:08 -04:00
const { container } = render(
2024-11-04 08:54:13 -01:00
<ReactionsProvider rtcSession={fakeRtcSession}>
<GridTile
2024-11-06 04:36:48 -05:00
vm={new GridTileViewModel(of(vm))}
2024-11-04 08:54:13 -01:00
onOpenProfile={() => {}}
targetWidth={300}
targetHeight={200}
showSpeakingIndicators
/>
</ReactionsProvider>,
2024-09-06 17:27:08 -04:00
);
expect(await axe(container)).toHaveNoViolations();
// Name should be visible
screen.getByText("Alice");
},
);
});