@zohodesk/testinglibrary 0.4.6-experimental → 0.4.8-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.
Files changed (61) hide show
  1. package/.gitlab-ci.yml +35 -20
  2. package/README.md +13 -2
  3. package/build/core/playwright/builtInFixtures/page.js +7 -0
  4. package/build/core/playwright/fixtures.js +1 -1
  5. package/build/core/playwright/helpers/auth/getUsers.js +12 -25
  6. package/build/core/playwright/runner/Runner.js +22 -0
  7. package/build/core/playwright/runner/RunnerHelper.js +43 -0
  8. package/build/core/playwright/runner/RunnerTypes.js +17 -0
  9. package/build/core/playwright/runner/SpawnRunner.js +110 -0
  10. package/build/core/playwright/tagProcessor.js +79 -0
  11. package/build/core/playwright/test-runner.js +11 -36
  12. package/build/core/playwright/validateFeature.js +3 -33
  13. package/build/setup-folder-structure/samples/actors-index.js +0 -1
  14. package/build/setup-folder-structure/samples/settings.json +1 -1
  15. package/build/test/Test.js +11 -0
  16. package/build/test/core/playwright/__tests__/tagProcessor.test.js +94 -0
  17. package/build/test/core/playwright/__tests__/validateFeature.test.js +10 -5
  18. package/build/test/core/playwright/helpers/__tests__/getUsers_ListOfActors.test.js +80 -0
  19. package/build/test/core/playwright/runner/__tests__/RunnerHelper.test.js +16 -0
  20. package/build/test/core/playwright/runner/__tests__/SpawnRunner.test.js +27 -0
  21. package/nobdd/src/App.js +7 -0
  22. package/nobdd/uat/conf/default/actors/index.js +1 -4
  23. package/nobdd/uat/conf/default/settings.json +1 -1
  24. package/nobdd/uat/conf/nobdd/uat.config.js +3 -2
  25. package/nobdd/uat/env-config.json +3 -3
  26. package/nobdd/uat/fixtures/setup.teardown.js +2 -1
  27. package/nobdd/uat/modules/nobdd/steps/VerifyNoBDD.feature.spec.js +3 -3
  28. package/nobdd/uat/playwright/.auth/anitha.m+clientat@zohotest.com-cookies.json +276 -0
  29. package/nobdd/uat/playwright/.auth/anitha.m+clientattest@zohotest.com-cookies.json +3 -0
  30. package/nobdd/uat/playwright/.auth/anitha.m+uat@zohotest.com-cookies.json +3 -0
  31. package/nobdd/uat/playwright/.auth/skumaresan@zohotest.com-cookies.json +503 -0
  32. package/nobdd/uat/playwright/.auth/solairaj.m+26jun2023@zohotest.com-cookies.json +173 -0
  33. package/nobdd/uat/playwright/.auth/sridhar.parthasarathy@zohotest.com-cookies.json +520 -0
  34. package/nobdd/uat/playwright-report/data/15676399fddfec429bc2935c407212f42cfa65b2.webm +0 -0
  35. package/nobdd/uat/playwright-report/data/7be7af3de16a483f32cdcb86b3a290f584e21f76.zip +0 -0
  36. package/nobdd/uat/playwright-report/index.html +68 -0
  37. package/nobdd/uat/playwright-report/test-summary.json +17 -0
  38. package/nobdd/uat/playwright-report/trace/assets/codeMirrorModule-BK3t1EEu.js +24 -0
  39. package/nobdd/uat/playwright-report/trace/assets/wsPort-964mA9MZ.js +69 -0
  40. package/nobdd/uat/playwright-report/trace/codeMirrorModule.Hs9-1ZG4.css +1 -0
  41. package/nobdd/uat/playwright-report/trace/codicon.zGuYmc9o.ttf +0 -0
  42. package/nobdd/uat/playwright-report/trace/index.-g_5lMbJ.css +1 -0
  43. package/nobdd/uat/playwright-report/trace/index.cbtHmFgM.js +2 -0
  44. package/nobdd/uat/playwright-report/trace/index.html +26 -0
  45. package/nobdd/uat/playwright-report/trace/playwright-logo.svg +9 -0
  46. package/nobdd/uat/playwright-report/trace/snapshot.html +21 -0
  47. package/nobdd/uat/playwright-report/trace/sw.bundle.js +4 -0
  48. package/nobdd/uat/playwright-report/trace/uiMode.fcU_T5Nf.js +10 -0
  49. package/nobdd/uat/playwright-report/trace/uiMode.html +17 -0
  50. package/nobdd/uat/playwright-report/trace/uiMode.pWy0Re7G.css +1 -0
  51. package/nobdd/uat/playwright-report/trace/wsPort.zR1WIy9-.css +1 -0
  52. package/nobdd/uat/playwright-report/trace/xtermModule.0lwXJFHT.css +32 -0
  53. package/nobdd/uat/test-results/modules-nobdd-steps-ExamplesForTestData.featur-a74c6-required-nobdd-Verify-the-page-is-not-logged-in-chromium/trace.zip +0 -0
  54. package/nobdd/uat/test-results/modules-nobdd-steps-ExamplesForTestData.featur-a74c6-required-nobdd-Verify-the-page-is-not-logged-in-chromium/video.webm +0 -0
  55. package/nobdd/uat.config.js +3 -2
  56. package/package.json +1 -1
  57. package/build/core/playwright/tag-processor.js +0 -68
  58. package/nobdd/uat/conf/default/actors/beta/custom-module.json +0 -24
  59. package/nobdd/uat/conf/default/actors/beta/index.js +0 -6
  60. package/nobdd/uat/conf/default/actors/beta/parent-child.json +0 -24
  61. package/npm-shrinkwrap.json +0 -10125
package/.gitlab-ci.yml CHANGED
@@ -1,29 +1,35 @@
1
- image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v2
1
+ image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v3
2
2
 
3
- #workflow:
4
- # rules:
5
- # - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
3
+ workflow:
4
+ rules:
5
+ - if: $CI_PIPELINE_SOURCE == "merge_request_event"
6
+ when: always
7
+ - if: $CI_PIPELINE_SOURCE == "web"
8
+ when: always
6
9
 
7
10
  stages:
8
11
  - build
9
12
  - unit
10
13
  - uat
11
14
 
15
+ default:
16
+ cache:
17
+ key: build-cache
18
+ paths:
19
+ - node_modules
20
+ - build
21
+
12
22
  # Install dependencies stage
13
23
  build:
14
24
  stage: build
15
- image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v2
16
25
  script:
26
+ - npm install --ignore-scripts
27
+ - npm run build
17
28
  - npm install
18
- artifacts:
19
- paths:
20
- - node_modules/
21
-
22
29
 
23
30
  # Unit tests stage
24
31
  unit:
25
32
  stage: unit
26
- image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v2
27
33
  script:
28
34
  - npm run test
29
35
  artifacts:
@@ -34,10 +40,7 @@ unit:
34
40
  # UAT tests stage
35
41
  uat-auth:
36
42
  stage: uat
37
- image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v2
38
43
  script:
39
- - npm install
40
- - npm run build
41
44
  - cd examples
42
45
  - npm install $(npm pack ../../testing-framework | tail -1)
43
46
  - output=$(npm run uatauth)
@@ -53,10 +56,7 @@ uat-auth:
53
56
 
54
57
  uat-noauth:
55
58
  stage: uat
56
- image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v2
57
59
  script:
58
- - npm install
59
- - npm run build
60
60
  - cd examples
61
61
  - npm install $(npm pack ../../testing-framework | tail -1)
62
62
  - output=$(npm run uatnoauth)
@@ -72,10 +72,7 @@ uat-noauth:
72
72
 
73
73
  uat-profile:
74
74
  stage: uat
75
- image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v2
76
75
  script:
77
- - npm install
78
- - npm run build
79
76
  - cd examples
80
77
  - npm install $(npm pack ../../testing-framework | tail -1)
81
78
  - output=$(npm run uatprofile)
@@ -89,12 +86,30 @@ uat-profile:
89
86
  paths:
90
87
  - examples/uat/playwright-report
91
88
 
92
- uat-nobdd:
89
+
90
+ uat-unauth:
93
91
  stage: uat
94
92
  image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v2
95
93
  script:
96
94
  - npm install
97
95
  - npm run build
96
+ - cd examples
97
+ - npm install $(npm pack ../../testing-framework | tail -1)
98
+ - output=$(npm run uatunauth)
99
+ - echo "$output"
100
+ - if [[ "$output" == *"failed"* ]]; then
101
+ - exit 1
102
+ - fi
103
+
104
+
105
+ artifacts:
106
+ when: always
107
+ paths:
108
+ - examples/uat/playwright-report
109
+
110
+ uat-nobdd:
111
+ stage: uat
112
+ script:
98
113
  - cd nobdd
