mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-12-26 00:41:11 -06:00
SDA-4606 Setting programmatically default values of new config fields (#2171)
* SDA-4606 Setting programmatically default values of new config fields * Upgrade electron to patch reported file picker issue
This commit is contained in:
parent
afef6e77c1
commit
defcd1a90a
@ -178,7 +178,7 @@
|
|||||||
"builder-util-runtime": "^9.0.3",
|
"builder-util-runtime": "^9.0.3",
|
||||||
"cross-env": "7.0.3",
|
"cross-env": "7.0.3",
|
||||||
"del": "3.0.0",
|
"del": "3.0.0",
|
||||||
"electron": "31.1.0",
|
"electron": "31.2.0",
|
||||||
"electron-builder": "^24.13.2",
|
"electron-builder": "^24.13.2",
|
||||||
"electron-devtools-installer": "^3.2.0",
|
"electron-devtools-installer": "^3.2.0",
|
||||||
"electron-icon-maker": "0.0.5",
|
"electron-icon-maker": "0.0.5",
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as os from 'os';
|
import * as os from 'os';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import { IConfig, IGlobalConfig } from '../src/app/config-handler';
|
import {
|
||||||
|
ConfigFieldsDefaultValues,
|
||||||
|
IConfig,
|
||||||
|
IGlobalConfig,
|
||||||
|
} from '../src/app/config-handler';
|
||||||
|
|
||||||
jest.mock('electron-log');
|
jest.mock('electron-log');
|
||||||
jest.mock('../src/app/auto-update-handler', () => {
|
jest.mock('../src/app/auto-update-handler', () => {
|
||||||
@ -88,6 +92,32 @@ describe('config', () => {
|
|||||||
expect(configField).toEqual({});
|
expect(configField).toEqual({});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should retrieve default values when field not present in either user or global config', () => {
|
||||||
|
const fieldMock: string[] = [
|
||||||
|
'isPodUrlEditable',
|
||||||
|
'forceAutoUpdate',
|
||||||
|
'enableBrowserLogin',
|
||||||
|
'browserLoginAutoConnect',
|
||||||
|
'latestAutoUpdateChannelEnabled',
|
||||||
|
'betaAutoUpdateChannelEnabled',
|
||||||
|
];
|
||||||
|
const globalConfig: object = { url: 'test' };
|
||||||
|
const userConfig: object = { configVersion: '4.0.1' };
|
||||||
|
|
||||||
|
// creating temp file
|
||||||
|
writeConfigFile(globalConfig);
|
||||||
|
writeUserFile(userConfig);
|
||||||
|
|
||||||
|
// changing path from /Users/.../SymphonyElectron/config/Symphony.config to temp path
|
||||||
|
configInstance.globalConfigPath = globalConfigDir;
|
||||||
|
configInstance.userConfigPath = userConfigDir;
|
||||||
|
configInstance.readGlobalConfig();
|
||||||
|
configInstance.readUserConfig();
|
||||||
|
|
||||||
|
const configField: IConfig = configInstance.getConfigFields(fieldMock);
|
||||||
|
expect(configField).toEqual({ ...ConfigFieldsDefaultValues });
|
||||||
|
});
|
||||||
|
|
||||||
it('should succeed when only present in user config', () => {
|
it('should succeed when only present in user config', () => {
|
||||||
const fieldMock: string[] = ['url'];
|
const fieldMock: string[] = ['url'];
|
||||||
const globalConfig: object = { url: 'something' };
|
const globalConfig: object = { url: 'something' };
|
||||||
|
@ -31,6 +31,15 @@ export enum CloudConfigDataTypes {
|
|||||||
DISABLED = 'DISABLED',
|
DISABLED = 'DISABLED',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const ConfigFieldsDefaultValues: Partial<IConfig> = {
|
||||||
|
isPodUrlEditable: true,
|
||||||
|
forceAutoUpdate: false,
|
||||||
|
enableBrowserLogin: false,
|
||||||
|
browserLoginAutoConnect: false,
|
||||||
|
latestAutoUpdateChannelEnabled: true,
|
||||||
|
betaAutoUpdateChannelEnabled: true,
|
||||||
|
};
|
||||||
|
|
||||||
export const ConfigFieldsToRestart = new Set([
|
export const ConfigFieldsToRestart = new Set([
|
||||||
'permissions',
|
'permissions',
|
||||||
'disableThrottling',
|
'disableThrottling',
|
||||||
@ -284,6 +293,7 @@ class Config {
|
|||||||
*/
|
*/
|
||||||
public getConfigFields(fields: string[]): IConfig {
|
public getConfigFields(fields: string[]): IConfig {
|
||||||
const configFields: IConfig = {
|
const configFields: IConfig = {
|
||||||
|
...this.getConfigfromDefaultFields(fields),
|
||||||
...this.getGlobalConfigFields(fields),
|
...this.getGlobalConfigFields(fields),
|
||||||
...this.getUserConfigFields(fields),
|
...this.getUserConfigFields(fields),
|
||||||
...this.getFilteredCloudConfigFields(fields),
|
...this.getFilteredCloudConfigFields(fields),
|
||||||
@ -313,6 +323,23 @@ class Config {
|
|||||||
return userConfigData;
|
return userConfigData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns default value of specified fields
|
||||||
|
*
|
||||||
|
* @param fields {Array}
|
||||||
|
*/
|
||||||
|
public getConfigfromDefaultFields(fields: string[]): IGlobalConfig {
|
||||||
|
const defaultConfigData = pick(
|
||||||
|
ConfigFieldsDefaultValues,
|
||||||
|
fields,
|
||||||
|
) as IGlobalConfig;
|
||||||
|
logger.info(
|
||||||
|
`config-handler: getting default config values for the fields ${fields}`,
|
||||||
|
defaultConfigData,
|
||||||
|
);
|
||||||
|
return defaultConfigData;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the specified fields from global config file
|
* Returns the specified fields from global config file
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user