This commit is contained in:
Half-Shot
2024-11-07 09:53:47 +00:00
parent e8e905c710
commit f4f0821987
5 changed files with 187 additions and 188 deletions

View File

@@ -97,7 +97,7 @@ test("Can raise hand", () => {
expect(container).toMatchSnapshot();
});
test("Can can lower hand", () => {
test("Can lower hand", () => {
const room = new MockRoom(memberUserIdAlice);
const rtcSession = new MockRTCSession(room, membership);
const { getByRole, getByText, container } = render(

View File

@@ -1,176 +1,5 @@
// 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`] = `
<div>
<button
@@ -541,6 +370,177 @@ exports[`Can close search with the escape key 1`] = `
</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`] = `
<div>
<button

View File

@@ -5,10 +5,10 @@ SPDX-License-Identifier: AGPL-3.0-only
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 { TooltipProvider } from "@vector-im/compound-web";
import { ReactNode } from "react";
import { act, ReactNode } from "react";
import {
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", () => {
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);
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", () => {
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);
return Promise.resolve();
};

View File

@@ -5,8 +5,8 @@ SPDX-License-Identifier: AGPL-3.0-only
Please see LICENSE in the repository root for full details.
*/
import { act, render } from "@testing-library/react";
import { FC } from "react";
import { render } from "@testing-library/react";
import { act, FC } from "react";
import { describe, expect, test } from "vitest";
import { RoomEvent } from "matrix-js-sdk/src/matrix";

View File

@@ -289,12 +289,14 @@ export const ReactionsProvider = ({
}, [room, addRaisedHand, removeRaisedHand, memberships, raisedHands]);
const lowerHand = useCallback(async () => {
if (
!myUserId ||
clientState?.state !== "valid" ||
!clientState.authenticated ||
!raisedHands[myUserId]
) {
console.log("lower hand!");
if (!myUserId || !raisedHands[myUserId]) {
console.log(
"something is missing!",
myUserId,
clientState,
raisedHands[myUserId ?? ""],
);
return;
}
const myReactionId = raisedHands[myUserId].reactionEventId;
@@ -303,10 +305,7 @@ export const ReactionsProvider = ({
return;
}
try {
await clientState.authenticated.client.redactEvent(
rtcSession.room.roomId,
myReactionId,
);
await room.client.redactEvent(rtcSession.room.roomId, myReactionId);
logger.debug("Redacted raise hand event");
} catch (ex) {
logger.error("Failed to redact reaction event", myReactionId, ex);