Skip to content

Commit

Permalink
SDA-4770 Expose openfin (#2264)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbenmoussati authored Jan 16, 2025
1 parent 8a6704b commit b27faed
Show file tree
Hide file tree
Showing 20 changed files with 730 additions and 5 deletions.
8 changes: 7 additions & 1 deletion config/Symphony.config
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,11 @@
"userDataPath": "",
"chromeFlags": "",
"betaAutoUpdateChannelEnabled": true,
"latestAutoUpdateChannelEnabled": true
"latestAutoUpdateChannelEnabled": true,
"openfin": {
"uuid": "",
"licenseKey": "",
"runtimeVersion": "",
"autoConnect": false
}
}
8 changes: 8 additions & 0 deletions installer/mac/postinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ if [ "$EUID" -ne 0 ]; then
defaults write "$plistFilePath" betaAutoUpdateChannelEnabled -bool true
defaults write "$plistFilePath" latestAutoUpdateChannelEnabled -bool true
defaults write "$plistFilePath" installVariant -string "$uuid"
defaults write "$plistFilePath" uuid -string ""
defaults write "$plistFilePath" licenseKey -string ""
defaults write "$plistFilePath" runtimeVersion -string ""
defaults write "$plistFilePath" autoConnect -bool false
else
sudo -u "$userName" defaults write "$plistFilePath" url -string "$pod_url"
sudo -u "$userName" defaults write "$plistFilePath" autoUpdateUrl -string ""
Expand Down Expand Up @@ -168,6 +172,10 @@ else
sudo -u "$userName" defaults write "$plistFilePath" betaAutoUpdateChannelEnabled -bool true
sudo -u "$userName" defaults write "$plistFilePath" latestAutoUpdateChannelEnabled -bool true
sudo -u "$userName" defaults write "$plistFilePath" installVariant -string "$uuid"
sudo -u "$userName" defaults write "$plistFilePath" uuid -string ""
sudo -u "$userName" defaults write "$plistFilePath" licenseKey -string ""
sudo -u "$userName" defaults write "$plistFilePath" runtimeVersion -string ""
sudo -u "$userName" defaults write "$plistFilePath" autoConnect -bool false
fi

