Remove WindowManager, separate functionality into smaller modules (#2682)

* Move sendToRenderer to respective singletons

* Move to using ViewManager call for getting view by webContentsId

* Move show and create logic to main window, handle deep linking seperately

* Move resizing logic and event handing to mainWindow

* Move server switching logic to main/app

* Move tab switching logic to main/app, rely on showById for most usage

* Migrate remaining functions, remove windowManager objects, set up imports for self-contained singletons

* Fix E2E tests

* Update src/main/app/servers.ts

Co-authored-by: Elias Nahum <nahumhbl@gmail.com>

---------

Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
This commit is contained in:
Devin Binnie
2023-04-19 11:04:26 -04:00
committed by GitHub
parent a141d3cde4
commit f4f4511cc7
57 changed files with 1089 additions and 1640 deletions

View File

@@ -36,6 +36,7 @@ jest.mock('electron', () => ({
BrowserWindow: jest.fn(),
ipcMain: {
handle: jest.fn(),
on: jest.fn(),
},
screen: {
getDisplayMatching: jest.fn(),
@@ -469,6 +470,39 @@ describe('main/windows/mainWindow', () => {
});
});
describe('show', () => {
const mainWindow = new MainWindow();
mainWindow.win = {
visible: false,
isVisible: () => mainWindow.visible,
show: jest.fn(),
focus: jest.fn(),
on: jest.fn(),
once: jest.fn(),
webContents: {
setWindowOpenHandler: jest.fn(),
},
};
beforeEach(() => {
mainWindow.win.show.mockImplementation(() => {
mainWindow.visible = true;
});
});
afterEach(() => {
jest.resetAllMocks();
});
it('should show main window if it exists and focus it if it is already visible', () => {
mainWindow.show();
expect(mainWindow.win.show).toHaveBeenCalled();
mainWindow.show();
expect(mainWindow.win.focus).toHaveBeenCalled();
});
});
describe('onUnresponsive', () => {
const mainWindow = new MainWindow();