@zohodesk/testinglibrary 0.1.8-stb-bdd-v6 → 0.1.8-stb-bdd-v8
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/bdd-poc/core-runner/exportMethods.js +3 -1
- package/build/bdd-poc/core-runner/stepDefinitions.js +3 -1
- package/build/bdd-poc/test/cucumber/featureFileParer.js +3 -5
- package/build/bdd-poc/test/tagsHandle.js +69 -68
- package/build/core/playwright/builtInFixtures/index.js +5 -2
- package/build/core/playwright/tag-processor.js +19 -10
- package/build/core/playwright/test-runner.js +23 -12
- package/package.json +1 -1
|
@@ -42,11 +42,13 @@ function getInputArray(description, argument) {
|
|
|
42
42
|
const $When = $Given;
|
|
43
43
|
const $And = $Given;
|
|
44
44
|
const $Then = $Given;
|
|
45
|
+
const $Step = $Given;
|
|
45
46
|
function createNativeBDD() {
|
|
46
47
|
return {
|
|
47
48
|
$Given,
|
|
48
49
|
$When,
|
|
49
50
|
$And,
|
|
50
|
-
$Then
|
|
51
|
+
$Then,
|
|
52
|
+
$Step
|
|
51
53
|
};
|
|
52
54
|
}
|
|
@@ -71,14 +71,12 @@ function testDataExtraction(tableHeader, tableBody) {
|
|
|
71
71
|
const result = [];
|
|
72
72
|
if (tableBody && tableHeader) {
|
|
73
73
|
tableBody.forEach(array => {
|
|
74
|
-
const
|
|
74
|
+
const InputObject = {};
|
|
75
75
|
array.forEach((item, index) => {
|
|
76
|
-
|
|
76
|
+
InputObject[`<${tableHeader[index]}>`] = item;
|
|
77
77
|
});
|
|
78
|
-
result.push(
|
|
78
|
+
result.push(InputObject);
|
|
79
79
|
});
|
|
80
|
-
} else {
|
|
81
|
-
return;
|
|
82
80
|
}
|
|
83
81
|
return result;
|
|
84
82
|
}
|
|
@@ -1,69 +1,70 @@
|
|
|
1
|
-
|
|
1
|
+
// const editionOrder = ['Free','Express','Standard','Professional','Enterprise']
|
|
2
|
+
// import { buildEditionTags} from '../../core/playwright/tag-processor'
|
|
3
|
+
// function allowedTags(userArgs){
|
|
4
|
+
// let tags = userArgs?.tags || null
|
|
5
|
+
// if(tags){
|
|
6
|
+
// if(Array.isArray(tags)){
|
|
7
|
+
// return buildGrepTags(tags,'|')
|
|
8
|
+
// }
|
|
9
|
+
// return tags;
|
|
10
|
+
// }
|
|
11
|
+
// let edition = userArgs?.edition || null
|
|
12
|
+
// if(edition){
|
|
13
|
+
// const editionFrmCli = edition.split(',')
|
|
14
|
+
// if(editionFrmCli.length === 1){
|
|
15
|
+
// // const sortedEdition = editionPreprocessing(editionOrder,editionFrmCli)
|
|
16
|
+
// return buildEditionTags(expressionHandle(editionFrmCli,editionOrder),'|')
|
|
17
|
+
// }
|
|
18
|
+
// }
|
|
19
|
+
// return;
|
|
20
|
+
// }
|
|
2
21
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if ($edition == editionOrder[0]) {
|
|
53
|
-
return editionOrder.slice(1, editionOrder.length + 1);
|
|
54
|
-
}
|
|
55
|
-
return editionOrder.slice(index_Edition + 1, editionOrder.length + 1);
|
|
56
|
-
case '<':
|
|
57
|
-
if ($edition == editionOrder[0]) {
|
|
58
|
-
return editionOrder;
|
|
59
|
-
}
|
|
60
|
-
return editionOrder.slice(index_Edition, editionOrder.length + 1);
|
|
61
|
-
case '>':
|
|
62
|
-
if ($edition == editionOrder[editionOrder.length - 1]) {
|
|
63
|
-
return editionOrder;
|
|
64
|
-
}
|
|
65
|
-
return editionOrder.slice(0, index_Edition + 1);
|
|
66
|
-
default:
|
|
67
|
-
break;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
22
|
+
// function buildGrepTags(tags,operator){
|
|
23
|
+
// return tags.join(`${operator}`)
|
|
24
|
+
// }
|
|
25
|
+
|
|
26
|
+
// function expressionHandle(editionFrmCli,editionOrder){
|
|
27
|
+
// var expression;
|
|
28
|
+
// var $edition;
|
|
29
|
+
// if(editionFrmCli.split('=').length !== 1){
|
|
30
|
+
// expression = editionFrmCli.split('').slice(0,2).join('');
|
|
31
|
+
// $edition = editionFrmCli.split('=').pop()
|
|
32
|
+
// }else if(editionFrmCli.split('>').length !== 1){
|
|
33
|
+
// expression = editionFrmCli.split('').slice(0,1).join('');
|
|
34
|
+
// $edition = editionFrmCli.split('>').pop()
|
|
35
|
+
// }else {
|
|
36
|
+
// expression = editionFrmCli.split('').slice(0,1).join('');
|
|
37
|
+
// $edition = editionFrmCli.split('<').pop()
|
|
38
|
+
// }
|
|
39
|
+
// const index_Edition = editionOrder.indexOf($edition)
|
|
40
|
+
// switch(expression){
|
|
41
|
+
// case '>=':
|
|
42
|
+
// if($edition == editionOrder[editionOrder.length-1]){
|
|
43
|
+
// return editionOrder[editionOrder.length-1]
|
|
44
|
+
// }
|
|
45
|
+
// return editionOrder.slice(0,index_Edition);
|
|
46
|
+
// case '<=':
|
|
47
|
+
// if($edition == editionOrder[0]){
|
|
48
|
+
// return editionOrder.slice(1,editionOrder.length + 1)
|
|
49
|
+
// }
|
|
50
|
+
// return editionOrder.slice(index_Edition+1,editionOrder.length+1);
|
|
51
|
+
// case '<':
|
|
52
|
+
// if($edition == editionOrder[0]){
|
|
53
|
+
// return editionOrder;
|
|
54
|
+
// }
|
|
55
|
+
// return editionOrder.slice(index_Edition, editionOrder.length + 1);
|
|
56
|
+
// case '>':
|
|
57
|
+
// if($edition == editionOrder[editionOrder.length-1]){
|
|
58
|
+
// return editionOrder;
|
|
59
|
+
// }
|
|
60
|
+
// return editionOrder.slice(0,index_Edition+1);
|
|
61
|
+
// default:
|
|
62
|
+
// break;
|
|
63
|
+
// }
|
|
64
|
+
// }
|
|
65
|
+
|
|
66
|
+
// export {
|
|
67
|
+
// allowedTags,
|
|
68
|
+
// expressionHandle
|
|
69
|
+
// }
|
|
70
|
+
"use strict";
|
|
@@ -10,6 +10,9 @@ var _context = _interopRequireDefault(require("./context"));
|
|
|
10
10
|
var _cacheLayer = _interopRequireDefault(require("./cacheLayer"));
|
|
11
11
|
// import addTags from './addTags';
|
|
12
12
|
|
|
13
|
+
const addTags = {
|
|
14
|
+
$tags: ({}, use) => use([])
|
|
15
|
+
};
|
|
13
16
|
function getBuiltInFixtures(bddMode) {
|
|
14
17
|
let builtInFixtures = {
|
|
15
18
|
..._page.default,
|
|
@@ -18,8 +21,8 @@ function getBuiltInFixtures(bddMode) {
|
|
|
18
21
|
};
|
|
19
22
|
if (bddMode) {
|
|
20
23
|
builtInFixtures = {
|
|
21
|
-
...builtInFixtures
|
|
22
|
-
|
|
24
|
+
...builtInFixtures,
|
|
25
|
+
...addTags
|
|
23
26
|
};
|
|
24
27
|
}
|
|
25
28
|
return builtInFixtures;
|
|
@@ -9,9 +9,10 @@ exports.tagProcessor = tagProcessor;
|
|
|
9
9
|
var _logger = require("../../utils/logger");
|
|
10
10
|
/* eslint-disable dot-notation */
|
|
11
11
|
|
|
12
|
-
function getTagsString(tags, editionTags) {
|
|
13
|
-
|
|
14
|
-
}
|
|
12
|
+
// function getTagsString(tags, editionTags) {
|
|
13
|
+
// return tags && tags !== '' ? `${tags} and not (${editionTags})` : `not (${editionTags})`;
|
|
14
|
+
// }
|
|
15
|
+
|
|
15
16
|
function getEdition(edition) {
|
|
16
17
|
if (edition.startsWith('<=')) {
|
|
17
18
|
return ['<=', edition.slice(2)];
|
|
@@ -45,26 +46,34 @@ function editionPreprocessing(editionOrder, selectedEdition) {
|
|
|
45
46
|
_logger.Logger.log(_logger.Logger.INFO_TYPE, `No matching editions ${selectedEdition} found. Running with default edition`);
|
|
46
47
|
return [];
|
|
47
48
|
}
|
|
48
|
-
function buildEditionTags(editionArgs, operator) {
|
|
49
|
-
return editionArgs.map(edition =>
|
|
49
|
+
function buildEditionTags(editionArgs, operator, prefix = "") {
|
|
50
|
+
return editionArgs.map(edition => `${prefix}${edition}`).join(` ${operator} `);
|
|
50
51
|
}
|
|
51
52
|
function tagProcessor(userArgsObject, editionOrder) {
|
|
53
|
+
let filteredTags;
|
|
52
54
|
let tagArgs = userArgsObject['tags'];
|
|
55
|
+
let multiTags = userArgsObject['tags'] || " ";
|
|
56
|
+
if (multiTags.split(',').length >= 2) {
|
|
57
|
+
tagArgs = buildEditionTags(multiTags.split(','), '|');
|
|
58
|
+
}
|
|
53
59
|
const edition = userArgsObject['edition'] || null;
|
|
54
60
|
if (edition !== null) {
|
|
55
61
|
let editionsArray = edition.split(',');
|
|
56
62
|
if (editionsArray.length === 1) {
|
|
57
63
|
const editionArgs = editionPreprocessing(editionOrder, edition);
|
|
58
64
|
if (editionArgs && editionArgs.length > 0) {
|
|
59
|
-
const editionTags = buildEditionTags(editionArgs, '
|
|
60
|
-
|
|
65
|
+
const editionTags = buildEditionTags(editionArgs, '|', "@edition_");
|
|
66
|
+
filteredTags = editionTags;
|
|
61
67
|
}
|
|
62
68
|
} else {
|
|
63
69
|
// More than one edition given
|
|
64
70
|
const filteredEditions = editionOrder.filter(edition => !editionsArray.includes(edition));
|
|
65
|
-
const editionTags = buildEditionTags(filteredEditions, '
|
|
66
|
-
|
|
71
|
+
const editionTags = buildEditionTags(filteredEditions, '|', "@edition_");
|
|
72
|
+
filteredTags = editionTags;
|
|
67
73
|
}
|
|
68
74
|
}
|
|
69
|
-
return
|
|
75
|
+
return {
|
|
76
|
+
tags: tagArgs,
|
|
77
|
+
editionTags: filteredTags
|
|
78
|
+
};
|
|
70
79
|
}
|
|
@@ -15,7 +15,8 @@ var _readConfigFile = require("./readConfigFile");
|
|
|
15
15
|
var _rootPath = require("../../utils/rootPath");
|
|
16
16
|
var _tagProcessor = require("./tag-processor");
|
|
17
17
|
var _bddPoc = require("../../bdd-poc");
|
|
18
|
-
|
|
18
|
+
// import { allowedTags } from '../../bdd-poc/test/tagsHandle';
|
|
19
|
+
|
|
19
20
|
function parseUserArgs() {
|
|
20
21
|
return (0, _cliArgsToObject.cliArgsToObject)(process.argv.slice(2));
|
|
21
22
|
}
|
|
@@ -24,9 +25,25 @@ function getPlaywrightArgs(userArgsObject, debug, bddMode, tagArgs, headless) {
|
|
|
24
25
|
if (debug) {
|
|
25
26
|
playwrightArgs.push('--debug');
|
|
26
27
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
|
|
29
|
+
// if (!bddMode && tagArgs) {
|
|
30
|
+
// playwrightArgs.push('--grep');
|
|
31
|
+
// playwrightArgs.push(tagArgs);
|
|
32
|
+
// }
|
|
33
|
+
|
|
34
|
+
if (tagArgs && userArgsObject !== null && userArgsObject !== void 0 && userArgsObject.edition || userArgsObject !== null && userArgsObject !== void 0 && userArgsObject.tags) {
|
|
35
|
+
const {
|
|
36
|
+
tags,
|
|
37
|
+
editionTags
|
|
38
|
+
} = tagArgs;
|
|
39
|
+
if (tags) {
|
|
40
|
+
playwrightArgs.push('--grep');
|
|
41
|
+
playwrightArgs.push(tags);
|
|
42
|
+
}
|
|
43
|
+
if (editionTags) {
|
|
44
|
+
playwrightArgs.push('--grep-invert');
|
|
45
|
+
playwrightArgs.push(editionTags);
|
|
46
|
+
}
|
|
30
47
|
}
|
|
31
48
|
if (!headless && !userArgsObject.headed) {
|
|
32
49
|
playwrightArgs.push('--headed');
|
|
@@ -101,6 +118,8 @@ function main() {
|
|
|
101
118
|
editionOrder
|
|
102
119
|
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
103
120
|
const tagArgs = (0, _tagProcessor.tagProcessor)(userArgsObject, editionOrder);
|
|
121
|
+
// const tagArgs = allowedTags(userArgsObject)
|
|
122
|
+
|
|
104
123
|
const playwrightArgs = getPlaywrightArgs(userArgsObject, debug, bddMode, tagArgs, headless);
|
|
105
124
|
(0, _envInitializer.initializeEnvConfig)(userArgsObject.mode ? userArgsObject.mode : mode);
|
|
106
125
|
const playwrightPath = _path.default.resolve((0, _rootPath.getExecutableBinaryPath)('playwright'));
|
|
@@ -109,14 +128,6 @@ function main() {
|
|
|
109
128
|
let promises = [];
|
|
110
129
|
if (bddMode) {
|
|
111
130
|
promises.push((0, _bddPoc.createCucumberBDD)());
|
|
112
|
-
if (userArgsObject !== null && userArgsObject !== void 0 && userArgsObject.edition || userArgsObject !== null && userArgsObject !== void 0 && userArgsObject.tags) {
|
|
113
|
-
if (userArgsObject !== null && userArgsObject !== void 0 && userArgsObject.edition) {
|
|
114
|
-
playwrightArgs.push('--grep-invert');
|
|
115
|
-
} else {
|
|
116
|
-
playwrightArgs.push('--grep');
|
|
117
|
-
}
|
|
118
|
-
playwrightArgs.push((0, _tagsHandle.allowedTags)(userArgsObject));
|
|
119
|
-
}
|
|
120
131
|
}
|
|
121
132
|
const args = ['test', '--config', configPath].concat(playwrightArgs);
|
|
122
133
|
Promise.all(promises).then(() => runPlaywright(command, args)).catch(err => {
|