mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
C2-9049: Zoom restriction in SDA (#1196)
This commit is contained in:
@@ -3,6 +3,7 @@ import { autoLaunchInstance } from '../src/app/auto-launch-controller';
|
||||
import { config } from '../src/app/config-handler';
|
||||
import { exportCrashDumps, exportLogs } from '../src/app/reports-handler';
|
||||
import { updateAlwaysOnTop } from '../src/app/window-actions';
|
||||
import { zoomIn, zoomOut } from '../src/app/window-utils';
|
||||
import * as envMock from '../src/common/env';
|
||||
import { logger } from '../src/common/logger';
|
||||
import { dialog, session, shell } from './__mocks__/electron';
|
||||
@@ -80,6 +81,7 @@ jest.mock('../src/app/window-handler', () => {
|
||||
windowHandler: {
|
||||
createMoreInfoWindow: jest.fn(),
|
||||
getMainWindow: jest.fn(),
|
||||
isMana: true,
|
||||
},
|
||||
};
|
||||
});
|
||||
@@ -93,6 +95,14 @@ jest.mock('../src/common/logger', () => {
|
||||
};
|
||||
});
|
||||
|
||||
jest.mock('../src/app/window-utils', () => {
|
||||
return {
|
||||
windowExists: jest.fn(() => true),
|
||||
zoomIn: jest.fn(),
|
||||
zoomOut: jest.fn(),
|
||||
};
|
||||
});
|
||||
|
||||
describe('app menu', () => {
|
||||
let appMenu;
|
||||
const updateUserFnLabel = 'updateUserConfig';
|
||||
@@ -112,6 +122,12 @@ describe('app menu', () => {
|
||||
});
|
||||
};
|
||||
|
||||
const findMenuItemBuildViewMenu = (menuItemLabel: string) => {
|
||||
return appMenu.buildViewMenu().submenu.find((menuItem) => {
|
||||
return menuItem.label === menuItemLabel;
|
||||
});
|
||||
};
|
||||
|
||||
const findHelpTroubleshootingMenuItem = (value: string) => {
|
||||
const helpMenuItem = findMenuItemBuildHelpMenu('Troubleshooting');
|
||||
return helpMenuItem.submenu.find((menuItem) => {
|
||||
@@ -364,5 +380,27 @@ describe('app menu', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('buildViewMenu', () => {
|
||||
it('should call zoomIn when click is triggered', () => {
|
||||
const focusedWindow = {
|
||||
isDestroyed: jest.fn(() => false),
|
||||
reload: jest.fn(),
|
||||
};
|
||||
const menuItem = findMenuItemBuildViewMenu('Zoom In');
|
||||
menuItem.click(item, focusedWindow);
|
||||
expect(zoomIn).toBeCalled();
|
||||
});
|
||||
|
||||
it('should call zoomOut when click is triggered', () => {
|
||||
const focusedWindow = {
|
||||
isDestroyed: jest.fn(() => false),
|
||||
reload: jest.fn(),
|
||||
};
|
||||
const menuItem = findMenuItemBuildViewMenu('Zoom Out');
|
||||
menuItem.click(item, focusedWindow);
|
||||
expect(zoomOut).toBeCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -45,6 +45,10 @@ jest.mock('../src/app/window-handler', () => {
|
||||
isOnline: false,
|
||||
updateVersionInfo: jest.fn(),
|
||||
isMana: false,
|
||||
appMenu: {
|
||||
buildMenu: jest.fn(),
|
||||
},
|
||||
getMainWindow: jest.fn(),
|
||||
},
|
||||
};
|
||||
});
|
||||
@@ -67,6 +71,7 @@ jest.mock('../src/common/logger', () => {
|
||||
logger: {
|
||||
setLoggerWindow: jest.fn(),
|
||||
error: jest.fn(),
|
||||
info: jest.fn(),
|
||||
},
|
||||
};
|
||||
});
|
||||
@@ -84,6 +89,11 @@ jest.mock('../src/app/config-handler', () => {
|
||||
bringToFront: 'ENABLED',
|
||||
};
|
||||
}),
|
||||
getFilteredCloudConfigFields: jest.fn(() => {
|
||||
return {
|
||||
devToolsEnabled: true,
|
||||
};
|
||||
}),
|
||||
},
|
||||
};
|
||||
});
|
||||
@@ -116,8 +126,6 @@ jest.mock('../src/app/notifications/notification-helper', () => {
|
||||
};
|
||||
});
|
||||
|
||||
jest.mock('../src/common/i18n');
|
||||
|
||||
describe('main api handler', () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
@@ -429,5 +437,26 @@ describe('main api handler', () => {
|
||||
ipcMain.send(apiName.symphonyApi, value);
|
||||
expect(windowHandler.isMana).toBe(true);
|
||||
});
|
||||
it('should call build menu when ismana set to true', () => {
|
||||
const value = {
|
||||
cmd: apiCmds.setIsMana,
|
||||
isMana: true,
|
||||
};
|
||||
ipcMain.send(apiName.symphonyApi, value);
|
||||
if (windowHandler.appMenu) {
|
||||
expect(windowHandler.appMenu.buildMenu).toBeCalled();
|
||||
}
|
||||
});
|
||||
|
||||
it('should not call build menu when ismana set to false', () => {
|
||||
const value = {
|
||||
cmd: apiCmds.setIsMana,
|
||||
isMana: false,
|
||||
};
|
||||
ipcMain.send(apiName.symphonyApi, value);
|
||||
if (windowHandler.appMenu) {
|
||||
expect(windowHandler.appMenu.buildMenu).not.toBeCalled();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user