[MM-57964] Implement openThread and openStopRecordingModal (#3073)

* Implement API to open thread from Calls widget

* Stop recording modal

* Rename
This commit is contained in:
Claudio Costa
2024-06-20 18:42:21 +02:00
committed by GitHub
parent d3a76caeef
commit c0e2b2a0e7
7 changed files with 100 additions and 1 deletions

View File

@@ -4,7 +4,13 @@
import {BrowserWindow, desktopCapturer, systemPreferences, ipcMain} from 'electron';
import ServerViewState from 'app/serverViewState';
import {CALLS_WIDGET_SHARE_SCREEN, BROWSER_HISTORY_PUSH, UPDATE_SHORTCUT_MENU} from 'common/communication';
import {
CALLS_WIDGET_SHARE_SCREEN,
BROWSER_HISTORY_PUSH,
UPDATE_SHORTCUT_MENU,
CALLS_WIDGET_OPEN_THREAD,
CALLS_WIDGET_OPEN_STOP_RECORDING_MODAL,
} from 'common/communication';
import {
MINIMUM_CALLS_WIDGET_WIDTH,
MINIMUM_CALLS_WIDGET_HEIGHT,
@@ -848,4 +854,63 @@ describe('main/windows/callsWidgetWindow', () => {
expect(callsWidgetWindow.isOpen()).toBe(false);
});
});
describe('handleCallsOpenThread', () => {
const view = {
view: {
server: {
id: 'server-1',
},
},
sendToRenderer: jest.fn(),
};
const callsWidgetWindow = new CallsWidgetWindow();
callsWidgetWindow.mainView = view;
callsWidgetWindow.win = {webContents: {id: 1}};
const focus = jest.fn();
beforeEach(() => {
MainWindow.get.mockReturnValue({focus});
ViewManager.getView.mockReturnValue(view);
ViewManager.handleDeepLink = jest.fn();
});
it('should switch server, focus and send open thread event', () => {
const threadID = 'call-thread-id';
callsWidgetWindow.handleCallsOpenThread({sender: {id: 1}}, threadID);
expect(ServerViewState.switchServer).toHaveBeenCalledWith('server-1');
expect(focus).toHaveBeenCalled();
expect(view.sendToRenderer).toBeCalledWith(CALLS_WIDGET_OPEN_THREAD, threadID);
});
});
describe('handleCallsOpenStopRecordingModal', () => {
const view = {
view: {
server: {
id: 'server-1',
},
},
sendToRenderer: jest.fn(),
};
const callsWidgetWindow = new CallsWidgetWindow();
callsWidgetWindow.mainView = view;
callsWidgetWindow.win = {webContents: {id: 1}};
const focus = jest.fn();
beforeEach(() => {
MainWindow.get.mockReturnValue({focus});
ViewManager.getView.mockReturnValue(view);
});
it('should switch server, focus and send open modal event', () => {
const channelID = 'call-channel-id';
callsWidgetWindow.handleCallsOpenStopRecordingModal({sender: {id: 1}}, channelID);
expect(ServerViewState.switchServer).toHaveBeenCalledWith('server-1');
expect(focus).toHaveBeenCalled();
expect(view.sendToRenderer).toBeCalledWith(CALLS_WIDGET_OPEN_STOP_RECORDING_MODAL, channelID);
});
});
});