@zohodesk/testinglibrary 0.4.5-experimental → 0.4.7-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 (128) hide show
  1. package/.gitlab-ci.yml +7 -7
  2. package/README.md +25 -4
  3. package/build/core/playwright/fixtures.js +24 -0
  4. package/build/core/playwright/helpers/auth/getUsers.js +25 -12
  5. package/build/core/playwright/index.js +10 -23
  6. package/build/core/playwright/setup/config-creator.js +3 -3
  7. package/build/core/playwright/setup/config-utils.js +8 -25
  8. package/build/core/playwright/tagProcessor.js +79 -0
  9. package/build/core/playwright/test-runner.js +4 -3
  10. package/build/core/playwright/validateFeature.js +3 -33
  11. package/build/decorators.d.ts +1 -1
  12. package/build/decorators.js +1 -1
  13. package/build/setup-folder-structure/samples/actors-index.js +3 -0
  14. package/build/setup-folder-structure/samples/auth-setup-sample.js +14 -66
  15. package/build/setup-folder-structure/samples/editions-index.js +3 -0
  16. package/build/setup-folder-structure/samples/free-sample.json +25 -0
  17. package/build/setup-folder-structure/samples/settings.json +7 -0
  18. package/build/setup-folder-structure/setupProject.js +18 -5
  19. package/build/test/core/playwright/__tests__/tagProcessor.test.js +94 -0
  20. package/build/test/core/playwright/__tests__/validateFeature.test.js +10 -5
  21. package/npm-shrinkwrap.json +5795 -2145
  22. package/package.json +7 -7
  23. package/build/bdd-framework/cli/commands/env.js +0 -42
  24. package/build/bdd-framework/cli/commands/export.js +0 -62
  25. package/build/bdd-framework/cli/commands/test.js +0 -64
  26. package/build/bdd-framework/cli/index.js +0 -11
  27. package/build/bdd-framework/cli/options.js +0 -19
  28. package/build/bdd-framework/cli/worker.js +0 -13
  29. package/build/bdd-framework/config/configDir.js +0 -35
  30. package/build/bdd-framework/config/enrichReporterData.js +0 -23
  31. package/build/bdd-framework/config/env.js +0 -50
  32. package/build/bdd-framework/config/index.js +0 -94
  33. package/build/bdd-framework/config/lang.js +0 -14
  34. package/build/bdd-framework/cucumber/buildStepDefinition.js +0 -43
  35. package/build/bdd-framework/cucumber/createTestStep.js +0 -43
  36. package/build/bdd-framework/cucumber/formatter/EventDataCollector.js +0 -126
  37. package/build/bdd-framework/cucumber/formatter/GherkinDocumentParser.js +0 -72
  38. package/build/bdd-framework/cucumber/formatter/PickleParser.js +0 -25
  39. package/build/bdd-framework/cucumber/formatter/durationHelpers.js +0 -13
  40. package/build/bdd-framework/cucumber/formatter/getColorFns.js +0 -57
  41. package/build/bdd-framework/cucumber/formatter/index.js +0 -16
  42. package/build/bdd-framework/cucumber/formatter/locationHelpers.js +0 -16
  43. package/build/bdd-framework/cucumber/loadConfig.js +0 -17
  44. package/build/bdd-framework/cucumber/loadFeatures.js +0 -70
  45. package/build/bdd-framework/cucumber/loadSnippetBuilder.js +0 -20
  46. package/build/bdd-framework/cucumber/loadSteps.js +0 -47
  47. package/build/bdd-framework/cucumber/resolveFeaturePaths.js +0 -62
  48. package/build/bdd-framework/cucumber/stepArguments.js +0 -21
  49. package/build/bdd-framework/cucumber/types.js +0 -5
  50. package/build/bdd-framework/cucumber/valueChecker.js +0 -23
  51. package/build/bdd-framework/decorators.js +0 -18
  52. package/build/bdd-framework/gen/fixtures.js +0 -48
  53. package/build/bdd-framework/gen/formatter.js +0 -167
  54. package/build/bdd-framework/gen/i18n.js +0 -39
  55. package/build/bdd-framework/gen/index.js +0 -197
  56. package/build/bdd-framework/gen/specialTags.js +0 -70
  57. package/build/bdd-framework/gen/testFile.js +0 -470
  58. package/build/bdd-framework/gen/testMeta.js +0 -60
  59. package/build/bdd-framework/gen/testNode.js +0 -35
  60. package/build/bdd-framework/gen/testPoms.js +0 -133
  61. package/build/bdd-framework/hooks/scenario.js +0 -130
  62. package/build/bdd-framework/hooks/worker.js +0 -89
  63. package/build/bdd-framework/index.js +0 -52
  64. package/build/bdd-framework/playwright/fixtureParameterNames.js +0 -93
  65. package/build/bdd-framework/playwright/getLocationInFile.js +0 -79
  66. package/build/bdd-framework/playwright/loadConfig.js +0 -42
  67. package/build/bdd-framework/playwright/loadUtils.js +0 -33
  68. package/build/bdd-framework/playwright/testTypeImpl.js +0 -79
  69. package/build/bdd-framework/playwright/transform.js +0 -88
  70. package/build/bdd-framework/playwright/types.js +0 -12
  71. package/build/bdd-framework/playwright/utils.js +0 -56
  72. package/build/bdd-framework/reporter/cucumber/base.js +0 -52
  73. package/build/bdd-framework/reporter/cucumber/custom.js +0 -73
  74. package/build/bdd-framework/reporter/cucumber/helper.js +0 -12
  75. package/build/bdd-framework/reporter/cucumber/html.js +0 -40
  76. package/build/bdd-framework/reporter/cucumber/index.js +0 -74
  77. package/build/bdd-framework/reporter/cucumber/json.js +0 -312
  78. package/build/bdd-framework/reporter/cucumber/junit.js +0 -205
  79. package/build/bdd-framework/reporter/cucumber/message.js +0 -20
  80. package/build/bdd-framework/reporter/cucumber/messagesBuilder/AttachmentMapper.js +0 -82
  81. package/build/bdd-framework/reporter/cucumber/messagesBuilder/Builder.js +0 -197
  82. package/build/bdd-framework/reporter/cucumber/messagesBuilder/GherkinDocument.js +0 -43
  83. package/build/bdd-framework/reporter/cucumber/messagesBuilder/GherkinDocumentClone.js +0 -52
  84. package/build/bdd-framework/reporter/cucumber/messagesBuilder/GherkinDocuments.js +0 -105
  85. package/build/bdd-framework/reporter/cucumber/messagesBuilder/Hook.js +0 -70
  86. package/build/bdd-framework/reporter/cucumber/messagesBuilder/Meta.js +0 -45
  87. package/build/bdd-framework/reporter/cucumber/messagesBuilder/Pickles.js +0 -27
  88. package/build/bdd-framework/reporter/cucumber/messagesBuilder/Projects.js +0 -38
  89. package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestCase.js +0 -128
  90. package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestCaseRun.js +0 -154
  91. package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestCaseRunHooks.js +0 -123
  92. package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestStepAttachments.js +0 -67
  93. package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestStepRun.js +0 -114
  94. package/build/bdd-framework/reporter/cucumber/messagesBuilder/index.js +0 -30
  95. package/build/bdd-framework/reporter/cucumber/messagesBuilder/pwStepUtils.js +0 -70
  96. package/build/bdd-framework/reporter/cucumber/messagesBuilder/timing.js +0 -35
  97. package/build/bdd-framework/reporter/cucumber/messagesBuilder/types.js +0 -5
  98. package/build/bdd-framework/run/StepInvoker.js +0 -69
  99. package/build/bdd-framework/run/bddData/index.js +0 -59
  100. package/build/bdd-framework/run/bddData/types.js +0 -5
  101. package/build/bdd-framework/run/bddFixtures.js +0 -192
  102. package/build/bdd-framework/run/bddWorld.js +0 -79
  103. package/build/bdd-framework/run/bddWorldInternal.js +0 -11
  104. package/build/bdd-framework/snippets/index.js +0 -132
  105. package/build/bdd-framework/snippets/snippetSyntax.js +0 -43
  106. package/build/bdd-framework/snippets/snippetSyntaxDecorators.js +0 -26
  107. package/build/bdd-framework/snippets/snippetSyntaxTs.js +0 -18
  108. package/build/bdd-framework/stepDefinitions/createBdd.js +0 -66
  109. package/build/bdd-framework/stepDefinitions/decorators/class.js +0 -68
  110. package/build/bdd-framework/stepDefinitions/decorators/steps.js +0 -99
  111. package/build/bdd-framework/stepDefinitions/defineStep.js +0 -62
  112. package/build/bdd-framework/stepDefinitions/stepConfig.js +0 -24
  113. package/build/bdd-framework/steps/createBdd.js +0 -78
  114. package/build/bdd-framework/steps/decorators/class.js +0 -68
  115. package/build/bdd-framework/steps/decorators/steps.js +0 -98
  116. package/build/bdd-framework/steps/defineStep.js +0 -62
  117. package/build/bdd-framework/steps/stepConfig.js +0 -24
  118. package/build/bdd-framework/utils/AutofillMap.js +0 -20
  119. package/build/bdd-framework/utils/exit.js +0 -62
  120. package/build/bdd-framework/utils/index.js +0 -93
  121. package/build/bdd-framework/utils/jsStringWrap.js +0 -44
  122. package/build/bdd-framework/utils/logger.js +0 -30
  123. package/build/bdd-framework/utils/stripAnsiEscapes.js +0 -20
  124. package/build/core/playwright/tag-processor.js +0 -68
  125. package/build/setup-folder-structure/samples/authUsers-sample.json +0 -9
  126. package/build/setup-folder-structure/samples/env-config-sample.json +0 -21
  127. package/build/test/core/playwright/helpers/__tests__/getUsers_ListOfActors.test.js +0 -80
  128. package/nobdd/src/App.js +0 -7
package/.gitlab-ci.yml CHANGED
@@ -1,4 +1,4 @@
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
3
  #workflow:
4
4
  # rules:
@@ -12,7 +12,7 @@ stages:
12
12
  # Install dependencies stage
13
13
  build:
14
14
  stage: build
15
- image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v2
15
+ image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v3
16
16
  script:
17
17
  - npm install
18
18
  artifacts:
@@ -23,7 +23,7 @@ build:
23
23
  # Unit tests stage
24
24
  unit:
25
25
  stage: unit
26
- image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v2
26
+ image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v3
27
27
  script:
28
28
  - npm run test
29
29
  artifacts:
@@ -34,7 +34,7 @@ unit:
34
34
  # UAT tests stage
35
35
  uat-auth:
36
36
  stage: uat
37
- image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v2
37
+ image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v3
38
38
  script:
39
39
  - npm install
40
40
  - npm run build
@@ -53,7 +53,7 @@ uat-auth:
53
53
 
54
54
  uat-noauth:
55
55
  stage: uat
56
- image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v2
56
+ image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v3
57
57
  script:
58
58
  - npm install
59
59
  - npm run build
@@ -72,7 +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
75
+ image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v3
76
76
  script:
77
77
  - npm install
78
78
  - npm run build
@@ -91,7 +91,7 @@ uat-profile:
91
91
 
92
92
  uat-nobdd:
93
93
  stage: uat
94
- image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v2
94
+ image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v3
95
95
  script:
96
96
  - npm install
97
97
  - npm run build
package/README.md CHANGED
@@ -26,15 +26,36 @@
26
26
  ### Bug fix
27
27
  - Updated the custom-reported to include the errors in tests during the executions. It will help us avoid the stage passed without the actual test execution.
28
28
 
29
- ### v0.2.9 - 24-10-2024
29
+
30
+ ## Version History
31
+
32
+ ### v0.2.9 - 25-10-2024
30
33
 
31
34
  #### Feature
32
35
  - Added support for scenario level tag support
33
36
  - Added a new cli optin like uat-validate to validate the feature files using playwright-bdd
34
37
  - Mode based configuration implementations
35
38
  - @only option enabled in dev pipeline
39
+ - Latest setup related configuration changed for init option
36
40
 
37
- ### v0.3.0 - 06-11-2024
41
+ ### v0.3.0 - 25-10-2024
38
42
 
39
- #### Enhancement
40
- - Beta feature Actors and edition configurations unified
43
+ #### Features
44
+ - Added support for scenario level tag support
45
+ - Updated the configuration for `video` and `trace` to accept Playwright-specific values instead of boolean values.
46
+ - Below package versions are updated in this release.
47
+ - playwright - 1.48.0,
48
+ - playwright-bdd - 7.5.0,
49
+ - @playwright/test - 1.48.0,
50
+ - @cucumber/cucumber - 11.0.1
51
+ - From this version, We adopt the playwright-bdd as library instead of modified source
52
+ - Published on 11-11-2024
53
+
54
+ #### Deprecations
55
+ - **Deprecated**: Passing `video` and `trace` as boolean (`true`/`false`) in project configuration.
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.
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _test = require("@playwright/test");
5
+ var _playwrightBdd = require("playwright-bdd");
6
+ var _readConfigFile = require("./readConfigFile");
7
+ var _builtInFixtures = _interopRequireDefault(require("./builtInFixtures"));
8
+ var _getUserFixtures = _interopRequireDefault(require("./helpers/getUserFixtures"));
9
+ const {
10
+ bddMode
11
+ } = (0, _readConfigFile.generateConfigFromFile)();
12
+ let base = bddMode ? _playwrightBdd.test : _test.test;
13
+ const buildInFixtures = (0, _builtInFixtures.default)(bddMode);
14
+ const buildInFixturesTest = base.extend({
15
+ ...buildInFixtures
16
+ });
17
+ const userFixtures = (0, _getUserFixtures.default)();
18
+ const userFixturesTest = base.extend({
19
+ ...userFixtures
20
+ });
21
+ const test = (0, _test.mergeTests)(buildInFixturesTest, userFixturesTest);
22
+ module.exports = {
23
+ test
24
+ };
@@ -52,22 +52,14 @@ function getDefaultActor() {
52
52
  } = getDefaultActorConf();
53
53
  return getUserForSelectedEditionAndProfile(edition, profile);
54
54
  }
55
- function getListOfActors(betaFeature) {
55
+ function getListOfActors() {
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;
62
61
  if (!(0, _fs.existsSync)(configFile)) {
63
62
  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
- }
71
63
  }
72
64
  try {
73
65
  return require(configFile);
@@ -76,21 +68,42 @@ function getListOfActors(betaFeature) {
76
68
  }
77
69
  }
78
70
  function getUserForSelectedEditionAndProfile(preferedEdition, preferredProfile, betaFeature, testDataPortal = null) {
79
- const actorsData = getListOfActors(betaFeature);
71
+ const actorsData = getListOfActors();
80
72
  if (!actorsData || !actorsData.editions) {
81
73
  throw new Error("The actors data is missing.");
82
74
  }
83
75
  const {
84
- editions: userdata
76
+ editions: userdata,
77
+ beta: betaPortals
85
78
  } = actorsData;
86
79
  const defaultConf = getDefaultActorConf();
87
80
  const edition = preferedEdition || defaultConf.edition;
88
81
  const profile = preferredProfile || defaultConf.profile;
89
82
  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
+ }
90
104
 
91
105
  // 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
92
106
  // For this we need to get the data from ci environment.
93
-
94
107
  let testingPortal = null;
95
108
  if (!userdata.hasOwnProperty(edition)) {
96
109
  throw new Error(`There is no "${edition}" edition configured.`);
@@ -1,37 +1,24 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
- Object.defineProperty(exports, "createBdd", {
6
+ exports.createBdd = void 0;
7
+ Object.defineProperty(exports, "expect", {
8
8
  enumerable: true,
9
9
  get: function () {
10
- return _bddFramework.createBdd;
10
+ return _test.expect;
11
11
  }
12
12
  });
13
- Object.defineProperty(exports, "expect", {
13
+ Object.defineProperty(exports, "test", {
14
14
  enumerable: true,
15
15
  get: function () {
16
- return _test.expect;
16
+ return _playwrightBdd.test;
17
17
  }
18
18
  });
19
- exports.test = void 0;
20
- var _bddFramework = require("../../bdd-framework");
19
+ var _playwrightBdd = require("playwright-bdd");
21
20
  var _test = require("@playwright/test");
22
- var _readConfigFile = require("./readConfigFile");
23
- var _builtInFixtures = _interopRequireDefault(require("./builtInFixtures"));
24
- var _getUserFixtures = _interopRequireDefault(require("./helpers/getUserFixtures"));
25
- const {
26
- bddMode
27
- } = (0, _readConfigFile.generateConfigFromFile)();
28
- let base = bddMode ? _bddFramework.test : _test.test;
29
- const buildInFixtures = (0, _builtInFixtures.default)(bddMode);
30
- const buildInFixturesTest = base.extend({
31
- ...buildInFixtures
32
- });
33
- const userFixtures = (0, _getUserFixtures.default)();
34
- const userFixturesTest = base.extend({
35
- ...userFixtures
36
- });
37
- const test = exports.test = (0, _test.mergeTests)(buildInFixturesTest, userFixturesTest);
21
+ let createBdd = function () {
22
+ return (0, _playwrightBdd.createBdd)(_playwrightBdd.test);
23
+ };
24
+ exports.createBdd = createBdd;
@@ -39,12 +39,12 @@ const testDir = (0, _configUtils.getTestDir)(bddMode, process.cwd(), {
39
39
  featureFilesFolder,
40
40
  stepDefinitionsFolder
41
41
  });
42
- const testOptions = (0, _configUtils.getTestUseOptions)({
42
+ const use = {
43
43
  trace,
44
44
  video,
45
45
  viewport,
46
46
  testIdAttribute
47
- });
47
+ };
48
48
 
49
49
  /**
50
50
  * Playwright configuration object
@@ -65,7 +65,7 @@ function getPlaywrightConfig() {
65
65
  expect: {
66
66
  timeout: expectTimeout
67
67
  },
68
- use: testOptions,
68
+ use,
69
69
  projects: isAuthMode ? [{
70
70
  name: 'setup',
71
71
  testMatch: /.*\.setup\.js/,
@@ -7,14 +7,12 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.getBrowsersList = getBrowsersList;
8
8
  exports.getProjects = getProjects;
9
9
  exports.getTestDir = getTestDir;
10
- exports.getTestUseOptions = getTestUseOptions;
11
10
  var _test = require("@playwright/test");
12
11
  var _path = _interopRequireDefault(require("path"));
13
12
  var _readConfigFile = require("../readConfigFile");
14
- var _bddFramework = require("../../../bdd-framework");
13
+ var _playwrightBdd = require("playwright-bdd");
15
14
  var _logger = require("../../../utils/logger");
16
15
  var _browserTypes = require("../constants/browserTypes");
17
- var _configFileNameProvider = require("../helpers/configFileNameProvider");
18
16
  var _fileUtils = require("../../../utils/fileUtils");
19
17
  /**
20
18
  ** Playwright project configuration
@@ -148,30 +146,15 @@ function getPathsForFeatureFiles(cwd) {
148
146
  function getTestDir(bddMode, cwd, {
149
147
  stepDefinitionsFolder
150
148
  }) {
151
- return bddMode ? (0, _bddFramework.defineBddConfig)({
152
- paths: getPathsForFeatureFiles(cwd),
153
- import: [_path.default.join(cwd, 'uat', '**', stepDefinitionsFolder, '*.spec.js')],
149
+ return bddMode ? (0, _playwrightBdd.defineBddConfig)({
150
+ features: getPathsForFeatureFiles(cwd),
151
+ steps: [_path.default.join(cwd, 'uat', '**', stepDefinitionsFolder, '*.spec.js'), require.resolve('../fixtures.js')],
152
+ importTestFrom: require.resolve('../fixtures.js'),
154
153
  featuresRoot: _path.default.join(cwd, 'uat'),
155
154
  outputDir: _path.default.join(cwd, 'uat', '.features-gen'),
155
+ disableWarnings: {
156
+ importTestFrom: true
157
+ },
156
158
  publish: true
157
159
  }) : _path.default.join(cwd, 'uat');
158
- }
159
- function getTestUseOptions({
160
- viewport,
161
- trace,
162
- video,
163
- testIdAttribute
164
- }) {
165
- let defaultTestuseOptions = {
166
- viewport,
167
- testIdAttribute,
168
- trace: trace ? 'on' : 'off',
169
- video: video ? {
170
- mode: 'on',
171
- size: {
172
- ...viewport
173
- }
174
- } : 'off'
175
- };
176
- return defaultTestuseOptions;
177
160
  }
@@ -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,7 +14,7 @@ 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");
@@ -43,7 +43,7 @@ function getPlaywrightArgs(userArgsObject, debug, bddMode, tagArgs, headless) {
43
43
  }
44
44
  function runPreprocessing(tagArgs, configPath) {
45
45
  const beforeCommand = 'node';
46
- const bddGenPath = _path.default.resolve(__dirname, '../', '../', 'bdd-framework', 'cli', 'index.js');
46
+ const bddGenPath = _path.default.resolve((0, _rootPath.getExecutableBinaryPath)('bddgen'));
47
47
  const beforeArgs = [bddGenPath, '-c', configPath];
48
48
  if (tagArgs) {
49
49
  beforeArgs.push('--tags');
@@ -122,7 +122,8 @@ function main() {
122
122
 
123
123
  //This is only used for pass the user arguments to need places in legacy code. We need to rewamp that also.
124
124
  const userArgsObject = userArgConfig.getAll();
125
- const tagArgs = (0, _tagProcessor.tagProcessor)(userArgsObject, editionOrder);
125
+ const tagProcessor = new _tagProcessor.default(editionOrder);
126
+ const tagArgs = tagProcessor.processTags(userArgsObject);
126
127
  const playwrightArgs = getPlaywrightArgs(userArgsObject, debug, bddMode, tagArgs, headless);
127
128
  const playwrightPath = _path.default.resolve((0, _rootPath.getExecutableBinaryPath)('playwright'));
128
129
  const command = playwrightPath;
@@ -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 +1 @@
1
- export * from './bdd-framework/decorators';
1
+ export * from 'playwright-bdd/decorators';
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- var _decorators = require("./bdd-framework/decorators");
6
+ var _decorators = require("playwright-bdd/decorators");
7
7
  Object.keys(_decorators).forEach(function (key) {
8
8
  if (key === "default" || key === "__esModule") return;
9
9
  if (key in exports && exports[key] === _decorators[key]) return;
@@ -0,0 +1,3 @@
1
+ const editions = require('./editions/index');
2
+
3
+ module.exports = { editions }
@@ -1,73 +1,21 @@
1
1
  /* eslint-disable no-console */
2
2
  import { test as setup, expect } from '@zohodesk/testinglibrary';
3
- import path from 'path';
4
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
5
- import { getAuthFileDirectory } from '../../core/playwright';
6
- import { Logger } from '../../utils/logger';
3
+ import {
4
+ performLoginSteps,
5
+ getDefaultActor
6
+ } from '@zohodesk/testinglibrary/helpers';
7
7
 
8
- const userdata = require('./authUsers.json');
8
+ const user = getDefaultActor();
9
9
 
10
- const authContent = { cookies: [] };
11
-
12
- const LOGIN_ERR_MESSAGE = 'Need go be logged in';
13
- // const AUTH_ERR_MESSAGE = `Founded Path - ${path.resolve(process.cwd(),'uat','playwright','.auth')} \n Find if file is Properly Created. Cookies Cannot Be Read .. `
14
-
15
- function convertCookiesToParse(cookies, authFilePath) {
16
- try {
17
- return JSON.parse(cookies);
18
- } catch (err) {
19
- Logger.error(err);
20
- throw new Error(
21
- ` Error while parsing cookies ${err} \n${path.resolve(
22
- process.cwd(),
23
- authFilePath
24
- )} File is Empty`
25
- );
26
- // process.exit()
27
- }
28
- }
29
- const authDirectory = getAuthFileDirectory(); //path.resolve(process.cwd(), 'uat', 'playwright', '.auth');
30
- if (!existsSync(authDirectory)) {
31
- console.log('Creating auth directory for the first time setup...');
32
- mkdirSync(authDirectory, { recursive: true });
10
+ async function verifyPageIsLoaded(page) {
11
+ //Implement your validation steps here
12
+ //Refer desk_client_app auth.setup.js
13
+ return true;
33
14
  }
34
15
 
35
- userdata.forEach(data => {
36
- const authFile = path.resolve(path.join(authDirectory, `${data.filename}`));
37
- if (!existsSync(authFile)) {
38
- console.log('creating auth file..');
39
- writeFileSync(authFile, JSON.stringify(authContent, null, 2));
40
- }
41
- setup(data.description, async ({ page }) => {
42
- try {
43
- const cookies = readFileSync(authFile);
44
- const parsedCookies = convertCookiesToParse(cookies, authFile);
45
- await page
46
- .context()
47
- .addCookies(
48
- parsedCookies.cookies === undefined ? [] : parsedCookies.cookies
49
- );
50
- await page.goto(page.getBaseUrl());
51
- await page.waitForLoadState();
52
- if (await page.url().includes(process.env.domain)) {
53
- await page.waitForSelector(data.locator);
54
- } else {
55
- throw new Error(LOGIN_ERR_MESSAGE);
56
- }
57
- } catch (err) {
58
- if (err.message === LOGIN_ERR_MESSAGE) {
59
- await expect(page.locator('.load-bg')).toBeHidden();
60
- await page.locator('#login_id').type(data.useremail);
61
- await page.locator('#nextbtn').click();
62
- await page.locator('#password').type(data.password);
63
- await page.locator('#nextbtn').click();
64
-
65
- await page.waitForLoadState('networkidle');
66
-
67
- await page.waitForSelector(data.locator);
16
+ setup(`${user.edition} - Authentication`, async ({ page }) => {
68
17
 
69
- await page.context().storageState({ path: authFile });
70
- }
71
- }
72
- });
73
- });
18
+ //Implement performLoginSteps here
19
+ const { email, password } = user;
20
+ await performLoginSteps({ },verifyPageIsLoaded );
21
+ });
@@ -0,0 +1,3 @@
1
+ const free = require('./free.json');
2
+ const editions = { free};
3
+ module.exports = editions;
@@ -0,0 +1,25 @@
1
+ [
2
+ {
3
+ "id": "1",
4
+ "edition": "free",
5
+ "orgName": "orgFree",
6
+ "profiles": [
7
+ {
8
+ "profile": "admin",
9
+ "email": "admin+free@zohotest.com",
10
+ "password": "password@0987"
11
+ },
12
+ {
13
+ "profile": "agent",
14
+ "email": "agent@zohotest.com",
15
+ "password": "password@12345"
16
+ },
17
+ {
18
+ "profile": "lightagent",
19
+ "email": "lightagent@zohotest.com",
20
+ "password": "password@12345"
21
+ }
22
+ ]
23
+ }
24
+ ]
25
+
@@ -0,0 +1,7 @@
1
+ {
2
+ "environment": "dev",
3
+ "edition": "enterprise",
4
+ "profile": "admin",
5
+ "domain": "https://desk.localzoho.com/agent",
6
+ "devUrl" : ""
7
+ }