@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.
@@ -10,11 +10,13 @@ function Given(description, callback) {
10
10
  const Then = Given;
11
11
  const When = Given;
12
12
  const And = Given;
13
+ const Step = Given;
13
14
  function createBdd() {
14
15
  return {
15
16
  Given,
16
17
  When,
17
18
  Then,
18
- And
19
+ And,
20
+ Step
19
21
  };
20
22
  }
@@ -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 obj = {};
74
+ const InputObject = {};
75
75
  array.forEach((item, index) => {
76
- obj[`<${tableHeader[index]}>`] = item;
76
+ InputObject[`<${tableHeader[index]}>`] = item;
77
77
  });
78
- result.push(obj);
78
+ result.push(InputObject);
79
79
  });
80
- } else {
81
- return;
82
80
  }
83
81
  return result;
84
82
  }
@@ -1,69 +1,70 @@
1
- "use strict";
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
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.allowedTags = allowedTags;
7
- exports.expressionHandle = expressionHandle;
8
- var _tagProcessor = require("../../core/playwright/tag-processor");
9
- const editionOrder = ['Free', 'Express', 'Standard', 'Professional', 'Enterprise'];
10
- function allowedTags(userArgs) {
11
- let tags = (userArgs === null || userArgs === void 0 ? void 0 : userArgs.tags) || null;
12
- if (tags !== null) {
13
- if (Array.isArray(tags)) {
14
- return buildGrepTags(tags, '|');
15
- }
16
- return tags;
17
- }
18
- let edition = (userArgs === null || userArgs === void 0 ? void 0 : userArgs.edition) || null;
19
- if (edition !== null) {
20
- const editionFrmCli = edition.split(',');
21
- if (editionFrmCli.length === 1) {
22
- // const sortedEdition = editionPreprocessing(editionOrder,editionFrmCli)
23
- return (0, _tagProcessor.buildEditionTags)(expressionHandle(editionFrmCli, editionOrder), '|');
24
- }
25
- }
26
- return;
27
- }
28
- function buildGrepTags(tags, operator) {
29
- return tags.join(`${operator}`);
30
- }
31
- function expressionHandle(editionFrmCli, editionOrder) {
32
- var expression;
33
- var $edition;
34
- if (editionFrmCli.split('=').length !== 1) {
35
- expression = editionFrmCli.split('').slice(0, 2).join('');
36
- $edition = editionFrmCli.split('=').pop();
37
- } else if (editionFrmCli.split('>').length !== 1) {
38
- expression = editionFrmCli.split('').slice(0, 1).join('');
39
- $edition = editionFrmCli.split('>').pop();
40
- } else {
41
- expression = editionFrmCli.split('').slice(0, 1).join('');
42
- $edition = editionFrmCli.split('<').pop();
43
- }
44
- const index_Edition = editionOrder.indexOf($edition);
45
- switch (expression) {
46
- case '>=':
47
- if ($edition == editionOrder[editionOrder.length - 1]) {
48
- return editionOrder[editionOrder.length - 1];
49
- }
50
- return editionOrder.slice(0, index_Edition);
51
- case '<=':
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
- // ...addTags
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
- return tags && tags !== '' ? `${tags} and not (${editionTags})` : `not (${editionTags})`;
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 => `@edition_${edition}`).join(` ${operator} `);
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, 'or');
60
- tagArgs = `${getTagsString(tagArgs, editionTags)}`;
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, 'or');
66
- tagArgs = `${getTagsString(tagArgs, editionTags)}`;
71
+ const editionTags = buildEditionTags(filteredEditions, '|', "@edition_");
72
+ filteredTags = editionTags;
67
73
  }
68
74
  }
69
- return tagArgs;
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
- var _tagsHandle = require("../../bdd-poc/test/tagsHandle");
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
- if (!bddMode && tagArgs) {
28
- playwrightArgs.push('--grep');
29
- playwrightArgs.push(tagArgs);
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 => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/testinglibrary",
3
- "version": "0.1.8-stb-bdd-v6",
3
+ "version": "0.1.8-stb-bdd-v8",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {