New Header edgecase fixes: Close lobby button not shown, disable join button in various places, more... (#12235)
* Add missing tooltip Signed-off-by: Timo K <toger5@hotmail.de> * fix incoming call toast (icon + disabled button if there is an ongoing call) Signed-off-by: Timo K <toger5@hotmail.de> * room header - fix join button not getting disabled if there is an ongoing call - fix close lobby button not shown (instead we see the join button) Signed-off-by: Timo K <toger5@hotmail.de> * additional tests Signed-off-by: Timo K <toger5@hotmail.de> * fix tests Signed-off-by: Timo K <toger5@hotmail.de> * update snapshot Signed-off-by: Timo K <toger5@hotmail.de> * fix not open menu if disabled Signed-off-by: Timo K <toger5@hotmail.de> * add tooltip provider Signed-off-by: Timo K <toger5@hotmail.de> * update snap class Signed-off-by: Timo K <toger5@hotmail.de> * room header snap update Signed-off-by: Timo K <toger5@hotmail.de> * fix snapshot Signed-off-by: Timo K <toger5@hotmail.de> --------- Signed-off-by: Timo K <toger5@hotmail.de>
This commit is contained in:
parent
1c789cbb18
commit
552c65db98
5 changed files with 132 additions and 53 deletions
|
@ -55,7 +55,9 @@ import { Call, ElementCall } from "../../../../src/models/Call";
|
|||
import * as ShieldUtils from "../../../../src/utils/ShieldUtils";
|
||||
import { Container, WidgetLayoutStore } from "../../../../src/stores/widgets/WidgetLayoutStore";
|
||||
import MatrixClientContext from "../../../../src/contexts/MatrixClientContext";
|
||||
|
||||
import * as UseCall from "../../../../src/hooks/useCall";
|
||||
import { SdkContextClass } from "../../../../src/contexts/SDKContext";
|
||||
import WidgetStore, { IApp } from "../../../../src/stores/WidgetStore";
|
||||
jest.mock("../../../../src/utils/ShieldUtils");
|
||||
|
||||
function getWrapper(): RenderOptions {
|
||||
|
@ -322,25 +324,30 @@ describe("RoomHeader", () => {
|
|||
// allow element calls
|
||||
jest.spyOn(room.currentState, "mayClientSendStateEvent").mockReturnValue(true);
|
||||
jest.spyOn(WidgetLayoutStore.instance, "isInContainer").mockReturnValue(true);
|
||||
|
||||
jest.spyOn(CallStore.instance, "getCall").mockReturnValue({ widget: {}, on: () => {} } as unknown as Call);
|
||||
|
||||
const widget = { type: "m.jitsi" } as IApp;
|
||||
jest.spyOn(CallStore.instance, "getCall").mockReturnValue({
|
||||
widget,
|
||||
on: () => {},
|
||||
} as unknown as Call);
|
||||
jest.spyOn(WidgetStore.instance, "getApps").mockReturnValue([widget]);
|
||||
const { container } = render(<RoomHeader room={room} />, getWrapper());
|
||||
expect(getByLabelText(container, "Ongoing call")).toHaveAttribute("aria-disabled", "true");
|
||||
});
|
||||
|
||||
it("clicking on ongoing (unpinned) call re-pins it", () => {
|
||||
jest.spyOn(SdkConfig, "get").mockReturnValue({ use_exclusively: true });
|
||||
mockRoomMembers(room, 3);
|
||||
jest.spyOn(SettingsStore, "getValue").mockReturnValue(false);
|
||||
// allow calls
|
||||
jest.spyOn(room.currentState, "mayClientSendStateEvent").mockReturnValue(true);
|
||||
jest.spyOn(WidgetLayoutStore.instance, "isInContainer").mockReturnValue(false);
|
||||
const spy = jest.spyOn(WidgetLayoutStore.instance, "moveToContainer");
|
||||
|
||||
const widget = {};
|
||||
const widget = { type: "m.jitsi" } as IApp;
|
||||
jest.spyOn(CallStore.instance, "getCall").mockReturnValue({
|
||||
widget,
|
||||
on: () => {},
|
||||
} as unknown as Call);
|
||||
jest.spyOn(WidgetStore.instance, "getApps").mockReturnValue([widget]);
|
||||
|
||||
const { container } = render(<RoomHeader room={room} />, getWrapper());
|
||||
expect(getByLabelText(container, "Video call")).not.toHaveAttribute("aria-disabled", "true");
|
||||
|
@ -431,6 +438,57 @@ describe("RoomHeader", () => {
|
|||
fireEvent.click(videoButton);
|
||||
expect(dispatcherSpy).toHaveBeenCalledWith(expect.objectContaining({ view_call: true }));
|
||||
});
|
||||
|
||||
it("buttons are disabled if there is an ongoing call", async () => {
|
||||
mockRoomMembers(room, 3);
|
||||
|
||||
jest.spyOn(CallStore.prototype, "activeCalls", "get").mockReturnValue(
|
||||
new Set([{ roomId: "some_other_room" } as Call]),
|
||||
);
|
||||
const { container } = render(<RoomHeader room={room} />, getWrapper());
|
||||
|
||||
const [videoButton, voiceButton] = getAllByLabelText(container, "Ongoing call");
|
||||
|
||||
expect(voiceButton).toHaveAttribute("aria-disabled", "true");
|
||||
expect(videoButton).toHaveAttribute("aria-disabled", "true");
|
||||
});
|
||||
|
||||
it("join button is shown if there is an ongoing call", async () => {
|
||||
mockRoomMembers(room, 3);
|
||||
jest.spyOn(UseCall, "useParticipantCount").mockReturnValue(3);
|
||||
const { container } = render(<RoomHeader room={room} />, getWrapper());
|
||||
const joinButton = getByLabelText(container, "Join");
|
||||
expect(joinButton).not.toHaveAttribute("aria-disabled", "true");
|
||||
});
|
||||
|
||||
it("join button is disabled if there is an other ongoing call", async () => {
|
||||
mockRoomMembers(room, 3);
|
||||
jest.spyOn(UseCall, "useParticipantCount").mockReturnValue(3);
|
||||
jest.spyOn(CallStore.prototype, "activeCalls", "get").mockReturnValue(
|
||||
new Set([{ roomId: "some_other_room" } as Call]),
|
||||
);
|
||||
const { container } = render(<RoomHeader room={room} />, getWrapper());
|
||||
const joinButton = getByLabelText(container, "Ongoing call");
|
||||
|
||||
expect(joinButton).toHaveAttribute("aria-disabled", "true");
|
||||
});
|
||||
|
||||
it("close lobby button is shown", async () => {
|
||||
mockRoomMembers(room, 3);
|
||||
|
||||
jest.spyOn(SdkContextClass.instance.roomViewStore, "isViewingCall").mockReturnValue(true);
|
||||
const { container } = render(<RoomHeader room={room} />, getWrapper());
|
||||
getByLabelText(container, "Close lobby");
|
||||
});
|
||||
|
||||
it("close lobby button is shown if there is an ongoing call but we are viewing the lobby", async () => {
|
||||
mockRoomMembers(room, 3);
|
||||
jest.spyOn(UseCall, "useParticipantCount").mockReturnValue(3);
|
||||
jest.spyOn(SdkContextClass.instance.roomViewStore, "isViewingCall").mockReturnValue(true);
|
||||
|
||||
const { container } = render(<RoomHeader room={room} />, getWrapper());
|
||||
getByLabelText(container, "Close lobby");
|
||||
});
|
||||
});
|
||||
|
||||
describe("public room", () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue