SDA-1924 - Add new fields for about-app window (#958)

This commit is contained in:
Kiran Niranjan 2020-03-31 17:28:51 +05:30 committed by GitHub
parent cb7aedaf11
commit 5338649aaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 65 additions and 11 deletions

View File

@ -173,6 +173,13 @@ const getCurrentWindow = jest.fn(() => {
};
});
const clipboard = {
write: jest.fn(),
readTest: jest.fn(() => {
return '';
}),
};
export const dialog = {
showMessageBox: jest.fn(),
showErrorBox: jest.fn(),
@ -198,4 +205,5 @@ export const session = {
export const remote = {
app,
getCurrentWindow,
clipboard,
};

View File

@ -39,6 +39,13 @@ exports[`about app should render correctly 1`] = `
<ul
className="AboutApp-symphony-section"
>
<li>
<b>
POD:
</b>
N/A
</li>
<li>
<b>
SBE:

View File

@ -1,14 +1,21 @@
import { shallow } from 'enzyme';
import * as React from 'react';
import AboutApp from '../src/renderer/components/about-app';
import { ipcRenderer } from './__mocks__/electron';
import { ipcRenderer, remote } from './__mocks__/electron';
describe('about app', () => {
const aboutAppDataLabel = 'about-app-data';
const aboutDataMock = {
buildNumber: '4.x.x',
userConfig: {},
globalConfig: {},
cloudConfig: {},
finalConfig: {},
appName: 'Symphony',
versionLocalised: 'Version',
clientVersion: '1',
version: 'x.x.x',
buildNumber: '4.x.x',
hostname: 'N/A',
sfeVersion: 'N/A',
sdaVersion: '3.8.0',
sdaBuildNumber: '0',
electronVersion: '3.1.11',
@ -21,7 +28,7 @@ describe('about app', () => {
aresVersion: '9.10',
httpParserVersion: '11.12',
swiftSearchVersion: '1.55.3-beta.1',
swiftSerchSupportedVersion: '1.55.3',
swiftSearchSupportedVersion: 'N/A',
};
const onLabelEvent = 'on';
const removeListenerLabelEvent = 'removeListener';
@ -52,4 +59,14 @@ describe('about app', () => {
ipcRenderer.send('about-app-data', aboutDataMock);
expect(spy).toBeCalledWith(aboutDataMock);
});
it('should copy the correct data on to clipboard', () => {
const spyMount = jest.spyOn(remote.clipboard, 'write');
const wrapper = shallow(React.createElement(AboutApp));
ipcRenderer.send('about-app-data', aboutDataMock);
const copyButtonSelector = `button.AboutApp-copy-button[title="Copy all the version information in this page"]`;
wrapper.find(copyButtonSelector).simulate('click');
const expectedData = { text: JSON.stringify(aboutDataMock, null, 4) };
expect(spyMount).toBeCalledWith(expectedData, 'clipboard');
});
});

View File

@ -108,10 +108,10 @@ export interface ICustomRectangle extends Partial<Electron.Rectangle> {
}
class Config {
private userConfig: IConfig | {};
private globalConfig: IConfig | {};
private cloudConfig: ICloudConfig | {};
private filteredCloudConfig: ICloudConfig | {};
public userConfig: IConfig | {};
public globalConfig: IConfig | {};
public cloudConfig: ICloudConfig | {};
public filteredCloudConfig: ICloudConfig | {};
private isFirstTime: boolean = true;
private readonly configFileName: string;
private readonly userConfigPath: string;

View File

@ -524,7 +524,7 @@ export class WindowHandler {
const opts: BrowserWindowConstructorOptions = this.getWindowOpts({
width: 440,
height: 305,
height: 315,
modal: true,
alwaysOnTop: isMac,
resizable: false,
@ -547,7 +547,18 @@ export class WindowHandler {
this.aboutAppWindow.webContents.once('did-finish-load', async () => {
const ABOUT_SYMPHONY_NAMESPACE = 'AboutSymphony';
const versionLocalised = i18n.t('Version', ABOUT_SYMPHONY_NAMESPACE)();
const { hostname } = parse(this.url || this.globalConfig.url);
const userConfig = config.userConfig;
const globalConfig = config.globalConfig;
const cloudConfig = config.cloudConfig;
const filteredConfig = config.filteredCloudConfig;
const finalConfig = { ...globalConfig, ...userConfig, ...filteredConfig };
const aboutInfo = {
userConfig,
globalConfig,
cloudConfig,
finalConfig,
hostname,
buildNumber: versionHandler.versionInfo.buildNumber,
clientVersion: versionHandler.versionInfo.clientVersion,
sfeVersion: versionHandler.versionInfo.sfeVersion,

View File

@ -3,10 +3,15 @@ import * as React from 'react';
import { i18n } from '../../common/i18n-preload';
interface IState {
userConfig: object;
globalConfig: object;
cloudConfig: object;
finalConfig: object;
appName: string;
copyWrite?: string;
clientVersion: string;
buildNumber: string;
hostname: string;
sfeVersion: string;
versionLocalised?: string;
sdaVersion?: string;
@ -38,10 +43,15 @@ export default class AboutApp extends React.Component<{}, IState> {
constructor(props) {
super(props);
this.state = {
userConfig: {},
globalConfig: {},
cloudConfig: {},
finalConfig: {},
appName: 'Symphony',
versionLocalised: 'Version',
clientVersion: 'N/A',
buildNumber: 'N/A',
hostname: 'N/A',
sfeVersion: 'N/A',
sdaVersion: 'N/A',
sdaBuildNumber: 'N/A',
@ -64,7 +74,7 @@ export default class AboutApp extends React.Component<{}, IState> {
* main render function
*/
public render(): JSX.Element {
const { clientVersion, buildNumber, sfeVersion,
const { clientVersion, buildNumber, hostname, sfeVersion,
sdaVersion, sdaBuildNumber,
} = this.state;
@ -90,6 +100,7 @@ export default class AboutApp extends React.Component<{}, IState> {
<div className='AboutApp-main-container'>
<section>
<ul className='AboutApp-symphony-section'>
<li><b>POD:</b> {hostname || 'N/A'}</li>
<li><b>SBE:</b> {podVersion}</li>
<li><b>SDA:</b> {sdaVersionBuild}</li>
<li><b>SFE:</b> {sfeVersion}</li>
@ -121,7 +132,7 @@ export default class AboutApp extends React.Component<{}, IState> {
public copy(): void {
const data = this.state;
if (data) {
remote.clipboard.write({ text: JSON.stringify(data) }, 'clipboard' );
remote.clipboard.write({ text: JSON.stringify(data, null, 4) }, 'clipboard' );
}
}