## Remove the temp settings & permissions file created ##
Expand Down
56 changes: 54 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@
"typescript": "^4.9.5"
},
"dependencies": {
"@openfin/node-adapter": "^40.101.1",
"@types/lazy-brush": "^1.0.0",
"adm-zip": "^0.5.10",
"bplist-parser": "^0.3.2",
Expand Down
1 change: 1 addition & 0 deletions spec/config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ describe('config', () => {
'latestAutoUpdateChannelEnabled',
'betaAutoUpdateChannelEnabled',
'browserLoginRetryTimeout',
'openfin',
];
const globalConfig: object = { url: 'test' };
const userConfig: object = { configVersion: '4.0.1' };
Expand Down
4 changes: 4 additions & 0 deletions spec/dialogHandler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ jest.mock('../src/renderer/notification', () => {
};
});

jest.mock('@openfin/node-adapter', () => ({
connect: jest.fn(),
}));

jest.mock('electron-log');

describe('dialog handler', () => {
Expand Down
158 changes: 158 additions & 0 deletions spec/mainApiHandler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { activityDetection } from '../src/app/activity-detection';
import * as c9PipeHandler from '../src/app/c9-pipe-handler';
import { downloadHandler } from '../src/app/download-handler';
import '../src/app/main-api-handler';
import { openfinHandler } from '../src/app/openfin-handler';
import { protocolHandler } from '../src/app/protocol-handler';
import { screenSnippet } from '../src/app/screen-snippet-handler';
import * as windowActions from '../src/app/window-actions';
Expand All @@ -10,9 +11,56 @@ import * as utils from '../src/app/window-utils';
import { apiCmds, apiName } from '../src/common/api-interface';
import { logger } from '../src/common/logger';
import { BrowserWindow, ipcMain } from './__mocks__/electron';
import { connect } from '@openfin/node-adapter';

jest.mock('electron-log');

jest.mock('../src/app/openfin-handler', () => {
return {
openfinHandler: {
connect: jest.fn(),
fireIntent: jest.fn(),
joinContextGroup: jest.fn(),
getContextGroups: jest.fn(),
getConnectionStatus: jest.fn(),
getInfo: jest.fn(),
getAllClientsInContextGroup: jest.fn(),
registerIntentHandler: jest.fn(),
unregisterIntentHandler: jest.fn(),
},
};
});

jest.mock('@openfin/node-adapter', () => ({
connect: jest.fn(),
}));

(connect as jest.Mock).mockResolvedValue({
Interop: {
connectSync: jest.fn().mockReturnValue({
onDisconnection: jest.fn(),
fireIntent: jest.fn(),
registerIntentHandler: jest.fn(),
}),
},
});

jest.mock('../src/app/config-handler', () => {
return {
config: {
getConfigFields: jest.fn(() => {
return {
openfin: {
uuid: 'some-uuid',
licenseKey: 'some-license-key',
runtimeVersion: 'some-runtime-version',
},
};
}),
},
};
});

jest.mock('../src/app/protocol-handler', () => {
return {
protocolHandler: {
Expand Down Expand Up @@ -553,4 +601,114 @@ describe('main api handler', () => {
expect(spy).toBeCalledWith(...expectedValue);
});
});

describe('openfin api events', () => {
beforeEach(() => {
(connect as jest.Mock).mockResolvedValue({
Interop: {
connectSync: jest.fn().mockReturnValue({
onDisconnection: jest.fn(),
}),
},
});
(windowHandler.getMainWebContents as jest.Mock).mockReturnValue({
send: jest.fn(),
});
});

afterEach(() => {
jest.clearAllMocks();
});

it('should call `connect` correctly', () => {
const spy = jest.spyOn(openfinHandler, 'connect');
const value = {
cmd: apiCmds.openfinConnect,
};

ipcMain.send(apiName.symphonyApi, value);

expect(spy).toHaveBeenCalledTimes(1);
});

it('should call `fireIntent`', () => {
const spy = jest.spyOn(openfinHandler, 'fireIntent');
const value = {
cmd: apiCmds.openfinFireIntent,
intent: {
name: 'ViewContact',
context: {
type: 'fdc3.contact',
name: 'Andy Young',
id: {
email: '[email protected]',
},
},
},
};

ipcMain.send(apiName.symphonyApi, value);

expect(spy).toHaveBeenCalledTimes(1);
});

it('should call `registerIntentHandler`', () => {
const spy = jest.spyOn(openfinHandler, 'registerIntentHandler');
const value = {
cmd: apiCmds.openfinRegisterIntentHandler,
intentName: 'ViewContact',
};

ipcMain.send(apiName.symphonyApi, value);

expect(spy).toHaveBeenCalledTimes(1);
});

it('should call `unregisterIntentHandler`', () => {
const spy = jest.spyOn(openfinHandler, 'unregisterIntentHandler');
const value = {
cmd: apiCmds.openfinUnregisterIntentHandler,
intentName: 'ViewContact',
};

ipcMain.send(apiName.symphonyApi, value);

expect(spy).toHaveBeenCalledTimes(1);
});

it('should call `joinContextGroup`', () => {
const spy = jest.spyOn(openfinHandler, 'joinContextGroup');
const value = {
cmd: apiCmds.openfinJoinContextGroup,
contextGroupId: 'group-id',
};

ipcMain.send(apiName.symphonyApi, value);

expect(spy).toHaveBeenCalledTimes(1);
});

it('should call `getContextGroups`', () => {
const spy = jest.spyOn(openfinHandler, 'getContextGroups');
const value = {
cmd: apiCmds.openfinGetContextGroups,
};

ipcMain.send(apiName.symphonyApi, value);

expect(spy).toHaveBeenCalledTimes(1);
});

it('should call `getAllClientsInContextGroup`', () => {
const spy = jest.spyOn(openfinHandler, 'getAllClientsInContextGroup');
const value = {
cmd: apiCmds.openfinGetAllClientsInContextGroup,
contextGroupId: 'group-id',
};

ipcMain.send(apiName.symphonyApi, value);

expect(spy).toHaveBeenCalledTimes(1);
});
});
});
Loading

0 comments on commit b27faed

Please sign in to comment.