99
114
  - npm install $(npm pack ../../testing-framework | tail -1)
100
115
  - output=$(npm run uatnobdd)
package/README.md CHANGED
@@ -49,7 +49,18 @@
49
49
  - @playwright/test - 1.48.0,
50
50
  - @cucumber/cucumber - 11.0.1
51
51
  - From this version, We adopt the playwright-bdd as library instead of modified source
52
-
52
+ - Published on 11-11-2024
53
+
53
54
  #### Deprecations
54
55
  - **Deprecated**: Passing `video` and `trace` as boolean (`true`/`false`) in project configuration.
55
- - **New Approach**: Use Playwright values for `video` and `trace` options, such as `'on'`, `'retain-on-failure'`, or `'off'`.
56
+ - **New Approach**: Use Playwright values for `video` and `trace` options, such as `'on'`, `'retain-on-failure'`, or `'off'`.
57
+
58
+ ### v0.3.1 - 13-11-2024
59
+
60
+ #### Issue Fix
61
+ - Adding bddmode to get the fixtures.
62
+
63
+ ### v0.2.9.1 - 14-11-2024
64
+
65
+ #### Enhancement
66
+ - Beta feature Actors and edition configurations are unified
@@ -70,6 +70,13 @@ var _default = exports.default = {
70
70
  await use(page);
71
71
  return;
72
72
  }
73
+
74
+ //This block is used to skip the login process if the @unauthenticated tag is added to the script
75
+ if ($tags.includes('@unauthenticated')) {
76
+ await context.clearCookies();
77
+ await use(page);
78
+ return;
79
+ }
73
80
  const testPortalDetails = getCustomAccountDetails($tags);
74
81
  if (testPortalDetails === null) {
75
82
  await performDefaultPageSteps({
@@ -10,7 +10,7 @@ const {
10
10
  bddMode
11
11
  } = (0, _readConfigFile.generateConfigFromFile)();
12
12
  let base = bddMode ? _playwrightBdd.test : _test.test;
13
- const buildInFixtures = (0, _builtInFixtures.default)();
13
+ const buildInFixtures = (0, _builtInFixtures.default)(bddMode);
14
14
  const buildInFixturesTest = base.extend({
15
15
  ...buildInFixtures
16
16
  });
@@ -52,14 +52,22 @@ function getDefaultActor() {
52
52
  } = getDefaultActorConf();
53
53
  return getUserForSelectedEditionAndProfile(edition, profile);
54
54
  }
55
- function getListOfActors() {
55
+ function getListOfActors(betaFeature) {
56
56
  const {
57
57
  uatDirectory
58
58
  } = (0, _readConfigFile.generateConfigFromFile)();
59
59
  const mode = getRunMode();
60
60
  let configFile = _path.default.join(uatDirectory, `conf/${mode}/actors/index.js`);
61
+ let betaReference = mode;
61
62
  if (!(0, _fs.existsSync)(configFile)) {
62
63
  configFile = _path.default.join(uatDirectory, `conf/default/actors/index.js`);
64
+ betaReference = "default";
65
+ }
66
+ if (betaFeature) {
67
+ configFile = _path.default.join(uatDirectory, `conf/${betaReference}/actors/beta/${betaFeature}/index.js`);
68
+ if (!(0, _fs.existsSync)(configFile)) {
69
+ throw new Error(`There is no beta feature configured with the name "${betaFeature}"`);
70
+ }
63
71
  }
64
72
  try {
65
73
  return require(configFile);
@@ -68,42 +76,21 @@ function getListOfActors() {
68
76
  }
69
77
  }
70
78
  function getUserForSelectedEditionAndProfile(preferedEdition, preferredProfile, betaFeature, testDataPortal = null) {
71
- const actorsData = getListOfActors();
79
+ const actorsData = getListOfActors(betaFeature);
72
80
  if (!actorsData || !actorsData.editions) {
73
81
  throw new Error("The actors data is missing.");
74
82
  }
75
83
  const {
76
- editions: userdata,
77
- beta: betaPortals
84
+ editions: userdata
78
85
  } = actorsData;
79
86
  const defaultConf = getDefaultActorConf();
80
87
  const edition = preferedEdition || defaultConf.edition;
81
88
  const profile = preferredProfile || defaultConf.profile;
82
89
  let selectedProfile = {};
83
- if (betaFeature && betaFeature !== null) {
84
- if (!betaPortals.hasOwnProperty(betaFeature)) {
85
- throw new Error(`There is no "${betaFeature}" beta feature configured.`);
86
- }
87
- const betaEdition = betaPortals[betaFeature].find(portal => portal.edition === edition);
88
- if (!betaEdition) {
89
- throw new Error(`There is no "${edition}" edition configured in "${betaFeature}" beta feature.`);
90
- }
91
- const {
92
- profiles: betaProfiles,
93
- ...betaEditionData
94
- } = betaEdition;
95
- selectedProfile = betaProfiles.find(user => user.profile === profile);
96
- if (!selectedProfile) {
97
- throw new Error(`There is no "${profile}" configured in edition of "${edition}" in "${betaFeature}" beta features.`);
98
- }
99
- return {
100
- ...betaEditionData,
101
- ...selectedProfile
102
- };
103
- }
104
90
 
105
91
  // TODO: We are returning the first data from array. We need to check the possiblity of having multiple users for same profile and possibly round robin
106
92
  // For this we need to get the data from ci environment.
93
+
107
94
  let testingPortal = null;
108
95
  if (!userdata.hasOwnProperty(edition)) {
109
96
  throw new Error(`There is no "${edition}" edition configured.`);
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ class Runner {
4
+ constructor(config) {
5
+ this.tagArgs = "";
6
+ this.userArgs = "";
7
+ this.config = config;
8
+ }
9
+ setUserArgs(userArgs) {
10
+ this.userArgs = userArgs;
11
+ }
12
+ setTagArgs(tagArgs) {
13
+ this.tagArgs = tagArgs;
14
+ }
15
+ setConfig(config) {
16
+ this.config = config;
17
+ }
18
+ run() {
19
+ throw new Error("Method 'run()' must be implemented.");
20
+ }
21
+ }
22
+ module.exports = Runner;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _RunnerTypes = _interopRequireDefault(require("./RunnerTypes"));
9
+ var _configUtils = require("../setup/config-utils");
10
+ var _cliArgsToObject = require("../../../utils/cliArgsToObject");
11
+ var _browserTypes = require("../constants/browserTypes");
12
+ var _customCommands = require("../custom-commands");
13
+ class RunnerHelper {
14
+ static createRunner(type, runnerObj) {
15
+ const runnerClass = _RunnerTypes.default.getRunnerClass(type, runnerObj);
16
+ if (!runnerClass) {
17
+ throw new Error("Invalid runner type");
18
+ }
19
+ return runnerClass;
20
+ }
21
+ static getPlaywrightArgs(userArgsObject, debug, bddMode, tagArgs, headless) {
22
+ const {
23
+ browsers = null
24
+ } = userArgsObject;
25
+ let browserList = (0, _configUtils.getBrowsersList)(browsers);
26
+ const playwrightArgs = (0, _cliArgsToObject.objectToCliArgs)(userArgsObject, key => !_customCommands.CUSTOM_COMMANDS.includes(key));
27
+ if (debug) {
28
+ playwrightArgs.push('--debug');
29
+ }
30
+ if (!bddMode && tagArgs) {
31
+ playwrightArgs.push('--grep');
32
+ playwrightArgs.push(tagArgs);
33
+ }
34
+ if (!headless && !userArgsObject.headed) {
35
+ playwrightArgs.push('--headed');
36
+ }
37
+ if (browserList && browserList.length > 0) {
38
+ browserList.map(browser => playwrightArgs.push(`--project=${_browserTypes.BROWSER_PROJECT_MAPPING[browser.toUpperCase()]}`));
39
+ }
40
+ return playwrightArgs;
41
+ }
42
+ }
43
+ var _default = exports.default = RunnerHelper;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _SpawnRunner = _interopRequireDefault(require("./SpawnRunner"));
5
+ class RunnerTypes {
6
+ static getRunnerClass(type, runnerObj) {
7
+ const RunnerClass = this.runnerTypes[type];
8
+ if (!RunnerClass) {
9
+ throw new Error("Invalid runner type");
10
+ }
11
+ return new RunnerClass(runnerObj);
12
+ }
13
+ static runnerTypes = {
14
+ spawn: _SpawnRunner.default //require("./SpawnRunner"), // used lazy loading to reduce circular dependencies
15
+ };
16
+ }
17
+ module.exports = RunnerTypes;
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _readConfigFile = require("../readConfigFile");
5
+ var _rootPath = require("../../../utils/rootPath");
6
+ var _path = _interopRequireDefault(require("path"));
7
+ var _logger = require("../../../utils/logger");
8
+ var _child_process = require("child_process");
9
+ var _RunnerHelper = _interopRequireDefault(require("./RunnerHelper"));
10
+ var _Runner = _interopRequireDefault(require("./Runner"));
11
+ class SpawnRunner extends _Runner.default {
12
+ constructor(runnerObj) {
13
+ super(runnerObj);
14
+ this.runnerObj = runnerObj;
15
+ }
16
+ run() {
17
+ const {
18
+ config
19
+ } = this.runnerObj;
20
+ let promises = [];
21
+ const {
22
+ bddMode
23
+ } = config.getAll();
24
+ if (bddMode) {
25
+ promises.push(this.runPreprocessing());
26
+ }
27
+ Promise.all(promises).then(() => this.runPlaywright()).catch(err => {
28
+ _logger.Logger.error(err);
29
+ process.exit();
30
+ });
31
+ }
32
+ runPreprocessing() {
33
+ const {
34
+ tagArgs
35
+ } = this.runnerObj;
36
+ const configPath = (0, _readConfigFile.isUserConfigFileAvailable)() ? _path.default.resolve(__dirname, '../', 'setup', 'config-creator.js') : _path.default.resolve('../', '../', '../', '../', 'playwrightConfig.js');
37
+ const beforeCommand = 'node';
38
+ const bddGenPath = _path.default.resolve(__dirname, '../', '../', '../', 'bdd-framework', 'cli', 'index.js');
39
+ const beforeArgs = [bddGenPath, '-c', require.resolve(configPath)];
40
+ if (tagArgs) {
41
+ beforeArgs.push('--tags');
42
+ beforeArgs.push(tagArgs);
43
+ }
44
+ return new Promise((resolve, reject) => {
45
+ const childProcessForPreprocessing = (0, _child_process.spawn)(beforeCommand, beforeArgs, {
46
+ stdio: 'inherit',
47
+ env: {
48
+ ...process.env
49
+ }
50
+ });
51
+ childProcessForPreprocessing.on('error', data => {
52
+ _logger.Logger.log(_logger.Logger.FAILURE_TYPE, data);
53
+ reject(data);
54
+ });
55
+ childProcessForPreprocessing.on('exit', code => {
56
+ if (code === 0) {
57
+ _logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Feature Files Processed Successfully');
58
+ resolve();
59
+ } else {
60
+ reject(`BddGen exited with code ${code}`);
61
+ }
62
+ });
63
+ });
64
+ }
65
+ runPlaywright() {
66
+ const {
67
+ tagArgs,
68
+ config,
69
+ userArgs
70
+ } = this.runnerObj;
71
+ const {
72
+ debug,
73
+ bddMode = false,
74
+ headless = false
75
+ } = config.getAll();
76
+ const playwrightArgs = _RunnerHelper.default.getPlaywrightArgs(userArgs, debug, bddMode, tagArgs, headless);
77
+ const playwrightPath = _path.default.resolve((0, _rootPath.getExecutableBinaryPath)('playwright'));
78
+ const command = playwrightPath;
79
+ const configPath = (0, _readConfigFile.isUserConfigFileAvailable)() ? _path.default.resolve(__dirname, '../', 'setup', 'config-creator.js') : _path.default.resolve('../', '../', '../', '../', 'playwrightConfig.js');
80
+ const args = ['test', '--config', require.resolve(configPath)].concat(playwrightArgs);
81
+ return new Promise((resolve, reject) => {
82
+ const childProcessForRunningPlaywright = (0, _child_process.spawn)(command, args, {
83
+ stdio: 'inherit',
84
+ env: {
85
+ ...process.env
86
+ }
87
+ });
88
+ childProcessForRunningPlaywright.on('error', error => {
89
+ _logger.Logger.log(_logger.Logger.FAILURE_TYPE, error);
90
+ });
91
+ childProcessForRunningPlaywright.on('exit', (code, signal) => {
92
+ if (code !== 0) {
93
+ reject(`Child Process Exited with Code ${code} and Signal ${signal}`);
94
+ } else {
95
+ _logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Test Ran Successfully');
96
+ resolve();
97
+ }
98
+ });
99
+ process.on('exit', () => {
100
+ childProcessForRunningPlaywright.kill();
101
+ reject('Terminating Playwright Process...');
102
+ });
103
+ process.on('SIGINT', () => {
104
+ childProcessForRunningPlaywright.kill();
105
+ reject('Cleaning up...');
106
+ });
107
+ });
108
+ }
109
+ }
110
+ module.exports = SpawnRunner;
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+
3
+ var _logger = require("../../utils/logger");
4
+ function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
5
+ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
6
+ function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
7
+ var _buildTagsString = /*#__PURE__*/new WeakSet();
8
+ var _parseEdition = /*#__PURE__*/new WeakSet();
9
+ var _processSingleEdition = /*#__PURE__*/new WeakSet();
10
+ var _processMultipleEditions = /*#__PURE__*/new WeakSet();
11
+ var _getEditionArgs = /*#__PURE__*/new WeakSet();
12
+ var _buildEditionTags = /*#__PURE__*/new WeakSet();
13
+ class TagProcessor {
14
+ constructor(editionOrder) {
15
+ _classPrivateMethodInitSpec(this, _buildEditionTags);
16
+ _classPrivateMethodInitSpec(this, _getEditionArgs);
17
+ _classPrivateMethodInitSpec(this, _processMultipleEditions);
18
+ _classPrivateMethodInitSpec(this, _processSingleEdition);
19
+ _classPrivateMethodInitSpec(this, _parseEdition);
20
+ _classPrivateMethodInitSpec(this, _buildTagsString);
21
+ this.editionOrder = editionOrder;
22
+ }
23
+ processTags(userArgs) {
24
+ const tagArgs = userArgs['tags'] || '';
25
+ const edition = userArgs['edition'] || null;
26
+ if (!edition) return tagArgs;
27
+ const editionsArray = edition.split(',');
28
+ const editionTags = editionsArray.length === 1 ? _classPrivateMethodGet(this, _processSingleEdition, _processSingleEdition2).call(this, editionsArray[0], tagArgs) : _classPrivateMethodGet(this, _processMultipleEditions, _processMultipleEditions2).call(this, editionsArray, tagArgs);
29
+ return editionTags;
30
+ }
31
+ }
32
+ function _buildTagsString2(tags, editionTags) {
33
+ return tags && tags !== '' ? `${tags} and not (${editionTags})` : `not (${editionTags})`;
34
+ }
35
+ function _parseEdition2(edition) {
36
+ if (edition.startsWith('<=')) return ['<=', edition.slice(2)];
37
+ if (edition.startsWith('>=')) return ['>=', edition.slice(2)];
38
+ if (edition.startsWith('<')) return ['<', edition.slice(1)];
39
+ if (edition.startsWith('>')) return ['>', edition.slice(1)];
40
+ return [null, edition];
41
+ }
42
+ function _processSingleEdition2(selectedEdition, tagArgs) {
43
+ const editionArgs = _classPrivateMethodGet(this, _getEditionArgs, _getEditionArgs2).call(this, selectedEdition);
44
+ if (editionArgs && editionArgs.length > 0) {
45
+ const editionTags = _classPrivateMethodGet(this, _buildEditionTags, _buildEditionTags2).call(this, editionArgs, 'or');
46
+ return _classPrivateMethodGet(this, _buildTagsString, _buildTagsString2).call(this, tagArgs, editionTags);
47
+ }
48
+ _logger.Logger.log(_logger.Logger.INFO_TYPE, `No matching editions for ${selectedEdition} found. Running with default edition`);
49
+ return tagArgs;
50
+ }
51
+ function _processMultipleEditions2(editionsArray, tagArgs) {
52
+ const filteredEditions = this.editionOrder.filter(edition => !editionsArray.includes(edition));
53
+ const editionTags = _classPrivateMethodGet(this, _buildEditionTags, _buildEditionTags2).call(this, filteredEditions, 'or');
54
+ return _classPrivateMethodGet(this, _buildTagsString, _buildTagsString2).call(this, tagArgs, editionTags);
55
+ }
56
+ function _getEditionArgs2(selectedEdition) {
57
+ const [operator, editionValue] = _classPrivateMethodGet(this, _parseEdition, _parseEdition2).call(this, selectedEdition.toLowerCase());
58
+ const index = this.editionOrder.findIndex(edition => edition.toLowerCase() === editionValue);
59
+ if (index === -1) {
60
+ _logger.Logger.log(_logger.Logger.INFO_TYPE, `No matching editions for ${selectedEdition} found. Running with default edition`);
61
+ return [];
62
+ }
63
+ switch (operator) {
64
+ case '<=':
65
+ return this.editionOrder.slice(index + 1);
66
+ case '>=':
67
+ return this.editionOrder.slice(0, index);
68
+ case '<':
69
+ return this.editionOrder.slice(index);
70
+ case '>':
71
+ return this.editionOrder.slice(0, index + 1);
72
+ default:
73
+ return this.editionOrder.filter((_, i) => i !== index);
74
+ }
75
+ }
76
+ function _buildEditionTags2(editionArgs, operator = 'or') {
77
+ return editionArgs.map(edition => `@edition_${edition}`).join(` ${operator} `);
78
+ }
79
+ module.exports = TagProcessor;
@@ -14,33 +14,14 @@ var _envInitializer = require("./env-initializer");
14
14
  var _logger = require("../../utils/logger");
15
15
  var _readConfigFile = require("./readConfigFile");
16
16
  var _rootPath = require("../../utils/rootPath");
17
- var _tagProcessor = require("./tag-processor");
17
+ var _tagProcessor = _interopRequireDefault(require("./tagProcessor"));
18
18
  var _configUtils = require("./setup/config-utils");
19
19
  var _browserTypes = require("./constants/browserTypes");
20
20
  var _ConfigurationHelper = require("./configuration/ConfigurationHelper");
21
21
  var _Configuration = _interopRequireDefault(require("./configuration/Configuration"));
22
22
  var _UserArgs = _interopRequireDefault(require("./configuration/UserArgs"));
23
- function getPlaywrightArgs(userArgsObject, debug, bddMode, tagArgs, headless) {
24
- const {
25
- browsers = null
26
- } = userArgsObject;
27
- let browserList = (0, _configUtils.getBrowsersList)(browsers);
28
- const playwrightArgs = (0, _cliArgsToObject.objectToCliArgs)(userArgsObject, key => !_customCommands.CUSTOM_COMMANDS.includes(key));
29
- if (debug) {
30
- playwrightArgs.push('--debug');
31
- }
32
- if (!bddMode && tagArgs) {
33
- playwrightArgs.push('--grep');
34
- playwrightArgs.push(tagArgs);
35
- }
36
- if (!headless && !userArgsObject.headed) {
37
- playwrightArgs.push('--headed');
38
- }
39
- if (browserList && browserList.length > 0) {
40
- browserList.map(browser => playwrightArgs.push(`--project=${_browserTypes.BROWSER_PROJECT_MAPPING[browser.toUpperCase()]}`));
41
- }
42
- return playwrightArgs;
43
- }
23
+ var _RunnerHelper = _interopRequireDefault(require("./runner/RunnerHelper"));
24
+ var _Runner = _interopRequireDefault(require("./runner/Runner"));
44
25
  function runPreprocessing(tagArgs, configPath) {
45
26
  const beforeCommand = 'node';
46
27
  const bddGenPath = _path.default.resolve((0, _rootPath.getExecutableBinaryPath)('bddgen'));
@@ -122,19 +103,13 @@ function main() {
122
103
 
123
104
  //This is only used for pass the user arguments to need places in legacy code. We need to rewamp that also.
124
105
  const userArgsObject = userArgConfig.getAll();
125
- const tagArgs = (0, _tagProcessor.tagProcessor)(userArgsObject, editionOrder);
126
- const playwrightArgs = getPlaywrightArgs(userArgsObject, debug, bddMode, tagArgs, headless);
127
- const playwrightPath = _path.default.resolve((0, _rootPath.getExecutableBinaryPath)('playwright'));
128
- const command = playwrightPath;
129
- const configPath = (0, _readConfigFile.isUserConfigFileAvailable)() ? require.resolve('./setup/config-creator.js') : require.resolve('../../../playwright.config.js');
130
- const args = ['test', '--config', configPath].concat(playwrightArgs);
131
- let promises = [];
132
- if (bddMode) {
133
- promises.push(runPreprocessing(tagArgs, configPath));
134
- }
135
- Promise.all(promises).then(() => runPlaywright(command, args)).catch(err => {
136
- _logger.Logger.error(err);
137
- process.exit();
138
- });
106
+ const tagProcessor = new _tagProcessor.default(editionOrder);
107
+ const tagArgs = tagProcessor.processTags(userArgsObject);
108
+ const runnerObj = new _Runner.default();
109
+ runnerObj.setTagArgs(tagArgs);
110
+ runnerObj.setUserArgs(userArgsObject);
111
+ runnerObj.setConfig(uatConfig);
112
+ const runner = _RunnerHelper.default.createRunner('spawn', runnerObj);
113
+ runner.run();
139
114
  }
140
115
  var _default = exports.default = main;
@@ -7,40 +7,9 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = void 0;
8
8
  var _parseUserArgs = _interopRequireDefault(require("./helpers/parseUserArgs"));
9
9
  var _readConfigFile = require("./readConfigFile");
10
- var _tagProcessor = require("./tag-processor");
10
+ var _tagProcessor = _interopRequireDefault(require("./tagProcessor"));
11
11
  var _testRunner = require("./test-runner");
12
12
  var _logger = require("../../utils/logger");
13
- // @cucumber/gherkins need to be includ in package.json
14
-
15
- // const getFeatureFiles = (dir) => {
16
- // let featureFiles = [];
17
- // const files = fs.readdirSync(dir, { withFileTypes: true });
18
- // files.forEach(file => {
19
- // const fullPath = path.join(dir, file.name);
20
- // if (file.isDirectory()) {
21
- // featureFiles = featureFiles.concat(getFeatureFiles(fullPath));
22
- // } else if (file.isFile() && fullPath.endsWith('.feature')) {
23
- // featureFiles.push(fullPath);
24
- // }
25
- // });
26
- // return featureFiles;
27
- // };
28
-
29
- //const validateFeatureFiles = () => {
30
- // const featuresDir = path.join(process.cwd(), 'uat/modules');
31
- // const parser = new Parser();
32
- // const featureFiles = getFeatureFiles(featuresDir);
33
- // featureFiles.forEach( filePath => {
34
- // const featureFileContent = fs.readFileSync(filePath, 'utf-8');
35
- // try {
36
- // parser.parse(featureFileContent);
37
- // console.log(`${filePath}: Feature file is valid!`);
38
- // } catch (error) {
39
- // console.error(`${filePath}: Feature file is invalid - ${error.message}`);
40
- // }
41
- // })
42
- //}
43
-
44
13
  const validateFeatureFiles = () => {
45
14
  const userArgsObject = (0, _parseUserArgs.default)();
46
15
  const uatConfig = (0, _readConfigFile.generateConfigFromFile)();
@@ -48,7 +17,8 @@ const validateFeatureFiles = () => {
48
17
  editionOrder
49
18
  } = uatConfig;
50
19
  const configPath = (0, _readConfigFile.isUserConfigFileAvailable)() ? require.resolve('./setup/config-creator.js') : require.resolve('../../../playwright.config.js');
51
- const tagArgs = (0, _tagProcessor.tagProcessor)(userArgsObject, editionOrder);
20
+ const tagProcessor = new _tagProcessor.default(editionOrder);
21
+ const tagArgs = tagProcessor.processTags(userArgsObject);
52
22
  (0, _testRunner.runPreprocessing)(tagArgs, configPath).then(() => {
53
23
  _logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Feature files validated successfully.');
54
24
  }).catch(error => {
@@ -1,3 +1,2 @@
1
1
  const editions = require('./editions/index');
2
-
3
2
  module.exports = { editions }
@@ -2,6 +2,6 @@
2
2
  "environment": "dev",
3
3
  "edition": "enterprise",
4
4
  "profile": "admin",
5
- "domain": "https://desk.localzoho.com/agent",
5
+ "domain": "https://zdesk-devops16.csez.zohocorpin.com:31025/agent",
6
6
  "devUrl" : ""
7
7
  }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _Runner = _interopRequireDefault(require("../core/playwright/runner/Runner"));
5
+ delete require.cache[require.resolve('../core/playwright/runner/Runner')];
6
+ function test() {
7
+ console.log("inside runner");
8
+ const runner = _Runner.default.createRunner('spawn');
9
+ runner.run(tagArgs);
10
+ }
11
+ test();