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

Commit e8e2121

Browse files
committed
add test for: no button if cannot change join rule and room not public nor knock
Signed-off-by: Timo K <[email protected]>
1 parent a6106f5 commit e8e2121

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

test/components/views/rooms/RoomHeader/CallGuestLinkButton-test.tsx

+12-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limitations under the License.
1717
import React from "react";
1818
import { TooltipProvider } from "@vector-im/compound-web";
1919
import { fireEvent, getByLabelText, render, screen } from "@testing-library/react";
20-
import { JoinRule, Room } from "matrix-js-sdk/src/matrix";
20+
import { EventTimeline, JoinRule, Room } from "matrix-js-sdk/src/matrix";
2121
import { KnownMembership } from "matrix-js-sdk/src/types";
2222

2323
import { SDKContext, SdkContextClass } from "../../../../../src/contexts/SDKContext";
@@ -136,6 +136,7 @@ describe("<CallGuestLinkButton />", () => {
136136
expect(callParams[1].subtitle).toEqual(expectedShareDialogProps.subtitle);
137137
expect(callParams[1].customTitle).toEqual(expectedShareDialogProps.customTitle);
138138
});
139+
139140
it("shows the ShareDialog on click with knock join rules", () => {
140141
jest.spyOn(room, "getJoinRule").mockReturnValue(JoinRule.Knock);
141142
getComponent(room);
@@ -147,6 +148,16 @@ describe("<CallGuestLinkButton />", () => {
147148
expect(callParams[1].customTitle).toEqual(expectedShareDialogProps.customTitle);
148149
});
149150

151+
it("don't show external conference button if room not public nor knock and the user cannot change join rules", () => {
152+
jest.spyOn(room, "getLiveTimeline").mockReturnValue({
153+
getState: jest.fn().mockReturnValue({
154+
maySendStateEvent: jest.fn().mockReturnValue(false),
155+
}),
156+
} as unknown as EventTimeline);
157+
getComponent(room);
158+
expect(screen.queryByLabelText("Share call link")).not.toBeInTheDocument();
159+
});
160+
150161
it("don't show external conference button if now guest spa link is configured", () => {
151162
jest.spyOn(room, "getJoinRule").mockReturnValue(JoinRule.Public);
152163
jest.spyOn(SdkContextClass.instance.roomViewStore, "isViewingCall").mockReturnValue(true);

0 commit comments

Comments
 (0)