Hide voip buttons in group rooms in environments with widgets disabled (#12664)
* Hide voip buttons in group rooms in environments with widgets disabled Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix test stubs Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
5bcf76c9ab
commit
2d8c23e806
3 changed files with 79 additions and 23 deletions
|
@ -61,6 +61,7 @@ import { _t } from "../../../../src/languageHandler";
|
|||
import * as UseCall from "../../../../src/hooks/useCall";
|
||||
import { SdkContextClass } from "../../../../src/contexts/SDKContext";
|
||||
import WidgetStore, { IApp } from "../../../../src/stores/WidgetStore";
|
||||
import { UIFeature } from "../../../../src/settings/UIFeature";
|
||||
|
||||
jest.mock("../../../../src/utils/ShieldUtils");
|
||||
|
||||
|
@ -255,7 +256,47 @@ describe("RoomHeader", () => {
|
|||
expect(queryByLabelText(container, "Voice call")).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
describe("UIFeature.Widgets enabled (default)", () => {
|
||||
beforeEach(() => {
|
||||
jest.spyOn(SettingsStore, "getValue").mockImplementation((feature) => feature == UIFeature.Widgets);
|
||||
});
|
||||
|
||||
it("should show call buttons in a room with 2 members", () => {
|
||||
mockRoomMembers(room, 2);
|
||||
const { container } = render(<RoomHeader room={room} />, getWrapper());
|
||||
expect(getByLabelText(container, "Video call")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("should show call buttons in a room with more than 2 members", () => {
|
||||
mockRoomMembers(room, 3);
|
||||
const { container } = render(<RoomHeader room={room} />, getWrapper());
|
||||
expect(getByLabelText(container, "Video call")).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe("UIFeature.Widgets disabled", () => {
|
||||
beforeEach(() => {
|
||||
jest.spyOn(SettingsStore, "getValue").mockImplementation((feature) => false);
|
||||
});
|
||||
|
||||
it("should show call buttons in a room with 2 members", () => {
|
||||
mockRoomMembers(room, 2);
|
||||
const { container } = render(<RoomHeader room={room} />, getWrapper());
|
||||
expect(getByLabelText(container, "Video call")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("should not show call buttons in a room with more than 2 members", () => {
|
||||
mockRoomMembers(room, 3);
|
||||
const { container } = render(<RoomHeader room={room} />, getWrapper());
|
||||
expect(queryByLabelText(container, "Video call")).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe("groups call disabled", () => {
|
||||
beforeEach(() => {
|
||||
jest.spyOn(SettingsStore, "getValue").mockImplementation((feature) => feature == UIFeature.Widgets);
|
||||
});
|
||||
|
||||
it("you can't call if you're alone", () => {
|
||||
mockRoomMembers(room, 1);
|
||||
const { container } = render(<RoomHeader room={room} />, getWrapper());
|
||||
|
@ -313,7 +354,9 @@ describe("RoomHeader", () => {
|
|||
|
||||
describe("group call enabled", () => {
|
||||
beforeEach(() => {
|
||||
jest.spyOn(SettingsStore, "getValue").mockImplementation((feature) => feature === "feature_group_calls");
|
||||
jest.spyOn(SettingsStore, "getValue").mockImplementation(
|
||||
(feature) => feature === "feature_group_calls" || feature == UIFeature.Widgets,
|
||||
);
|
||||
});
|
||||
|
||||
it("renders only the video call element", async () => {
|
||||
|
@ -353,7 +396,7 @@ describe("RoomHeader", () => {
|
|||
|
||||
it("clicking on ongoing (unpinned) call re-pins it", () => {
|
||||
mockRoomMembers(room, 3);
|
||||
jest.spyOn(SettingsStore, "getValue").mockReturnValue(false);
|
||||
jest.spyOn(SettingsStore, "getValue").mockImplementation((feature) => feature == UIFeature.Widgets);
|
||||
// allow calls
|
||||
jest.spyOn(room.currentState, "mayClientSendStateEvent").mockReturnValue(true);
|
||||
jest.spyOn(WidgetLayoutStore.instance, "isInContainer").mockReturnValue(false);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue