@zohodesk/testinglibrary 0.1.5-exp.1 → 0.1.5-exp.3
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.
|
@@ -10,7 +10,6 @@ exports.getAuthFilePath = getAuthFilePath;
|
|
|
10
10
|
exports.isUserConfigFileAvailable = isUserConfigFileAvailable;
|
|
11
11
|
var _fs = require("fs");
|
|
12
12
|
var _path = _interopRequireDefault(require("path"));
|
|
13
|
-
var _importSync = _interopRequireDefault(require("import-sync"));
|
|
14
13
|
var _logger = require("../../utils/logger");
|
|
15
14
|
const fileName = exports.fileName = 'uat.config.js';
|
|
16
15
|
function getDefaultConfig() {
|
|
@@ -35,7 +34,8 @@ function getDefaultConfig() {
|
|
|
35
34
|
additionalPages: {},
|
|
36
35
|
featureFilesFolder: 'feature-files',
|
|
37
36
|
stepDefinitionsFolder: 'steps',
|
|
38
|
-
testIdAttribute: 'data-testid'
|
|
37
|
+
testIdAttribute: 'data-testid',
|
|
38
|
+
editionOrder: ['Free', 'Express', 'Standard', 'Professional', 'Enterprise']
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
function combineDefaultConfigWithUserConfig(userConfiguration) {
|
|
@@ -84,6 +84,7 @@ function combineDefaultConfigWithUserConfig(userConfiguration) {
|
|
|
84
84
|
* @property {string} stepDefinitionsFolder: folder name under which step implementations will be placed. Default is steps
|
|
85
85
|
* @property {viewportConfig} viewport: viewport configuration for the browser. Default is { width: 1280, height: 720 }
|
|
86
86
|
* @property {string} testIdAttribute: Change the default data-testid attribute. configure what attribute to search while calling getByTestId
|
|
87
|
+
* @property {Array} editionOrder: Order in the form of larger editions in the back. Edition with the most privelages should be last
|
|
87
88
|
*/
|
|
88
89
|
|
|
89
90
|
/**
|
|
@@ -95,7 +96,7 @@ function generateConfigFromFile() {
|
|
|
95
96
|
const filePath = _path.default.resolve(process.cwd(), fileName);
|
|
96
97
|
if ((0, _fs.existsSync)(filePath)) {
|
|
97
98
|
/** @type {UserConfig} */
|
|
98
|
-
const config = (
|
|
99
|
+
const config = require(filePath);
|
|
99
100
|
const modifiedConfiguration = combineDefaultConfigWithUserConfig(config);
|
|
100
101
|
return modifiedConfiguration;
|
|
101
102
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.tagProcessor = tagProcessor;
|
|
7
|
+
function getTagsString(tags, editionTags) {
|
|
8
|
+
return tags && tags !== '' ? `${tags} or (${editionTags})` : `${editionTags}`;
|
|
9
|
+
}
|
|
10
|
+
function getEdition(edition) {
|
|
11
|
+
if (edition.startsWith('<=')) {
|
|
12
|
+
return ['<=', edition.slice(2)];
|
|
13
|
+
} else if (edition.startsWith('>=')) {
|
|
14
|
+
return ['>=', edition.slice(2)];
|
|
15
|
+
} else if (edition.startsWith('<')) {
|
|
16
|
+
return ['<', edition.slice(1)];
|
|
17
|
+
} else if (edition.startsWith('>')) {
|
|
18
|
+
return ['>', edition.slice(1)];
|
|
19
|
+
}
|
|
20
|
+
return [null, edition];
|
|
21
|
+
}
|
|
22
|
+
function editionPreprocessing(editionOrder, selectedEdition) {
|
|
23
|
+
const [operator, editionToBeSearched] = getEdition(selectedEdition.toLowerCase());
|
|
24
|
+
const index = editionOrder.findIndex(edition => edition.toLowerCase() === editionToBeSearched);
|
|
25
|
+
if (index !== -1) {
|
|
26
|
+
let resultArray;
|
|
27
|
+
if (operator === '>') {
|
|
28
|
+
resultArray = editionOrder.slice(index + 1);
|
|
29
|
+
} else if (operator === '<') {
|
|
30
|
+
resultArray = editionOrder.slice(0, index);
|
|
31
|
+
} else if (operator === '>=') {
|
|
32
|
+
resultArray = editionOrder.slice(index);
|
|
33
|
+
} else if (operator === '<=') {
|
|
34
|
+
resultArray = editionOrder.slice(0, index + 1);
|
|
35
|
+
} else {
|
|
36
|
+
resultArray = [editionOrder[index]];
|
|
37
|
+
}
|
|
38
|
+
return resultArray;
|
|
39
|
+
}
|
|
40
|
+
Logger.log(Logger.INFO_TYPE, `No matching editions ${selectedEdition} found. Running with default edition`);
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
function buildEditionTags(editionArgs, operator) {
|
|
44
|
+
return editionArgs.map(edition => `@edition_${edition}`).join(` ${operator} `);
|
|
45
|
+
}
|
|
46
|
+
function tagProcessor(userArgsObject, editionOrder) {
|
|
47
|
+
let tagArgs = userArgsObject['tags'];
|
|
48
|
+
const edition = userArgsObject['edition'] || null;
|
|
49
|
+
if (edition !== null) {
|
|
50
|
+
let editionsArray = edition.split(',');
|
|
51
|
+
if (editionsArray.length === 1) {
|
|
52
|
+
const editionArgs = editionPreprocessing(editionOrder, edition);
|
|
53
|
+
if (editionArgs && editionArgs.length > 0) {
|
|
54
|
+
const editionTags = buildEditionTags(editionArgs, 'or');
|
|
55
|
+
tagArgs = `${getTagsString(tagArgs, editionTags)}`;
|
|
56
|
+
}
|
|
57
|
+
} else {
|
|
58
|
+
// More than one edition given
|
|
59
|
+
const editionTags = buildEditionTags(editionsArray, 'And');
|
|
60
|
+
tagArgs = `${getTagsString(tagArgs, editionTags)}`;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return tagArgs;
|
|
64
|
+
}
|
|
@@ -13,6 +13,7 @@ var _envInitializer = require("./env-initializer");
|
|
|
13
13
|
var _logger = require("../../utils/logger");
|
|
14
14
|
var _readConfigFile = require("./readConfigFile");
|
|
15
15
|
var _rootPath = require("../../utils/rootPath");
|
|
16
|
+
var _tagProcessor = require("./tag-processor");
|
|
16
17
|
function parseUserArgs() {
|
|
17
18
|
return (0, _cliArgsToObject.cliArgsToObject)(process.argv.slice(2));
|
|
18
19
|
}
|
|
@@ -85,13 +86,15 @@ function runPlaywright(command, args) {
|
|
|
85
86
|
function main() {
|
|
86
87
|
const userArgsObject = parseUserArgs();
|
|
87
88
|
// eslint-disable-next-line
|
|
88
|
-
|
|
89
|
+
|
|
89
90
|
const {
|
|
90
91
|
debug,
|
|
91
92
|
mode = 'dev',
|
|
92
93
|
bddMode = false,
|
|
93
|
-
headless = false
|
|
94
|
+
headless = false,
|
|
95
|
+
editionOrder
|
|
94
96
|
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
97
|
+
const tagArgs = (0, _tagProcessor.tagProcessor)(userArgsObject, editionOrder);
|
|
95
98
|
const playwrightArgs = getPlaywrightArgs(userArgsObject, debug, bddMode, tagArgs, headless);
|
|
96
99
|
(0, _envInitializer.initializeEnvConfig)(userArgsObject.mode ? userArgsObject.mode : mode);
|
|
97
100
|
const playwrightPath = _path.default.resolve((0, _rootPath.getExecutableBinaryPath)('playwright'));
|
package/npm-shrinkwrap.json
CHANGED