Switch to the new session
API for screen-sharing (#25802)
This commit is contained in:
parent
a84349f969
commit
93e6ee11ab
3 changed files with 43 additions and 1 deletions
|
@ -21,6 +21,9 @@ import { Action } from "matrix-react-sdk/src/dispatcher/actions";
|
|||
import dispatcher from "matrix-react-sdk/src/dispatcher/dispatcher";
|
||||
import * as rageshake from "matrix-react-sdk/src/rageshake/rageshake";
|
||||
import { BreadcrumbsStore } from "matrix-react-sdk/src/stores/BreadcrumbsStore";
|
||||
import Modal from "matrix-react-sdk/src/Modal";
|
||||
import DesktopCapturerSourcePicker from "matrix-react-sdk/src/components/views/elements/DesktopCapturerSourcePicker";
|
||||
import { mocked } from "jest-mock";
|
||||
|
||||
import ElectronPlatform from "../../../../src/vector/platform/ElectronPlatform";
|
||||
|
||||
|
@ -76,6 +79,35 @@ describe("ElectronPlatform", () => {
|
|||
expect(dispatchFireSpy).toHaveBeenCalledWith(Action.ViewUserSettings);
|
||||
});
|
||||
|
||||
it("creates a modal on openDesktopCapturerSourcePicker", async () => {
|
||||
const plat = new ElectronPlatform();
|
||||
Modal.createDialog = jest.fn();
|
||||
|
||||
// @ts-ignore mock
|
||||
mocked(Modal.createDialog).mockReturnValue({
|
||||
finished: new Promise((r) => r(["source"])),
|
||||
});
|
||||
|
||||
let res: () => void;
|
||||
const waitForIPCSend = new Promise<void>((r) => {
|
||||
res = r;
|
||||
});
|
||||
// @ts-ignore mock
|
||||
jest.spyOn(plat.ipc, "call").mockImplementation(() => {
|
||||
res();
|
||||
});
|
||||
|
||||
const [event, handler] = getElectronEventHandlerCall("openDesktopCapturerSourcePicker")!;
|
||||
handler();
|
||||
|
||||
await waitForIPCSend;
|
||||
|
||||
expect(event).toBeTruthy();
|
||||
expect(Modal.createDialog).toHaveBeenCalledWith(DesktopCapturerSourcePicker);
|
||||
// @ts-ignore mock
|
||||
expect(plat.ipc.call).toHaveBeenCalledWith("callDisplayMediaCallback", "source");
|
||||
});
|
||||
|
||||
describe("updates", () => {
|
||||
it("dispatches on check updates action", () => {
|
||||
new ElectronPlatform();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue