change logic of when to show the call and share button. (#12385)
Allow starting calls in rooms with only one person if one can add invite others with a call link. Signed-off-by: Timo K <toger5@hotmail.de>
This commit is contained in:
parent
307d737555
commit
015b9386e1
2 changed files with 32 additions and 5 deletions
|
@ -33,6 +33,7 @@ import {
|
|||
getByLabelText,
|
||||
getByRole,
|
||||
getByText,
|
||||
queryAllByLabelText,
|
||||
render,
|
||||
RenderOptions,
|
||||
screen,
|
||||
|
@ -83,7 +84,6 @@ describe("RoomHeader", () => {
|
|||
);
|
||||
|
||||
let room: Room;
|
||||
|
||||
const ROOM_ID = "!1:example.org";
|
||||
|
||||
let setCardSpy: jest.SpyInstance | undefined;
|
||||
|
@ -371,7 +371,7 @@ describe("RoomHeader", () => {
|
|||
}
|
||||
});
|
||||
|
||||
it("can't call if you have no friends", () => {
|
||||
it("can't call if you have no friends and cannot invite friends", () => {
|
||||
mockRoomMembers(room, 1);
|
||||
const { container } = render(<RoomHeader room={room} />, getWrapper());
|
||||
for (const button of getAllByLabelText(container, "There's no one here to call")) {
|
||||
|
@ -379,6 +379,29 @@ describe("RoomHeader", () => {
|
|||
}
|
||||
});
|
||||
|
||||
it("can call if you have no friends but can invite friends", () => {
|
||||
mockRoomMembers(room, 1);
|
||||
// go through all the different `canInvite` and `getJoinRule` combinations
|
||||
jest.spyOn(room, "getJoinRule").mockReturnValue(JoinRule.Invite);
|
||||
jest.spyOn(room, "canInvite").mockReturnValue(false);
|
||||
const { container: containerNoInviteNotPublic } = render(<RoomHeader room={room} />, getWrapper());
|
||||
expect(queryAllByLabelText(containerNoInviteNotPublic, "There's no one here to call")).toHaveLength(2);
|
||||
jest.spyOn(room, "getJoinRule").mockReturnValue(JoinRule.Knock);
|
||||
jest.spyOn(room, "canInvite").mockReturnValue(false);
|
||||
const { container: containerNoInvitePublic } = render(<RoomHeader room={room} />, getWrapper());
|
||||
expect(queryAllByLabelText(containerNoInvitePublic, "There's no one here to call")).toHaveLength(2);
|
||||
|
||||
jest.spyOn(room, "canInvite").mockReturnValue(true);
|
||||
jest.spyOn(room, "getJoinRule").mockReturnValue(JoinRule.Invite);
|
||||
const { container: containerInviteNotPublic } = render(<RoomHeader room={room} />, getWrapper());
|
||||
expect(queryAllByLabelText(containerInviteNotPublic, "There's no one here to call")).toHaveLength(2);
|
||||
|
||||
jest.spyOn(room, "getJoinRule").mockReturnValue(JoinRule.Knock);
|
||||
jest.spyOn(room, "canInvite").mockReturnValue(true);
|
||||
const { container: containerInvitePublic } = render(<RoomHeader room={room} />, getWrapper());
|
||||
expect(queryAllByLabelText(containerInvitePublic, "There's no one here to call")).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("calls using legacy or jitsi", async () => {
|
||||
mockRoomMembers(room, 2);
|
||||
jest.spyOn(room.currentState, "mayClientSendStateEvent").mockImplementation((key) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue