@zohodesk/testinglibrary 0.3.5-experimental → 0.3.7-experimental
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/core/playwright/configuration/ConfigurationHelper.js +3 -10
- package/build/core/playwright/env-initializer.js +0 -1
- package/build/core/playwright/helpers/auth/getUsers.js +23 -11
- package/build/core/playwright/helpers/configFileNameProvider.js +9 -3
- package/build/core/playwright/readConfigFile.js +7 -21
- package/build/core/playwright/test-runner.js +9 -11
- package/build/test/core/playwright/helpers/__tests__/configFileNameProvider.test.js +34 -0
- package/npm-shrinkwrap.json +1 -1
- package/package.json +1 -1
- package/build/test/Test.js +0 -63
|
@@ -12,16 +12,9 @@ var _configFileNameProvider = require("../helpers/configFileNameProvider");
|
|
|
12
12
|
var _mergeObjects = require("../helpers/mergeObjects");
|
|
13
13
|
var _fs = require("fs");
|
|
14
14
|
const Configuration = require("./Configuration");
|
|
15
|
-
function checkForDeprecatedKeys(configKey) {
|
|
16
|
-
let deprecatedConfigInUatConfigFile = ['mode'];
|
|
17
|
-
if (deprecatedConfigInUatConfigFile.includes(configKey)) {
|
|
18
|
-
_logger.Logger.log(_logger.Logger.INFO_TYPE, `key ${configKey} is deprecated. Please use other options`);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
15
|
function combineConfiguration(defaultConfig, userConfiguration) {
|
|
22
16
|
let configurationObj = {};
|
|
23
17
|
Object.keys(userConfiguration).forEach(configKey => {
|
|
24
|
-
checkForDeprecatedKeys(configKey);
|
|
25
18
|
let configValue = userConfiguration[configKey];
|
|
26
19
|
if (configValue !== null && configValue !== undefined) {
|
|
27
20
|
configurationObj[configKey] = configValue;
|
|
@@ -33,12 +26,12 @@ function combineConfiguration(defaultConfig, userConfiguration) {
|
|
|
33
26
|
});
|
|
34
27
|
return (0, _mergeObjects.mergeObjects)(defaultConfig, configurationObj);
|
|
35
28
|
}
|
|
36
|
-
function getApplicationConfig() {
|
|
29
|
+
function getApplicationConfig(mode) {
|
|
37
30
|
let filePath = "";
|
|
38
31
|
try {
|
|
39
|
-
filePath = _path.default.resolve(process.cwd(), (0, _configFileNameProvider.getUATFileName)());
|
|
32
|
+
filePath = _path.default.resolve(process.cwd(), (0, _configFileNameProvider.getUATFileName)(mode));
|
|
40
33
|
if (!(0, _fs.existsSync)(filePath)) {
|
|
41
|
-
throw new Error("
|
|
34
|
+
throw new Error("Exception while getting the uat file from the application - " + filePath);
|
|
42
35
|
}
|
|
43
36
|
const config = require(filePath);
|
|
44
37
|
return config;
|
|
@@ -10,7 +10,6 @@ var _path = _interopRequireDefault(require("path"));
|
|
|
10
10
|
var _configFileNameProvider = require("./helpers/configFileNameProvider");
|
|
11
11
|
var _logger = require("../../utils/logger");
|
|
12
12
|
var _getUsers = require("./helpers/auth/getUsers");
|
|
13
|
-
var _readConfigFile = require("./readConfigFile");
|
|
14
13
|
function setEnvironmentVariables(configJSON) {
|
|
15
14
|
for (const key in configJSON) {
|
|
16
15
|
process.env[key] = configJSON[key];
|
|
@@ -33,12 +33,17 @@ function getDefaultActorConf() {
|
|
|
33
33
|
const {
|
|
34
34
|
uatDirectory
|
|
35
35
|
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
36
|
-
const
|
|
37
|
-
const filePath = _path.default.join(uatDirectory,
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
const modeSettingsFile = `conf/${getRunMode()}/settings.json`;
|
|
37
|
+
const filePath = _path.default.join(uatDirectory, modeSettingsFile);
|
|
38
|
+
try {
|
|
39
|
+
if (!(0, _fs.existsSync)(filePath)) {
|
|
40
|
+
const defaultSettingsFile = _path.default.join(uatDirectory, `conf/default/settings.json`);
|
|
41
|
+
return require(defaultSettingsFile);
|
|
42
|
+
}
|
|
43
|
+
return require(filePath);
|
|
44
|
+
} catch (error) {
|
|
45
|
+
throw new Error(`${defaultSettingFile} ${filePath} both files are missing.`);
|
|
40
46
|
}
|
|
41
|
-
return require(filePath);
|
|
42
47
|
}
|
|
43
48
|
function getDefaultActor() {
|
|
44
49
|
const {
|
|
@@ -52,18 +57,25 @@ function getListOfActors() {
|
|
|
52
57
|
uatDirectory
|
|
53
58
|
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
54
59
|
const mode = getRunMode();
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
60
|
+
let configFile = _path.default.join(uatDirectory, `conf/${mode}/actors/index.js`);
|
|
61
|
+
if (!(0, _fs.existsSync)(configFile)) {
|
|
62
|
+
configFile = _path.default.join(uatDirectory, `conf/default/actors/index.js`);
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
return require(configFile);
|
|
66
|
+
} catch (error) {
|
|
67
|
+
throw new Error(`Error loading actor configuration from ${configFile}`);
|
|
59
68
|
}
|
|
60
|
-
return require(filePath);
|
|
61
69
|
}
|
|
62
70
|
function getUserForSelectedEditionAndProfile(preferedEdition, preferredProfile, betaFeature, testDataPortal = null) {
|
|
71
|
+
const actorsData = getListOfActors();
|
|
72
|
+
if (!actorsData || !actorsData.editions) {
|
|
73
|
+
throw new Error("The actors data is missing.");
|
|
74
|
+
}
|
|
63
75
|
const {
|
|
64
76
|
editions: userdata,
|
|
65
77
|
beta: betaPortals
|
|
66
|
-
} =
|
|
78
|
+
} = actorsData;
|
|
67
79
|
const defaultConf = getDefaultActorConf();
|
|
68
80
|
const edition = preferedEdition || defaultConf.edition;
|
|
69
81
|
const profile = preferredProfile || defaultConf.profile;
|
|
@@ -9,8 +9,14 @@ exports.getReportFileName = getReportFileName;
|
|
|
9
9
|
exports.getUATFileName = getUATFileName;
|
|
10
10
|
var _path = _interopRequireDefault(require("path"));
|
|
11
11
|
var _fs = _interopRequireDefault(require("fs"));
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
var _auth = require("./auth");
|
|
13
|
+
function getUATFileName(mode) {
|
|
14
|
+
mode = mode || (0, _auth.getRunMode)();
|
|
15
|
+
const uatConfFilePath = _path.default.resolve(process.cwd(), `uat/conf/${mode}/uat.config.js`);
|
|
16
|
+
if (_fs.default.existsSync(uatConfFilePath)) {
|
|
17
|
+
return uatConfFilePath;
|
|
18
|
+
}
|
|
19
|
+
return _path.default.resolve(process.cwd(), `uat.config.js`);
|
|
14
20
|
}
|
|
15
21
|
function getEnvConfigFilePath(mode) {
|
|
16
22
|
const confFilePath = _path.default.resolve(process.cwd(), `uat/conf/${mode}/settings.json`);
|
|
@@ -18,7 +24,7 @@ function getEnvConfigFilePath(mode) {
|
|
|
18
24
|
if (_fs.default.existsSync(confFilePath)) {
|
|
19
25
|
return `uat/conf/${mode}/settings.json`;
|
|
20
26
|
}
|
|
21
|
-
return `uat/
|
|
27
|
+
return `uat/conf/default/settings.json`;
|
|
22
28
|
}
|
|
23
29
|
function getReportFileName() {
|
|
24
30
|
return `test-summary.json`;
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.generateConfigFromFile = generateConfigFromFile;
|
|
8
|
-
exports.getApplicationConfig = getApplicationConfig;
|
|
9
8
|
exports.getAuthFilePath = getAuthFilePath;
|
|
10
9
|
exports.getDefaultConfig = getDefaultConfig;
|
|
11
10
|
exports.isUserConfigFileAvailable = isUserConfigFileAvailable;
|
|
@@ -14,7 +13,6 @@ var _path = _interopRequireDefault(require("path"));
|
|
|
14
13
|
var _logger = require("../../utils/logger");
|
|
15
14
|
var _configFileNameProvider = require("./helpers/configFileNameProvider");
|
|
16
15
|
var _mergeObjects = require("./helpers/mergeObjects");
|
|
17
|
-
var _Configuration = require("./configuration/Configuration");
|
|
18
16
|
let cachedConfig = null;
|
|
19
17
|
function getDefaultConfig() {
|
|
20
18
|
return {
|
|
@@ -35,26 +33,18 @@ function getDefaultConfig() {
|
|
|
35
33
|
height: 720
|
|
36
34
|
},
|
|
37
35
|
debug: false,
|
|
38
|
-
|
|
36
|
+
testIdAttribute: 'data-testid',
|
|
39
37
|
additionalPages: {},
|
|
40
38
|
featureFilesFolder: 'feature-files',
|
|
41
39
|
stepDefinitionsFolder: 'steps',
|
|
42
|
-
testIdAttribute: 'data-testid',
|
|
43
40
|
testSetup: {},
|
|
44
41
|
editionOrder: ['Free', 'Express', 'Standard', 'Professional', 'Enterprise']
|
|
45
42
|
};
|
|
46
43
|
}
|
|
47
|
-
function checkForDeprecatedKeys(configKey) {
|
|
48
|
-
let deprecatedConfigInUatConfigFile = ['mode'];
|
|
49
|
-
if (deprecatedConfigInUatConfigFile.includes(configKey)) {
|
|
50
|
-
_logger.Logger.log(_logger.Logger.INFO_TYPE, `key ${configKey} is deprecated. Please use other options`);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
44
|
function combineDefaultConfigWithUserConfig(userConfiguration) {
|
|
54
45
|
let defaultConfig = getDefaultConfig();
|
|
55
46
|
let configurationObj = {};
|
|
56
47
|
Object.keys(userConfiguration).forEach(configKey => {
|
|
57
|
-
checkForDeprecatedKeys(configKey);
|
|
58
48
|
let configValue = userConfiguration[configKey];
|
|
59
49
|
if (configValue !== null && configValue !== undefined) {
|
|
60
50
|
configurationObj[configKey] = configValue;
|
|
@@ -113,11 +103,15 @@ function combineDefaultConfigWithUserConfig(userConfiguration) {
|
|
|
113
103
|
*
|
|
114
104
|
* @returns {UserConfig}
|
|
115
105
|
*/
|
|
106
|
+
|
|
107
|
+
function getConfigFilePath() {
|
|
108
|
+
return _path.default.resolve(process.cwd(), (0, _configFileNameProvider.getUATFileName)());
|
|
109
|
+
}
|
|
116
110
|
function generateConfigFromFile() {
|
|
117
111
|
if (cachedConfig !== null) {
|
|
118
112
|
return cachedConfig; // If cached, return the cached configuration
|
|
119
113
|
}
|
|
120
|
-
const filePath =
|
|
114
|
+
const filePath = getConfigFilePath();
|
|
121
115
|
if ((0, _fs.existsSync)(filePath)) {
|
|
122
116
|
/** @type {UserConfig} */
|
|
123
117
|
const config = require(filePath);
|
|
@@ -127,16 +121,8 @@ function generateConfigFromFile() {
|
|
|
127
121
|
}
|
|
128
122
|
return {};
|
|
129
123
|
}
|
|
130
|
-
function getApplicationConfig() {
|
|
131
|
-
const filePath = _path.default.resolve(process.cwd(), (0, _configFileNameProvider.getUATFileName)());
|
|
132
|
-
if ((0, _fs.existsSync)(filePath)) {
|
|
133
|
-
const config = require(filePath);
|
|
134
|
-
return config;
|
|
135
|
-
}
|
|
136
|
-
return {};
|
|
137
|
-
}
|
|
138
124
|
function isUserConfigFileAvailable() {
|
|
139
|
-
const filePath =
|
|
125
|
+
const filePath = getConfigFilePath();
|
|
140
126
|
if ((0, _fs.existsSync)(filePath)) {
|
|
141
127
|
return true;
|
|
142
128
|
}
|
|
@@ -103,27 +103,25 @@ function main() {
|
|
|
103
103
|
const uatConfig = new _Configuration.default((0, _readConfigFile.getDefaultConfig)());
|
|
104
104
|
|
|
105
105
|
// overriding the application config's from project
|
|
106
|
-
|
|
107
|
-
const {
|
|
108
|
-
isAuthMode,
|
|
109
|
-
editionOrder
|
|
110
|
-
} = uatConfig.getAll();
|
|
106
|
+
|
|
111
107
|
const userArgConfig = new _Configuration.default(_UserArgs.default.parseToObject(process.argv.slice(2)));
|
|
112
108
|
const mode = userArgConfig.get("mode");
|
|
113
|
-
(0,
|
|
109
|
+
uatConfig.addAll(new _Configuration.default((0, _ConfigurationHelper.getApplicationConfig)(mode)));
|
|
114
110
|
|
|
115
111
|
// overriding the user config's from CLI
|
|
116
|
-
// const userArgConfig = new Configuration( UserArgs.parseToObject(process.argv.slice(2)) );
|
|
117
112
|
uatConfig.addAll(userArgConfig);
|
|
118
|
-
|
|
119
|
-
//This is only used for pass the user arguments to need places in legacy code. We need to rewamp that also.
|
|
120
|
-
const userArgsObject = userArgConfig.getAll();
|
|
121
|
-
const tagArgs = (0, _tagProcessor.tagProcessor)(userArgsObject, editionOrder);
|
|
122
113
|
const {
|
|
114
|
+
isAuthMode,
|
|
115
|
+
editionOrder,
|
|
123
116
|
debug,
|
|
124
117
|
bddMode = false,
|
|
125
118
|
headless = false
|
|
126
119
|
} = uatConfig.getAll();
|
|
120
|
+
(0, _envInitializer.initializeEnvConfig)(mode, isAuthMode);
|
|
121
|
+
|
|
122
|
+
//This is only used for pass the user arguments to need places in legacy code. We need to rewamp that also.
|
|
123
|
+
const userArgsObject = userArgConfig.getAll();
|
|
124
|
+
const tagArgs = (0, _tagProcessor.tagProcessor)(userArgsObject, editionOrder);
|
|
127
125
|
const playwrightArgs = getPlaywrightArgs(userArgsObject, debug, bddMode, tagArgs, headless);
|
|
128
126
|
const playwrightPath = _path.default.resolve((0, _rootPath.getExecutableBinaryPath)('playwright'));
|
|
129
127
|
const command = playwrightPath;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _fs = require("fs");
|
|
5
|
+
var _path = _interopRequireDefault(require("path"));
|
|
6
|
+
var _configFileNameProvider = require("../../../../../core/playwright/helpers/configFileNameProvider");
|
|
7
|
+
jest.mock('fs');
|
|
8
|
+
jest.mock('path');
|
|
9
|
+
const mockCwd = '/mock/current/directory';
|
|
10
|
+
_path.default.resolve = jest.fn();
|
|
11
|
+
process.cwd = jest.fn(() => mockCwd);
|
|
12
|
+
describe('getUATFileName', () => {
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
jest.clearAllMocks();
|
|
15
|
+
});
|
|
16
|
+
test('return the pipeline matched config files for pipeline matched files exists', () => {
|
|
17
|
+
const mode = 'cd';
|
|
18
|
+
const mockPath = `${mockCwd}/uat/conf/${mode}/uat.config.js`;
|
|
19
|
+
_fs.existsSync.mockReturnValue(true);
|
|
20
|
+
_path.default.resolve.mockImplementation((...args) => args.join('/'));
|
|
21
|
+
const result = (0, _configFileNameProvider.getUATFileName)(mode);
|
|
22
|
+
expect(_fs.existsSync).toHaveBeenCalledWith(mockPath);
|
|
23
|
+
expect(result).toBe(mockPath);
|
|
24
|
+
});
|
|
25
|
+
test('return the default config files for pipeline matched files not exists', () => {
|
|
26
|
+
const mode = 'ci';
|
|
27
|
+
const defaultPath = `${mockCwd}/uat.config.js`;
|
|
28
|
+
_fs.existsSync.mockReturnValue(false);
|
|
29
|
+
_path.default.resolve.mockImplementation((...args) => args.join('/'));
|
|
30
|
+
const result = (0, _configFileNameProvider.getUATFileName)(mode);
|
|
31
|
+
expect(_fs.existsSync).toHaveBeenCalledWith(`${mockCwd}/uat/conf/${mode}/uat.config.js`);
|
|
32
|
+
expect(result).toBe(defaultPath);
|
|
33
|
+
});
|
|
34
|
+
});
|
package/npm-shrinkwrap.json
CHANGED
package/package.json
CHANGED
package/build/test/Test.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// const UserArgs = require("../core/playwright/configuration/UserArgs");
|
|
4
|
-
// const Configuration = require("../core/playwright/configuration/Configuration");
|
|
5
|
-
|
|
6
|
-
// function main() {
|
|
7
|
-
// const config = new Configuration();
|
|
8
|
-
// config.set("reportPath", "home/reports");
|
|
9
|
-
|
|
10
|
-
// const fwConfig = new Configuration();
|
|
11
|
-
// fwConfig.set("browser", "chrome");
|
|
12
|
-
// fwConfig.set("trace", true);
|
|
13
|
-
// config.setFrameworkConfig(fwConfig);
|
|
14
|
-
|
|
15
|
-
// const appConfig = new Configuration();
|
|
16
|
-
// appConfig.set("environment", "CI");
|
|
17
|
-
// appConfig.set("edition", "test");
|
|
18
|
-
// config.setApplicationConfig(appConfig);
|
|
19
|
-
|
|
20
|
-
// const uaConfig = new Configuration();
|
|
21
|
-
// uaConfig.set("debug", true);
|
|
22
|
-
// uaConfig.set("headless", true);
|
|
23
|
-
// config.setUserArguments(uaConfig);
|
|
24
|
-
|
|
25
|
-
// console.log("default Config : ", config.get("reportPath"));
|
|
26
|
-
// console.log("framework Config : ", config.getFrameworkConfig()?.get("browser"));
|
|
27
|
-
// console.log("application Config : ", config.getApplicationConfig()?.get("environment"));
|
|
28
|
-
// console.log("User arguments : ", config.getUserArguments()?.get("debug"));
|
|
29
|
-
// }
|
|
30
|
-
|
|
31
|
-
// function test(){
|
|
32
|
-
// const prop = new Map();
|
|
33
|
-
// prop.set("browser","durai");
|
|
34
|
-
|
|
35
|
-
// const config = Configuration(prop);
|
|
36
|
-
// console.log("output :" +config.get("browser"));
|
|
37
|
-
// // console.log(prop);
|
|
38
|
-
|
|
39
|
-
// }
|
|
40
|
-
|
|
41
|
-
// function testParseToArgs(){
|
|
42
|
-
// const prop = new Map();
|
|
43
|
-
// prop.set("browser","durai");
|
|
44
|
-
// const userArgsObject = UserArgs.parseToArgs(prop);
|
|
45
|
-
// console.log(userArgsObject);
|
|
46
|
-
// }
|
|
47
|
-
|
|
48
|
-
function throwError() {
|
|
49
|
-
throw new Error("catch error");
|
|
50
|
-
}
|
|
51
|
-
function catchError() {
|
|
52
|
-
try {
|
|
53
|
-
throw new Error("catch error");
|
|
54
|
-
} catch (err) {
|
|
55
|
-
console.log(err.message);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// throwError();
|
|
60
|
-
catchError();
|
|
61
|
-
// testParseToArgs();
|
|
62
|
-
|
|
63
|
-
// main();
|