[MM-55152] Add new Desktop API endpoints, improve preload script, some clean-up (#2900)

* Add constants for app info, add to API

* Migrate history button

* Converted calls API over to context bridge, removed some unnecessary logging

* Convert to TS, add types for web app to consume

* Fix tests, prune

* Fix lint

* More changes to support the legacy API

* Force legacy code off, add support for unreads/mentions/expired through the API

* Fix issues with cross-tab login, removed need for log in/log out signalling

* Fixed test, typos

* Change package name for types

* Add some other stuff to the types

* PR feedback

* More feedback

* Use npm package

* Change types and API to provide off listeners

* Version number

* Lock

* Fix typo

* Add sessionID for calls
This commit is contained in:
Devin Binnie
2023-12-13 09:39:46 -05:00
committed by GitHub
parent 675ec6d661
commit 0cab09b7f5
41 changed files with 1071 additions and 1040 deletions

View File

@@ -407,6 +407,7 @@ describe('main/views/viewManager', () => {
];
const view1 = {
id: 'server-1_view-messaging',
webContentsId: 1,
isLoggedIn: true,
view: {
type: TAB_MESSAGING,
@@ -415,10 +416,12 @@ describe('main/views/viewManager', () => {
},
},
sendToRenderer: jest.fn(),
updateHistoryButton: jest.fn(),
};
const view2 = {
...view1,
id: 'server-1_other_type_1',
webContentsId: 2,
view: {
...view1.view,
type: 'other_type_1',
@@ -427,6 +430,7 @@ describe('main/views/viewManager', () => {
const view3 = {
...view1,
id: 'server-1_other_type_2',
webContentsId: 3,
view: {
...view1.view,
type: 'other_type_2',
@@ -442,6 +446,7 @@ describe('main/views/viewManager', () => {
viewManager.getView = (viewId) => views.get(viewId);
viewManager.isViewClosed = (viewId) => closedViews.has(viewId);
viewManager.openClosedView = jest.fn();
viewManager.getViewByWebContentsId = (webContentsId) => [...views.values()].find((view) => view.webContentsId === webContentsId);
beforeEach(() => {
ServerManager.getAllServers.mockReturnValue(servers);
@@ -460,19 +465,19 @@ describe('main/views/viewManager', () => {
views.set(name, view);
});
ServerManager.lookupViewByURL.mockReturnValue({id: 'server-1_other_type_2'});
viewManager.handleBrowserHistoryPush(null, 'server-1_view-messaging', '/other_type_2/subpath');
viewManager.handleBrowserHistoryPush({sender: {id: 1}}, '/other_type_2/subpath');
expect(viewManager.openClosedView).toBeCalledWith('server-1_other_type_2', 'http://server-1.com/other_type_2/subpath');
});
it('should open redirect view if different from current view', () => {
ServerManager.lookupViewByURL.mockReturnValue({id: 'server-1_other_type_1'});
viewManager.handleBrowserHistoryPush(null, 'server-1_view-messaging', '/other_type_1/subpath');
viewManager.handleBrowserHistoryPush({sender: {id: 1}}, '/other_type_1/subpath');
expect(viewManager.showById).toBeCalledWith('server-1_other_type_1');
});
it('should ignore redirects to "/" to Messages from other views', () => {
ServerManager.lookupViewByURL.mockReturnValue({id: 'server-1_view-messaging'});
viewManager.handleBrowserHistoryPush(null, 'server-1_other_type_1', '/');
viewManager.handleBrowserHistoryPush({sender: {id: 2}}, '/');
expect(view1.sendToRenderer).not.toBeCalled();
});
});