diff --git a/src/button/ReactionToggleButton.test.tsx b/src/button/ReactionToggleButton.test.tsx
index 7faee4d8..6d881bb3 100644
--- a/src/button/ReactionToggleButton.test.tsx
+++ b/src/button/ReactionToggleButton.test.tsx
@@ -11,14 +11,13 @@ import { TooltipProvider } from "@vector-im/compound-web";
import { userEvent } from "@testing-library/user-event";
import { type ReactNode } from "react";
-import { MockRoom } from "../utils/testReactions";
import { ReactionToggleButton } from "./ReactionToggleButton";
import { ElementCallReactionEventType } from "../reactions";
import { CallViewModel } from "../state/CallViewModel";
import { getBasicCallViewModelEnvironment } from "../utils/test-viewmodel";
import { alice, local, localRtcMember } from "../utils/test-fixtures";
import { MockRTCSession } from "../utils/test";
-import { ReactionsProvider } from "../useReactionsSender";
+import { ReactionsSenderProvider } from "../useReactionsSender";
import { MatrixRTCSession } from "matrix-js-sdk/src/matrixrtc/MatrixRTCSession";
const localIdent = `${localRtcMember.sender}:${localRtcMember.deviceId}`;
@@ -32,9 +31,12 @@ function TestComponent({
}): ReactNode {
return (
-
+
-
+
);
}
@@ -51,14 +53,15 @@ test("Can open menu", async () => {
test("Can raise hand", async () => {
const user = userEvent.setup();
- const { vm, rtcSession } = getBasicCallViewModelEnvironment([local, alice]);
+ const { vm, rtcSession, handRaisedSubject } =
+ getBasicCallViewModelEnvironment([local, alice]);
const { getByLabelText, container } = render(
,
);
await user.click(getByLabelText("common.reactions"));
await user.click(getByLabelText("action.raise_hand"));
expect(rtcSession.room.client.sendEvent).toHaveBeenCalledWith(
- undefined,
+ rtcSession.room.roomId,
"m.reaction",
{
"m.relates_to": {
@@ -69,50 +72,46 @@ test("Can raise hand", async () => {
},
);
await act(() => {
- vm.updateReactions({
- raisedHands: {
- [localIdent]: new Date(),
+ // Mock receiving a reaction.
+ handRaisedSubject.next({
+ [localIdent]: {
+ time: new Date(),
+ reactionEventId: "",
+ membershipEventId: localRtcMember.eventId!,
},
- reactions: {},
});
});
expect(container).toMatchSnapshot();
});
test("Can lower hand", async () => {
+ const reactionEventId = "$my-reaction-event:example.org";
const user = userEvent.setup();
- const { vm, rtcSession } = getBasicCallViewModelEnvironment([local, alice]);
+ const { vm, rtcSession, handRaisedSubject } =
+ getBasicCallViewModelEnvironment([local, alice]);
const { getByLabelText, container } = render(
,
);
await user.click(getByLabelText("common.reactions"));
await user.click(getByLabelText("action.raise_hand"));
await act(() => {
- vm.updateReactions({
- raisedHands: {
- [localIdent]: new Date(),
+ handRaisedSubject.next({
+ [localIdent]: {
+ time: new Date(),
+ reactionEventId,
+ membershipEventId: localRtcMember.eventId!,
},
- reactions: {},
});
});
await user.click(getByLabelText("common.reactions"));
await user.click(getByLabelText("action.lower_hand"));
expect(rtcSession.room.client.redactEvent).toHaveBeenCalledWith(
- undefined,
- "m.reaction",
- {
- "m.relates_to": {
- event_id: localRtcMember.eventId,
- key: "🖐️",
- rel_type: "m.annotation",
- },
- },
+ rtcSession.room.roomId,
+ reactionEventId,
);
await act(() => {
- vm.updateReactions({
- raisedHands: {},
- reactions: {},
- });
+ // Mock receiving a redacted reaction.
+ handRaisedSubject.next({});
});
expect(container).toMatchSnapshot();
});
@@ -126,7 +125,7 @@ test("Can react with emoji", async () => {
await user.click(getByLabelText("common.reactions"));
await user.click(getByText("🐶"));
expect(rtcSession.room.client.sendEvent).toHaveBeenCalledWith(
- undefined,
+ rtcSession.room.roomId,
ElementCallReactionEventType,
{
"m.relates_to": {
@@ -150,7 +149,7 @@ test("Can fully expand emoji picker", async () => {
expect(container).toMatchSnapshot();
await user.click(getByText("🦗"));
expect(rtcSession.room.client.sendEvent).toHaveBeenCalledWith(
- undefined,
+ rtcSession.room.roomId,
ElementCallReactionEventType,
{
"m.relates_to": {
diff --git a/src/button/__snapshots__/ReactionToggleButton.test.tsx.snap b/src/button/__snapshots__/ReactionToggleButton.test.tsx.snap
index 5dce0977..4937bae3 100644
--- a/src/button/__snapshots__/ReactionToggleButton.test.tsx.snap
+++ b/src/button/__snapshots__/ReactionToggleButton.test.tsx.snap
@@ -68,6 +68,37 @@ exports[`Can fully expand emoji picker 1`] = `
`;
+exports[`Can lower hand 1`] = `
+
+`;
+
exports[`Can open menu 1`] = `
>;
reactionsSubject: BehaviorSubject>;
} {
+ const matrixRoomId = "!myRoomId:example.com";
const matrixRoomMembers = new Map(members.map((p) => [p.userId, p]));
const remoteParticipants = of([aliceParticipant]);
const liveKitRoom = mockLivekitRoom(
@@ -51,6 +52,7 @@ export function getBasicCallViewModelEnvironment(
off: vitest.fn(),
} as Partial as MatrixClient,
getMember: (userId) => matrixRoomMembers.get(userId) ?? null,
+ roomId: matrixRoomId,
});
const remoteRtcMemberships = new BehaviorSubject(