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

Commit

Permalink
add test for: no button if cannot change join rule and room not publi…
Browse files Browse the repository at this point in the history
…c nor knock

Signed-off-by: Timo K <toger5@hotmail.de>
  • Loading branch information
toger5 committed Apr 4, 2024
1 parent a6106f5 commit e8e2121
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
import React from "react";
import { TooltipProvider } from "@vector-im/compound-web";
import { fireEvent, getByLabelText, render, screen } from "@testing-library/react";
import { JoinRule, Room } from "matrix-js-sdk/src/matrix";
import { EventTimeline, JoinRule, Room } from "matrix-js-sdk/src/matrix";
import { KnownMembership } from "matrix-js-sdk/src/types";

import { SDKContext, SdkContextClass } from "../../../../../src/contexts/SDKContext";
Expand Down Expand Up @@ -136,6 +136,7 @@ describe("<CallGuestLinkButton />", () => {
expect(callParams[1].subtitle).toEqual(expectedShareDialogProps.subtitle);
expect(callParams[1].customTitle).toEqual(expectedShareDialogProps.customTitle);
});

it("shows the ShareDialog on click with knock join rules", () => {
jest.spyOn(room, "getJoinRule").mockReturnValue(JoinRule.Knock);
getComponent(room);
Expand All @@ -147,6 +148,16 @@ describe("<CallGuestLinkButton />", () => {
expect(callParams[1].customTitle).toEqual(expectedShareDialogProps.customTitle);
});

it("don't show external conference button if room not public nor knock and the user cannot change join rules", () => {
jest.spyOn(room, "getLiveTimeline").mockReturnValue({
getState: jest.fn().mockReturnValue({
maySendStateEvent: jest.fn().mockReturnValue(false),
}),
} as unknown as EventTimeline);
getComponent(room);
expect(screen.queryByLabelText("Share call link")).not.toBeInTheDocument();
});

it("don't show external conference button if now guest spa link is configured", () => {
jest.spyOn(room, "getJoinRule").mockReturnValue(JoinRule.Public);
jest.spyOn(SdkContextClass.instance.roomViewStore, "isViewingCall").mockReturnValue(true);
Expand Down

0 comments on commit e8e2121

Please sign in to comment.