@zohodesk/testinglibrary 0.4.99-n18-experimental → 0.4.101-n18-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/README.md +8 -10
- package/build/common/data-generator/steps/DataGeneratorStepsHelper.js +3 -1
- package/build/common/searchFake/steps/searchFake.spec.js +3 -3
- package/build/core/dataGenerator/DataGenerator.js +0 -9
- package/build/core/playwright/configuration/ConfigurationHelper.js +5 -7
- package/build/core/playwright/custom-commands.js +1 -1
- package/build/core/playwright/env-initializer.js +9 -10
- package/build/core/playwright/helpers/auth/getUsers.js +16 -15
- package/build/core/playwright/helpers/configFileNameProvider.js +8 -15
- package/build/core/playwright/helpers/thirdPartyLib.js +13 -0
- package/build/core/playwright/readConfigFile.js +2 -3
- package/build/core/playwright/test-runner.js +2 -4
- package/build/test/Test.js +13 -0
- package/build/test/core/playwright/helpers/__tests__/configFileNameProvider.test.js +13 -54
- package/build/test/core/playwright/helpers/__tests__/getUsers_ListOfActors.test.js +26 -29
- package/npm-shrinkwrap.json +147 -256
- package/package.json +3 -5
- package/build/core/playwright/constants/configFiles.js +0 -14
- package/build/core/playwright/helpers/configPathResolver.js +0 -36
- package/build/test/core/playwright/helpers/__tests__/configPathResolver.test.js +0 -42
- package/test-results/.last-run.json +0 -4
- package/unit_reports/unit-report.html +0 -260
package/README.md
CHANGED
|
@@ -17,22 +17,20 @@
|
|
|
17
17
|
|
|
18
18
|
- npm run report
|
|
19
19
|
|
|
20
|
-
### v3.2.13 - 30-10-2025
|
|
21
|
-
|
|
22
|
-
#### Enhancement
|
|
23
|
-
|
|
24
|
-
- A teardown option has been introduced in the configuration to manage and clean up login sessions stored in the NFS environment.
|
|
25
|
-
|
|
26
|
-
### Issue fix
|
|
27
|
-
|
|
28
|
-
- Custom teardown comment provided
|
|
29
|
-
|
|
30
20
|
### v3.2.11 - 13-10-2025
|
|
31
21
|
|
|
32
22
|
### Feature
|
|
33
23
|
|
|
34
24
|
- New step a search entity using {string} provided for search indexing, This step will use run time data generation response as input for the indexing
|
|
35
25
|
|
|
26
|
+
### Issue fix
|
|
27
|
+
- Custom teardown comment provided
|
|
28
|
+
|
|
29
|
+
### v3.2.10 - 09-10-2025
|
|
30
|
+
|
|
31
|
+
#### Enhancement
|
|
32
|
+
- A teardown option has been introduced in the configuration to manage and clean up login sessions stored in the NFS environment.
|
|
33
|
+
|
|
36
34
|
|
|
37
35
|
### v3.2.9 - 26-09-2025
|
|
38
36
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { test } from '@zohodesk/testinglibrary';
|
|
2
2
|
import DataGenerator from '@zohodesk/testinglibrary/DataGenerator';
|
|
3
|
+
import {getUserForSelectedEditionAndProfile} from '@zohodesk/testinglibrary/helpers'
|
|
3
4
|
|
|
4
5
|
const dataGenerator = new DataGenerator();
|
|
5
6
|
|
|
@@ -9,7 +10,8 @@ export async function generateAndCacheTestData(executionContext, type, identifie
|
|
|
9
10
|
const scenarioName = testInfo.title.split('/').pop() || 'Unknown Scenario';
|
|
10
11
|
|
|
11
12
|
if (profile) {
|
|
12
|
-
|
|
13
|
+
const { edition, orgName: portal, beta } = executionContext.actorInfo;
|
|
14
|
+
actorInfo = await getUserForSelectedEditionAndProfile(edition, profile, beta, portal);
|
|
13
15
|
} else {
|
|
14
16
|
actorInfo = executionContext.actorInfo;
|
|
15
17
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {createBdd
|
|
1
|
+
import {createBdd} from '@zohodesk/testinglibrary';
|
|
2
|
+
import { jsonpath } from '@zohodesk/testinglibrary/thirdPartyHelper';
|
|
2
3
|
import { executeRpcRequest , entityIdReConstructor } from '../helpers/rpcRequestHelper';
|
|
3
|
-
// import jp from 'jsonpath';
|
|
4
4
|
|
|
5
5
|
const { Given } = createBdd();
|
|
6
6
|
|
|
@@ -54,7 +54,7 @@ Given('a search entity using {string}', async ({page,cacheLayer}, reference,data
|
|
|
54
54
|
entityIdValue = searchObj;
|
|
55
55
|
} else {
|
|
56
56
|
const jsonPath = searchEntity?.startsWith?.('$') ? searchEntity : `$.${searchEntity}`;
|
|
57
|
-
const result =
|
|
57
|
+
const result = jsonpath.query(searchObj, jsonPath);
|
|
58
58
|
|
|
59
59
|
if (!result || result.length === 0) {
|
|
60
60
|
throw new Error(`JSONPath query '${jsonPath}' returned no results from cache object for reference: ${reference}`);
|
|
@@ -47,15 +47,6 @@ class DataGenerator {
|
|
|
47
47
|
throw error;
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
async getDataGenUserExecutionContext(edition, profile) {
|
|
51
|
-
try {
|
|
52
|
-
const dataGenUserDetails = await (0, _helpers.getUserForSelectedEditionAndProfile)(edition, profile);
|
|
53
|
-
return dataGenUserDetails;
|
|
54
|
-
} catch (error) {
|
|
55
|
-
console.error('Error occurred while fetching data generation user details: ', error);
|
|
56
|
-
throw error;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
50
|
}
|
|
60
51
|
async function _getGenerator(testInfo, generatorName) {
|
|
61
52
|
let generator = null;
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.combineConfiguration = combineConfiguration;
|
|
7
8
|
exports.getApplicationConfig = getApplicationConfig;
|
|
8
|
-
|
|
9
|
+
var _path = _interopRequireDefault(require("path"));
|
|
9
10
|
var _logger = require("../../../utils/logger");
|
|
10
11
|
var _configFileNameProvider = require("../helpers/configFileNameProvider");
|
|
11
12
|
var _mergeObjects = require("../helpers/mergeObjects");
|
|
12
13
|
var _fs = require("fs");
|
|
14
|
+
const Configuration = require("./Configuration");
|
|
13
15
|
function combineConfiguration(defaultConfig, userConfiguration) {
|
|
14
16
|
let configurationObj = {};
|
|
15
17
|
Object.keys(userConfiguration).forEach(configKey => {
|
|
@@ -24,10 +26,10 @@ function combineConfiguration(defaultConfig, userConfiguration) {
|
|
|
24
26
|
});
|
|
25
27
|
return (0, _mergeObjects.mergeObjects)(defaultConfig, configurationObj);
|
|
26
28
|
}
|
|
27
|
-
function getApplicationConfig(
|
|
29
|
+
function getApplicationConfig(mode) {
|
|
28
30
|
let filePath = "";
|
|
29
31
|
try {
|
|
30
|
-
filePath = (0, _configFileNameProvider.getUATFileName)(
|
|
32
|
+
filePath = _path.default.resolve(process.cwd(), (0, _configFileNameProvider.getUATFileName)(mode));
|
|
31
33
|
if (!(0, _fs.existsSync)(filePath)) {
|
|
32
34
|
throw new Error("Exception while getting the uat file from the application - " + filePath);
|
|
33
35
|
}
|
|
@@ -38,8 +40,4 @@ function getApplicationConfig(stage, mode) {
|
|
|
38
40
|
_logger.Logger.error(err);
|
|
39
41
|
return {};
|
|
40
42
|
}
|
|
41
|
-
}
|
|
42
|
-
function getRunStage() {
|
|
43
|
-
const stage = process.env.stage;
|
|
44
|
-
return stage || 'uat';
|
|
45
43
|
}
|
|
@@ -4,4 +4,4 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.CUSTOM_COMMANDS = void 0;
|
|
7
|
-
const CUSTOM_COMMANDS = exports.CUSTOM_COMMANDS = ['
|
|
7
|
+
const CUSTOM_COMMANDS = exports.CUSTOM_COMMANDS = ['mode', 'tags', 'edition', 'browsers', 'filePath', 'headless', 'modules', 'isTearDown'];
|
|
@@ -17,20 +17,19 @@ function setEnvironmentVariables(configJSON) {
|
|
|
17
17
|
}
|
|
18
18
|
function addHelperLogsForEnvInitialization() {
|
|
19
19
|
_logger.Logger.log(_logger.Logger.INFO_TYPE, `Mode under which test cases should run has not been specified in args.`);
|
|
20
|
-
_logger.Logger.log(_logger.Logger.INFO_TYPE, `Please specify --mode='dev/
|
|
20
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, `Please specify --mode='dev/prod' while running ZDTestingFramework test`);
|
|
21
21
|
_logger.Logger.log(_logger.Logger.INFO_TYPE, `Going to use default mode as dev`);
|
|
22
22
|
}
|
|
23
|
-
function initializeEnvConfig(
|
|
24
|
-
if (!mode) {
|
|
25
|
-
addHelperLogsForEnvInitialization();
|
|
26
|
-
mode = 'dev';
|
|
27
|
-
}
|
|
28
|
-
const configFilePath = (0, _fs.readFileSync)(_path.default.resolve(process.cwd(), `./${(0, _configFileNameProvider.getEnvConfigFilePath)(stage, mode)}`));
|
|
23
|
+
function initializeEnvConfig(mode, isAuthMode) {
|
|
29
24
|
try {
|
|
30
|
-
|
|
25
|
+
if (!mode) {
|
|
26
|
+
addHelperLogsForEnvInitialization();
|
|
27
|
+
mode = 'dev';
|
|
28
|
+
}
|
|
29
|
+
const configFile = (0, _fs.readFileSync)(_path.default.resolve(process.cwd(), `./${(0, _configFileNameProvider.getEnvConfigFilePath)(mode)}`));
|
|
30
|
+
const configJSON = JSON.parse(configFile);
|
|
31
31
|
setEnvironmentVariables({
|
|
32
32
|
...configJSON,
|
|
33
|
-
stage,
|
|
34
33
|
mode
|
|
35
34
|
});
|
|
36
35
|
if (isAuthMode) {
|
|
@@ -39,6 +38,6 @@ function initializeEnvConfig(stage, mode, isAuthMode) {
|
|
|
39
38
|
}
|
|
40
39
|
} catch (err) {
|
|
41
40
|
_logger.Logger.error(err);
|
|
42
|
-
throw new Error(`Config File Not Exists. Please provide a ${
|
|
41
|
+
throw new Error(`Config File Not Exists. Please provide a config file ${(0, _configFileNameProvider.getEnvConfigFilePath)(mode)} to intiailize the environment variables `);
|
|
43
42
|
}
|
|
44
43
|
}
|
|
@@ -13,9 +13,7 @@ exports.isCI = isCI;
|
|
|
13
13
|
exports.isDevelopmentSetup = isDevelopmentSetup;
|
|
14
14
|
var _path = _interopRequireDefault(require("path"));
|
|
15
15
|
var _fs = require("fs");
|
|
16
|
-
var
|
|
17
|
-
var _ConfigurationHelper = require("./../../configuration/ConfigurationHelper");
|
|
18
|
-
var _configFiles = require("../../constants/configFiles");
|
|
16
|
+
var _readConfigFile = require("../../readConfigFile");
|
|
19
17
|
/* eslint-disable global-require */
|
|
20
18
|
function getRunMode() {
|
|
21
19
|
let {
|
|
@@ -32,18 +30,19 @@ function isDevelopmentSetup() {
|
|
|
32
30
|
return mode === 'DEV' || mode === 'dev';
|
|
33
31
|
}
|
|
34
32
|
function getDefaultActorConf() {
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const
|
|
33
|
+
const {
|
|
34
|
+
uatDirectory
|
|
35
|
+
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
36
|
+
const modeSettingsFile = `conf/${getRunMode()}/settings.json`;
|
|
37
|
+
const filePath = _path.default.join(uatDirectory, modeSettingsFile);
|
|
39
38
|
try {
|
|
40
39
|
if (!(0, _fs.existsSync)(filePath)) {
|
|
41
|
-
const defaultSettingsFile = _path.default.join(
|
|
40
|
+
const defaultSettingsFile = _path.default.join(uatDirectory, `conf/default/settings.json`);
|
|
42
41
|
return require(defaultSettingsFile);
|
|
43
42
|
}
|
|
44
43
|
return require(filePath);
|
|
45
44
|
} catch (error) {
|
|
46
|
-
throw new Error(`${filePath}
|
|
45
|
+
throw new Error(`${defaultSettingFile} ${filePath} both files are missing.`);
|
|
47
46
|
}
|
|
48
47
|
}
|
|
49
48
|
function getDefaultActor() {
|
|
@@ -54,17 +53,18 @@ function getDefaultActor() {
|
|
|
54
53
|
return getUserForSelectedEditionAndProfile(edition, profile);
|
|
55
54
|
}
|
|
56
55
|
function getListOfActors(betaFeature) {
|
|
56
|
+
const {
|
|
57
|
+
uatDirectory
|
|
58
|
+
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
57
59
|
const mode = getRunMode();
|
|
58
|
-
|
|
59
|
-
const stagePath = (0, _configPathResolver.getConfigPath)(stage);
|
|
60
|
-
let configFile = _path.default.join(_path.default.resolve(process.cwd(), `${stagePath}/${mode}/${_configFiles.ACTOR_DIR}/${_configFiles.INDEX_FILE}`));
|
|
60
|
+
let configFile = _path.default.join(uatDirectory, `conf/${mode}/actors/index.js`);
|
|
61
61
|
let betaReference = mode;
|
|
62
62
|
if (!(0, _fs.existsSync)(configFile)) {
|
|
63
|
-
configFile = _path.default.join(
|
|
63
|
+
configFile = _path.default.join(uatDirectory, `conf/default/actors/index.js`);
|
|
64
64
|
betaReference = "default";
|
|
65
65
|
}
|
|
66
66
|
if (betaFeature) {
|
|
67
|
-
configFile = _path.default.join(
|
|
67
|
+
configFile = _path.default.join(uatDirectory, `conf/${betaReference}/actors/beta/${betaFeature}/index.js`);
|
|
68
68
|
if (!(0, _fs.existsSync)(configFile)) {
|
|
69
69
|
throw new Error(`There is no beta feature configured with the name "${betaFeature}"`);
|
|
70
70
|
}
|
|
@@ -113,6 +113,7 @@ function getUserForSelectedEditionAndProfile(preferedEdition, preferredProfile,
|
|
|
113
113
|
}
|
|
114
114
|
return {
|
|
115
115
|
...editionData,
|
|
116
|
-
...selectedProfile
|
|
116
|
+
...selectedProfile,
|
|
117
|
+
'beta': betaFeature
|
|
117
118
|
};
|
|
118
119
|
}
|
|
@@ -10,29 +10,22 @@ exports.getUATFileName = getUATFileName;
|
|
|
10
10
|
var _path = _interopRequireDefault(require("path"));
|
|
11
11
|
var _fs = _interopRequireDefault(require("fs"));
|
|
12
12
|
var _auth = require("./auth");
|
|
13
|
-
|
|
14
|
-
var _configPathResolver = require("./configPathResolver");
|
|
15
|
-
var _configFiles = require("../constants/configFiles");
|
|
16
|
-
function getUATFileName(stage, mode) {
|
|
17
|
-
stage = stage || (0, _ConfigurationHelper.getRunStage)();
|
|
13
|
+
function getUATFileName(mode) {
|
|
18
14
|
mode = mode || (0, _auth.getRunMode)();
|
|
19
|
-
const
|
|
20
|
-
const uatConfFilePath = _path.default.resolve(process.cwd(), `${stagePath}/${mode}/${_configFiles.UAT_CONFIG_FILE}`);
|
|
15
|
+
const uatConfFilePath = _path.default.resolve(process.cwd(), `uat/conf/${mode}/uat.config.js`);
|
|
21
16
|
if (_fs.default.existsSync(uatConfFilePath)) {
|
|
22
17
|
return uatConfFilePath;
|
|
23
18
|
}
|
|
24
|
-
;
|
|
25
|
-
return _path.default.resolve(process.cwd(), `${stagePath}/${_configFiles.DEFAULT_CONFIG_DIR}/${_configFiles.UAT_CONFIG_FILE}`);
|
|
19
|
+
return _path.default.resolve(process.cwd(), `uat/conf/default/uat.config.js`);
|
|
26
20
|
}
|
|
27
|
-
function getEnvConfigFilePath(
|
|
28
|
-
const
|
|
29
|
-
const confFilePath = `${stagePath}/${mode}/${_configFiles.SETTINGS_FILE}`;
|
|
21
|
+
function getEnvConfigFilePath(mode) {
|
|
22
|
+
const confFilePath = _path.default.resolve(process.cwd(), `uat/conf/${mode}/settings.json`);
|
|
30
23
|
// TODO: Actors Mode as config
|
|
31
24
|
if (_fs.default.existsSync(confFilePath)) {
|
|
32
|
-
return
|
|
25
|
+
return `uat/conf/${mode}/settings.json`;
|
|
33
26
|
}
|
|
34
|
-
return
|
|
27
|
+
return `uat/conf/default/settings.json`;
|
|
35
28
|
}
|
|
36
29
|
function getReportFileName() {
|
|
37
|
-
return
|
|
30
|
+
return `test-summary.json`;
|
|
38
31
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
Object.defineProperty(exports, "jsonpath", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _jsonpath.default;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
var _jsonpath = _interopRequireDefault(require("jsonpath"));
|
|
@@ -111,16 +111,15 @@ function combineDefaultConfigWithUserConfig(userConfiguration) {
|
|
|
111
111
|
*/
|
|
112
112
|
|
|
113
113
|
function getConfigFilePath() {
|
|
114
|
-
return (0, _configFileNameProvider.getUATFileName)();
|
|
114
|
+
return _path.default.resolve(process.cwd(), (0, _configFileNameProvider.getUATFileName)());
|
|
115
115
|
}
|
|
116
116
|
function generateConfigFromFile() {
|
|
117
117
|
if (cachedConfig === null) {
|
|
118
118
|
// Getting the default config's from framework
|
|
119
119
|
const uatConfig = new _Configuration.default(getDefaultConfig());
|
|
120
120
|
// overriding the application config's from project
|
|
121
|
+
const appConfig = new _Configuration.default((0, _ConfigurationHelper.getApplicationConfig)());
|
|
121
122
|
const userArgConfig = new _Configuration.default(_UserArgs.default.parseToObject(process.argv.slice(2)));
|
|
122
|
-
const stage = userArgConfig.get("stage");
|
|
123
|
-
const appConfig = new _Configuration.default((0, _ConfigurationHelper.getApplicationConfig)(stage));
|
|
124
123
|
// overriding the user config's from CLI
|
|
125
124
|
uatConfig.addAll(appConfig);
|
|
126
125
|
uatConfig.addAll(userArgConfig);
|
|
@@ -86,8 +86,7 @@ function main() {
|
|
|
86
86
|
// overriding the application config's from project
|
|
87
87
|
const userArgConfig = new _Configuration.default(_UserArgs.default.parseToObject(process.argv.slice(2)));
|
|
88
88
|
const mode = userArgConfig.get("mode");
|
|
89
|
-
|
|
90
|
-
uatConfig.addAll(new _Configuration.default((0, _ConfigurationHelper.getApplicationConfig)(stage, mode)));
|
|
89
|
+
uatConfig.addAll(new _Configuration.default((0, _ConfigurationHelper.getApplicationConfig)(mode)));
|
|
91
90
|
// overriding the user config's from CLI
|
|
92
91
|
uatConfig.addAll(userArgConfig);
|
|
93
92
|
const modules = uatConfig.get('modules');
|
|
@@ -96,7 +95,6 @@ function main() {
|
|
|
96
95
|
//We need to change this process.env variable to pass the module name in future.
|
|
97
96
|
process.env.modules = modules;
|
|
98
97
|
process.env.tearDown = tearDown;
|
|
99
|
-
process.env.stage = stage;
|
|
100
98
|
const {
|
|
101
99
|
isAuthMode,
|
|
102
100
|
editionOrder,
|
|
@@ -104,7 +102,7 @@ function main() {
|
|
|
104
102
|
bddMode = false,
|
|
105
103
|
headless = false
|
|
106
104
|
} = uatConfig.getAll();
|
|
107
|
-
(0, _envInitializer.initializeEnvConfig)(
|
|
105
|
+
(0, _envInitializer.initializeEnvConfig)(mode, isAuthMode);
|
|
108
106
|
|
|
109
107
|
//This is only used for pass the user arguments to need places in legacy code. We need to rewamp that also.
|
|
110
108
|
const userArgsObject = userArgConfig.getAll();
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
delete require.cache[require.resolve('../core/playwright/runner/Runner')];
|
|
4
|
+
function test() {
|
|
5
|
+
const inputString = "@hc";
|
|
6
|
+
const selectedTag = ["@hc_1234"].reverse().find(tag => tag.startsWith(inputString));
|
|
7
|
+
let tagInput = null;
|
|
8
|
+
if (selectedTag) {
|
|
9
|
+
tagInput = selectedTag.split(`${inputString}_`).pop().toLowerCase();
|
|
10
|
+
}
|
|
11
|
+
console.log(tagInput);
|
|
12
|
+
}
|
|
13
|
+
test();
|
|
@@ -4,72 +4,31 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
var _fs = require("fs");
|
|
5
5
|
var _path = _interopRequireDefault(require("path"));
|
|
6
6
|
var _configFileNameProvider = require("../../../../../core/playwright/helpers/configFileNameProvider");
|
|
7
|
-
var _configPathResolver = require("../../../../../core/playwright/helpers/configPathResolver");
|
|
8
7
|
jest.mock('fs');
|
|
9
|
-
jest.mock('path'
|
|
10
|
-
resolve: jest.fn()
|
|
11
|
-
}));
|
|
12
|
-
jest.mock("../../../../../core/playwright/helpers/configPathResolver", () => ({
|
|
13
|
-
getConfigPath: jest.fn()
|
|
14
|
-
}));
|
|
8
|
+
jest.mock('path');
|
|
15
9
|
const mockCwd = '/mock/current/directory';
|
|
16
10
|
_path.default.resolve = jest.fn();
|
|
17
11
|
process.cwd = jest.fn(() => mockCwd);
|
|
18
12
|
describe('getUATFileName', () => {
|
|
19
13
|
beforeEach(() => {
|
|
20
14
|
jest.clearAllMocks();
|
|
21
|
-
_path.default.resolve.mockImplementation((...segments) => segments.join('/'));
|
|
22
15
|
});
|
|
23
|
-
test('
|
|
24
|
-
const stage = 'uat';
|
|
16
|
+
test('return the pipeline matched config files for pipeline matched files exists', () => {
|
|
25
17
|
const mode = 'cd';
|
|
26
|
-
|
|
27
|
-
_fs.existsSync.mockReturnValue(true);
|
|
28
|
-
const expected = `${process.cwd()}/${stage}/conf/${mode}/uat.config.js`;
|
|
29
|
-
const result = (0, _configFileNameProvider.getUATFileName)(stage, mode);
|
|
30
|
-
expect(_configPathResolver.getConfigPath).toHaveBeenCalledWith(stage);
|
|
31
|
-
expect(_fs.existsSync).toHaveBeenCalledWith(expected);
|
|
32
|
-
expect(result).toBe(expected);
|
|
33
|
-
});
|
|
34
|
-
test('should use default stage and mode when not provided', () => {
|
|
35
|
-
const mode = 'dev';
|
|
36
|
-
const stageConfigPath = 'uat/conf';
|
|
37
|
-
const expectedPath = `${mockCwd}/${stageConfigPath}/${mode}/uat.config.js`;
|
|
18
|
+
const mockPath = `${mockCwd}/uat/conf/${mode}/uat.config.js`;
|
|
38
19
|
_fs.existsSync.mockReturnValue(true);
|
|
20
|
+
_path.default.resolve.mockImplementation((...args) => args.join('/'));
|
|
39
21
|
const result = (0, _configFileNameProvider.getUATFileName)(mode);
|
|
40
|
-
expect(_fs.existsSync).toHaveBeenCalledWith(
|
|
41
|
-
expect(result).toBe(
|
|
42
|
-
});
|
|
43
|
-
test('should return the default config files for pipeline matched files not exists', () => {
|
|
44
|
-
const mockStage = 'uat';
|
|
45
|
-
const mockMode = 'ci';
|
|
46
|
-
const stageConfigPath = 'uat/conf';
|
|
47
|
-
const nonExistingPath = `${mockCwd}/${stageConfigPath}/${mockMode}/uat.config.js`;
|
|
48
|
-
const expectedDefaultPath = `${mockCwd}/${mockStage}/conf/default/uat.config.js`;
|
|
49
|
-
_configPathResolver.getConfigPath.mockReturnValue(stageConfigPath);
|
|
50
|
-
_fs.existsSync.mockReturnValue(false);
|
|
51
|
-
const result = (0, _configFileNameProvider.getUATFileName)(mockStage, mockMode);
|
|
52
|
-
expect(_fs.existsSync).toHaveBeenCalledWith(nonExistingPath);
|
|
53
|
-
expect(result).toBe(expectedDefaultPath);
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
describe('getEnvConfigFilePath', () => {
|
|
57
|
-
beforeEach(() => {
|
|
58
|
-
jest.clearAllMocks();
|
|
59
|
-
_path.default.resolve.mockImplementation((...segments) => segments.join('/'));
|
|
60
|
-
});
|
|
61
|
-
test('should return conf file path when file exists', () => {
|
|
62
|
-
_configPathResolver.getConfigPath.mockReturnValue('uat/conf');
|
|
63
|
-
_fs.existsSync.mockReturnValue(true);
|
|
64
|
-
const result = (0, _configFileNameProvider.getEnvConfigFilePath)('uat', 'cd');
|
|
65
|
-
expect(_configPathResolver.getConfigPath).toHaveBeenCalledWith('uat');
|
|
66
|
-
expect(_fs.existsSync).toHaveBeenCalled();
|
|
67
|
-
expect(result).toBe('uat/conf/cd/settings.json');
|
|
22
|
+
expect(_fs.existsSync).toHaveBeenCalledWith(mockPath);
|
|
23
|
+
expect(result).toBe(mockPath);
|
|
68
24
|
});
|
|
69
|
-
test('
|
|
70
|
-
|
|
25
|
+
test('return the default config files for pipeline matched files not exists', () => {
|
|
26
|
+
const mode = 'ci';
|
|
27
|
+
const defaultPath = `${mockCwd}/uat/conf/default/uat.config.js`;
|
|
71
28
|
_fs.existsSync.mockReturnValue(false);
|
|
72
|
-
|
|
73
|
-
|
|
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);
|
|
74
33
|
});
|
|
75
34
|
});
|
|
@@ -1,83 +1,80 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _fs =
|
|
4
|
+
var _fs = require("fs");
|
|
5
5
|
var _path = _interopRequireDefault(require("path"));
|
|
6
|
-
var _getUsers = require("../../../../../core/playwright/helpers/auth/getUsers");
|
|
7
|
-
var _configPathResolver = require("../../../../../core/playwright/helpers/configPathResolver");
|
|
8
6
|
jest.mock('fs');
|
|
9
7
|
jest.mock('path');
|
|
10
|
-
jest.mock('../../../../../core/playwright/
|
|
11
|
-
|
|
8
|
+
jest.mock('../../../../../core/playwright/readConfigFile', () => ({
|
|
9
|
+
generateConfigFromFile: jest.fn(() => ({
|
|
10
|
+
uatDirectory: '/test/directory'
|
|
11
|
+
})),
|
|
12
|
+
getRunMode: jest.fn(() => 'dev')
|
|
12
13
|
}));
|
|
14
|
+
const {
|
|
15
|
+
getListOfActors
|
|
16
|
+
} = require('../../../../../core/playwright/helpers/auth/getUsers');
|
|
13
17
|
describe('getListOfActors', () => {
|
|
14
|
-
const stageConfig = 'uat/conf';
|
|
15
|
-
const mode = 'dev';
|
|
16
|
-
const stage = 'uat';
|
|
17
18
|
beforeEach(() => {
|
|
18
19
|
jest.clearAllMocks();
|
|
19
20
|
_path.default.join.mockImplementation((...args) => args.join('/'));
|
|
20
|
-
_path.default.resolve.mockImplementation((...args) => args.join('/'));
|
|
21
|
-
_configPathResolver.getConfigPath.mockReturnValue('uat/conf');
|
|
22
21
|
});
|
|
23
22
|
test('throws an error when config file cannot be loaded', () => {
|
|
24
|
-
_fs.
|
|
25
|
-
|
|
23
|
+
_fs.existsSync.mockReturnValueOnce(true); // Main config file exists
|
|
24
|
+
|
|
25
|
+
jest.mock('/test/directory/conf/dev/actors/index.js', () => {
|
|
26
26
|
throw new Error('Loading error');
|
|
27
27
|
}, {
|
|
28
28
|
virtual: true
|
|
29
29
|
});
|
|
30
|
-
expect(() =>
|
|
30
|
+
expect(() => getListOfActors()).toThrow('Error loading actor configuration from /test/directory/conf/dev/actors/index.js');
|
|
31
31
|
});
|
|
32
32
|
test('throws an error when beta feature config does not exist', () => {
|
|
33
|
-
_fs.
|
|
33
|
+
_fs.existsSync.mockReturnValueOnce(true) // Main config file exists
|
|
34
34
|
.mockReturnValueOnce(false); // Beta feature config does not exist in either path
|
|
35
35
|
|
|
36
36
|
const betaFeature = 'nonExistentFeature';
|
|
37
|
-
expect(() =>
|
|
37
|
+
expect(() => getListOfActors(betaFeature)).toThrow(`There is no beta feature configured with the name "${betaFeature}"`);
|
|
38
38
|
});
|
|
39
|
-
test('loads main configuration when betaFeature is not provided and main config exists', () => {
|
|
40
|
-
_fs.
|
|
41
|
-
|
|
42
|
-
jest.doMock(file, () => ({
|
|
39
|
+
test('loads main configuration when betaFeature is not provided and main config file exists', () => {
|
|
40
|
+
_fs.existsSync.mockReturnValueOnce(true);
|
|
41
|
+
jest.doMock('/test/directory/conf/dev/actors/index.js', () => ({
|
|
43
42
|
actors: []
|
|
44
43
|
}), {
|
|
45
44
|
virtual: true
|
|
46
45
|
});
|
|
47
|
-
const result =
|
|
46
|
+
const result = getListOfActors();
|
|
48
47
|
expect(result).toEqual({
|
|
49
48
|
actors: []
|
|
50
49
|
});
|
|
51
50
|
});
|
|
52
51
|
test('falls back to default configuration if main config file does not exist', () => {
|
|
53
|
-
_fs.
|
|
54
|
-
.
|
|
55
|
-
|
|
56
|
-
const defaultConfigFile = _path.default.join(_path.default.resolve(process.cwd(), `${stage}/conf/default/actors/index.js`));
|
|
57
|
-
jest.doMock(defaultConfigFile, () => ({
|
|
52
|
+
_fs.existsSync.mockReturnValueOnce(false).mockReturnValueOnce(true);
|
|
53
|
+
jest.doMock('/test/directory/conf/default/actors/index.js', () => ({
|
|
58
54
|
actors: []
|
|
59
55
|
}), {
|
|
60
56
|
virtual: true
|
|
61
57
|
});
|
|
62
|
-
const result =
|
|
58
|
+
const result = getListOfActors();
|
|
63
59
|
expect(result).toEqual({
|
|
64
60
|
actors: []
|
|
65
61
|
});
|
|
66
62
|
});
|
|
67
63
|
test('loads beta feature configuration when betaFeature is provided', () => {
|
|
68
|
-
_fs.
|
|
64
|
+
_fs.existsSync.mockReturnValueOnce(true) // Main config file exists
|
|
69
65
|
.mockReturnValueOnce(true); // Beta feature config exists
|
|
70
66
|
|
|
71
67
|
const betaFeature = 'parentchild';
|
|
72
|
-
const betaFeaturePath =
|
|
68
|
+
const betaFeaturePath = `/test/directory/conf/dev/actors/beta/${betaFeature}/index.js`;
|
|
73
69
|
jest.doMock(betaFeaturePath, () => ({
|
|
74
70
|
betaActors: []
|
|
75
71
|
}), {
|
|
76
72
|
virtual: true
|
|
77
73
|
});
|
|
78
|
-
const result =
|
|
74
|
+
const result = getListOfActors(betaFeature);
|
|
79
75
|
expect(result).toEqual({
|
|
80
76
|
betaActors: []
|
|
81
77
|
});
|
|
78
|
+
expect(_path.default.join).toHaveBeenCalledWith('/test/directory', `conf/dev/actors/beta/${betaFeature}/index.js`);
|
|
82
79
|
});
|
|
83
80
|
});
|