mirror of
https://github.com/vector-im/element-call.git
synced 2026-08-02 19:49:23 +00:00
Fix test
This commit is contained in:
@@ -97,7 +97,7 @@ test("Can raise hand", () => {
|
|||||||
expect(container).toMatchSnapshot();
|
expect(container).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Can can lower hand", () => {
|
test("Can lower hand", () => {
|
||||||
const room = new MockRoom(memberUserIdAlice);
|
const room = new MockRoom(memberUserIdAlice);
|
||||||
const rtcSession = new MockRTCSession(room, membership);
|
const rtcSession = new MockRTCSession(room, membership);
|
||||||
const { getByRole, getByText, container } = render(
|
const { getByRole, getByText, container } = render(
|
||||||
|
|||||||
@@ -1,176 +1,5 @@
|
|||||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||||
|
|
||||||
exports[`Can can lower hand 1`] = `
|
|
||||||
<div>
|
|
||||||
<button
|
|
||||||
aria-disabled="true"
|
|
||||||
aria-expanded="true"
|
|
||||||
aria-labelledby=":r52:"
|
|
||||||
class="_button_i91xf_17 raisedButton _has-icon_i91xf_66 _icon-only_i91xf_59"
|
|
||||||
data-kind="primary"
|
|
||||||
data-size="lg"
|
|
||||||
role="button"
|
|
||||||
tabindex="0"
|
|
||||||
>
|
|
||||||
<svg
|
|
||||||
aria-hidden="true"
|
|
||||||
fill="currentColor"
|
|
||||||
height="24"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
width="24"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
d="M11 3a1 1 0 1 1 2 0v8.5a.5.5 0 0 0 1 0V4a1 1 0 1 1 2 0v10.2l3.284-2.597a1.081 1.081 0 0 1 1.47 1.577c-.613.673-1.214 1.367-1.818 2.064-1.267 1.463-2.541 2.934-3.944 4.235A6 6 0 0 1 5 15V7a1 1 0 0 1 2 0v5.5a.5.5 0 0 0 1 0V4a1 1 0 0 1 2 0v7.5a.5.5 0 0 0 1 0V3Z"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</button>
|
|
||||||
<div
|
|
||||||
class="reactionPopupMenu"
|
|
||||||
>
|
|
||||||
<section
|
|
||||||
class="handRaiseSection"
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
aria-label="Toggle hand raised"
|
|
||||||
aria-labelledby=":r58:"
|
|
||||||
aria-pressed="true"
|
|
||||||
class="_button_i91xf_17 reactionButton"
|
|
||||||
data-kind="primary"
|
|
||||||
data-size="lg"
|
|
||||||
role="button"
|
|
||||||
tabindex="0"
|
|
||||||
>
|
|
||||||
🖐️
|
|
||||||
</button>
|
|
||||||
</section>
|
|
||||||
<div
|
|
||||||
class="verticalSeperator"
|
|
||||||
/>
|
|
||||||
<section>
|
|
||||||
<menu>
|
|
||||||
<li
|
|
||||||
class="reactionPopupMenuItem"
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
aria-disabled="false"
|
|
||||||
aria-labelledby=":r5d:"
|
|
||||||
class="_button_i91xf_17 reactionButton"
|
|
||||||
data-kind="secondary"
|
|
||||||
data-size="lg"
|
|
||||||
role="button"
|
|
||||||
tabindex="0"
|
|
||||||
>
|
|
||||||
👍
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
<li
|
|
||||||
class="reactionPopupMenuItem"
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
aria-disabled="false"
|
|
||||||
aria-labelledby=":r5i:"
|
|
||||||
class="_button_i91xf_17 reactionButton"
|
|
||||||
data-kind="secondary"
|
|
||||||
data-size="lg"
|
|
||||||
role="button"
|
|
||||||
tabindex="0"
|
|
||||||
>
|
|
||||||
🎉
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
<li
|
|
||||||
class="reactionPopupMenuItem"
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
aria-disabled="false"
|
|
||||||
aria-labelledby=":r5n:"
|
|
||||||
class="_button_i91xf_17 reactionButton"
|
|
||||||
data-kind="secondary"
|
|
||||||
data-size="lg"
|
|
||||||
role="button"
|
|
||||||
tabindex="0"
|
|
||||||
>
|
|
||||||
👏
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
<li
|
|
||||||
class="reactionPopupMenuItem"
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
aria-disabled="false"
|
|
||||||
aria-labelledby=":r5s:"
|
|
||||||
class="_button_i91xf_17 reactionButton"
|
|
||||||
data-kind="secondary"
|
|
||||||
data-size="lg"
|
|
||||||
role="button"
|
|
||||||
tabindex="0"
|
|
||||||
>
|
|
||||||
🐶
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
<li
|
|
||||||
class="reactionPopupMenuItem"
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
aria-disabled="false"
|
|
||||||
aria-labelledby=":r61:"
|
|
||||||
class="_button_i91xf_17 reactionButton"
|
|
||||||
data-kind="secondary"
|
|
||||||
data-size="lg"
|
|
||||||
role="button"
|
|
||||||
tabindex="0"
|
|
||||||
>
|
|
||||||
🐱
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
<li
|
|
||||||
class="reactionPopupMenuItem"
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
aria-disabled="false"
|
|
||||||
aria-labelledby=":r66:"
|
|
||||||
class="_button_i91xf_17 reactionButton"
|
|
||||||
data-kind="secondary"
|
|
||||||
data-size="lg"
|
|
||||||
role="button"
|
|
||||||
tabindex="0"
|
|
||||||
>
|
|
||||||
💡
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
<li
|
|
||||||
class="reactionPopupMenuItem"
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
aria-label="Open reactions search"
|
|
||||||
aria-labelledby=":r6b:"
|
|
||||||
class="_button_i91xf_17 _has-icon_i91xf_66 _icon-only_i91xf_59"
|
|
||||||
data-kind="tertiary"
|
|
||||||
data-size="lg"
|
|
||||||
role="button"
|
|
||||||
tabindex="0"
|
|
||||||
>
|
|
||||||
<svg
|
|
||||||
aria-hidden="true"
|
|
||||||
fill="currentColor"
|
|
||||||
height="24"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
width="24"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
d="M15.05 16.463a7.5 7.5 0 1 1 1.414-1.414l3.243 3.244a1 1 0 0 1-1.414 1.414l-3.244-3.244ZM16 10.5a5.5 5.5 0 1 0-11 0 5.5 5.5 0 0 0 11 0Z"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
</menu>
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`Can close menu 1`] = `
|
exports[`Can close menu 1`] = `
|
||||||
<div>
|
<div>
|
||||||
<button
|
<button
|
||||||
@@ -541,6 +370,177 @@ exports[`Can close search with the escape key 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`Can lower hand 1`] = `
|
||||||
|
<div>
|
||||||
|
<button
|
||||||
|
aria-disabled="true"
|
||||||
|
aria-expanded="true"
|
||||||
|
aria-labelledby=":r52:"
|
||||||
|
class="_button_i91xf_17 raisedButton _has-icon_i91xf_66 _icon-only_i91xf_59"
|
||||||
|
data-kind="primary"
|
||||||
|
data-size="lg"
|
||||||
|
role="button"
|
||||||
|
tabindex="0"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
aria-hidden="true"
|
||||||
|
fill="currentColor"
|
||||||
|
height="24"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
width="24"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M11 3a1 1 0 1 1 2 0v8.5a.5.5 0 0 0 1 0V4a1 1 0 1 1 2 0v10.2l3.284-2.597a1.081 1.081 0 0 1 1.47 1.577c-.613.673-1.214 1.367-1.818 2.064-1.267 1.463-2.541 2.934-3.944 4.235A6 6 0 0 1 5 15V7a1 1 0 0 1 2 0v5.5a.5.5 0 0 0 1 0V4a1 1 0 0 1 2 0v7.5a.5.5 0 0 0 1 0V3Z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
<div
|
||||||
|
class="reactionPopupMenu"
|
||||||
|
>
|
||||||
|
<section
|
||||||
|
class="handRaiseSection"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
aria-label="Toggle hand raised"
|
||||||
|
aria-labelledby=":r58:"
|
||||||
|
aria-pressed="true"
|
||||||
|
class="_button_i91xf_17 reactionButton"
|
||||||
|
data-kind="primary"
|
||||||
|
data-size="lg"
|
||||||
|
role="button"
|
||||||
|
tabindex="0"
|
||||||
|
>
|
||||||
|
🖐️
|
||||||
|
</button>
|
||||||
|
</section>
|
||||||
|
<div
|
||||||
|
class="verticalSeperator"
|
||||||
|
/>
|
||||||
|
<section>
|
||||||
|
<menu>
|
||||||
|
<li
|
||||||
|
class="reactionPopupMenuItem"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
aria-disabled="false"
|
||||||
|
aria-labelledby=":r5d:"
|
||||||
|
class="_button_i91xf_17 reactionButton"
|
||||||
|
data-kind="secondary"
|
||||||
|
data-size="lg"
|
||||||
|
role="button"
|
||||||
|
tabindex="0"
|
||||||
|
>
|
||||||
|
👍
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
<li
|
||||||
|
class="reactionPopupMenuItem"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
aria-disabled="false"
|
||||||
|
aria-labelledby=":r5i:"
|
||||||
|
class="_button_i91xf_17 reactionButton"
|
||||||
|
data-kind="secondary"
|
||||||
|
data-size="lg"
|
||||||
|
role="button"
|
||||||
|
tabindex="0"
|
||||||
|
>
|
||||||
|
🎉
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
<li
|
||||||
|
class="reactionPopupMenuItem"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
aria-disabled="false"
|
||||||
|
aria-labelledby=":r5n:"
|
||||||
|
class="_button_i91xf_17 reactionButton"
|
||||||
|
data-kind="secondary"
|
||||||
|
data-size="lg"
|
||||||
|
role="button"
|
||||||
|
tabindex="0"
|
||||||
|
>
|
||||||
|
👏
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
<li
|
||||||
|
class="reactionPopupMenuItem"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
aria-disabled="false"
|
||||||
|
aria-labelledby=":r5s:"
|
||||||
|
class="_button_i91xf_17 reactionButton"
|
||||||
|
data-kind="secondary"
|
||||||
|
data-size="lg"
|
||||||
|
role="button"
|
||||||
|
tabindex="0"
|
||||||
|
>
|
||||||
|
🐶
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
<li
|
||||||
|
class="reactionPopupMenuItem"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
aria-disabled="false"
|
||||||
|
aria-labelledby=":r61:"
|
||||||
|
class="_button_i91xf_17 reactionButton"
|
||||||
|
data-kind="secondary"
|
||||||
|
data-size="lg"
|
||||||
|
role="button"
|
||||||
|
tabindex="0"
|
||||||
|
>
|
||||||
|
🐱
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
<li
|
||||||
|
class="reactionPopupMenuItem"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
aria-disabled="false"
|
||||||
|
aria-labelledby=":r66:"
|
||||||
|
class="_button_i91xf_17 reactionButton"
|
||||||
|
data-kind="secondary"
|
||||||
|
data-size="lg"
|
||||||
|
role="button"
|
||||||
|
tabindex="0"
|
||||||
|
>
|
||||||
|
💡
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
<li
|
||||||
|
class="reactionPopupMenuItem"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
aria-label="Open reactions search"
|
||||||
|
aria-labelledby=":r6b:"
|
||||||
|
class="_button_i91xf_17 _has-icon_i91xf_66 _icon-only_i91xf_59"
|
||||||
|
data-kind="tertiary"
|
||||||
|
data-size="lg"
|
||||||
|
role="button"
|
||||||
|
tabindex="0"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
aria-hidden="true"
|
||||||
|
fill="currentColor"
|
||||||
|
height="24"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
width="24"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M15.05 16.463a7.5 7.5 0 1 1 1.414-1.414l3.243 3.244a1 1 0 0 1-1.414 1.414l-3.244-3.244ZM16 10.5a5.5 5.5 0 1 0-11 0 5.5 5.5 0 0 0 11 0Z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
</menu>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`Can open menu 1`] = `
|
exports[`Can open menu 1`] = `
|
||||||
<div>
|
<div>
|
||||||
<button
|
<button
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
Please see LICENSE in the repository root for full details.
|
Please see LICENSE in the repository root for full details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { act, render } from "@testing-library/react";
|
import { render } from "@testing-library/react";
|
||||||
import { afterAll, expect, test } from "vitest";
|
import { afterAll, expect, test } from "vitest";
|
||||||
import { TooltipProvider } from "@vector-im/compound-web";
|
import { TooltipProvider } from "@vector-im/compound-web";
|
||||||
import { ReactNode } from "react";
|
import { act, ReactNode } from "react";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
MockRoom,
|
MockRoom,
|
||||||
@@ -76,7 +76,7 @@ test("loads no audio elements when disabled in settings", () => {
|
|||||||
|
|
||||||
test("will play an audio sound when there is a reaction", () => {
|
test("will play an audio sound when there is a reaction", () => {
|
||||||
const audioIsPlaying: string[] = [];
|
const audioIsPlaying: string[] = [];
|
||||||
window.HTMLMediaElement.prototype.play = async function (): Promise<void> {
|
window.HTMLMediaElement.prototype.play = function (): Promise<void> {
|
||||||
audioIsPlaying.push((this.children[0] as HTMLSourceElement).src);
|
audioIsPlaying.push((this.children[0] as HTMLSourceElement).src);
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
};
|
};
|
||||||
@@ -101,7 +101,7 @@ test("will play an audio sound when there is a reaction", () => {
|
|||||||
|
|
||||||
test("will play multiple audio sounds when there are multiple different reactions", () => {
|
test("will play multiple audio sounds when there are multiple different reactions", () => {
|
||||||
const audioIsPlaying: string[] = [];
|
const audioIsPlaying: string[] = [];
|
||||||
window.HTMLMediaElement.prototype.play = async function (): Promise<void> {
|
window.HTMLMediaElement.prototype.play = function (): Promise<void> {
|
||||||
audioIsPlaying.push((this.children[0] as HTMLSourceElement).src);
|
audioIsPlaying.push((this.children[0] as HTMLSourceElement).src);
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
Please see LICENSE in the repository root for full details.
|
Please see LICENSE in the repository root for full details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { act, render } from "@testing-library/react";
|
import { render } from "@testing-library/react";
|
||||||
import { FC } from "react";
|
import { act, FC } from "react";
|
||||||
import { describe, expect, test } from "vitest";
|
import { describe, expect, test } from "vitest";
|
||||||
import { RoomEvent } from "matrix-js-sdk/src/matrix";
|
import { RoomEvent } from "matrix-js-sdk/src/matrix";
|
||||||
|
|
||||||
|
|||||||
@@ -289,12 +289,14 @@ export const ReactionsProvider = ({
|
|||||||
}, [room, addRaisedHand, removeRaisedHand, memberships, raisedHands]);
|
}, [room, addRaisedHand, removeRaisedHand, memberships, raisedHands]);
|
||||||
|
|
||||||
const lowerHand = useCallback(async () => {
|
const lowerHand = useCallback(async () => {
|
||||||
if (
|
console.log("lower hand!");
|
||||||
!myUserId ||
|
if (!myUserId || !raisedHands[myUserId]) {
|
||||||
clientState?.state !== "valid" ||
|
console.log(
|
||||||
!clientState.authenticated ||
|
"something is missing!",
|
||||||
!raisedHands[myUserId]
|
myUserId,
|
||||||
) {
|
clientState,
|
||||||
|
raisedHands[myUserId ?? ""],
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const myReactionId = raisedHands[myUserId].reactionEventId;
|
const myReactionId = raisedHands[myUserId].reactionEventId;
|
||||||
@@ -303,10 +305,7 @@ export const ReactionsProvider = ({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await clientState.authenticated.client.redactEvent(
|
await room.client.redactEvent(rtcSession.room.roomId, myReactionId);
|
||||||
rtcSession.room.roomId,
|
|
||||||
myReactionId,
|
|
||||||
);
|
|
||||||
logger.debug("Redacted raise hand event");
|
logger.debug("Redacted raise hand event");
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
logger.error("Failed to redact reaction event", myReactionId, ex);
|
logger.error("Failed to redact reaction event", myReactionId, ex);
|
||||||
|
|||||||
Reference in New Issue
Block a user