@zohodesk/testinglibrary 0.0.5 → 0.0.6-n20-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 (136) hide show
  1. package/.babelrc +24 -0
  2. package/.eslintrc.js +31 -0
  3. package/.gitlab-ci.yml +206 -0
  4. package/.prettierrc +6 -0
  5. package/README.md +189 -18
  6. package/bin/cli.js +2 -2
  7. package/bin/postinstall.js +1 -16
  8. package/build/common/data-generator/steps/DataGenerator.spec.js +19 -0
  9. package/build/common/data-generator/steps/DataGeneratorStepsHelper.js +19 -0
  10. package/build/common/multi-actor/steps/multiActorHandling.spec.js +26 -0
  11. package/build/common/searchFake/helpers/rpcRequestHelper.js +52 -0
  12. package/build/common/searchFake/steps/searchFake.spec.js +77 -0
  13. package/build/core/dataGenerator/DataGenerator.js +108 -0
  14. package/build/core/dataGenerator/DataGeneratorError.js +50 -0
  15. package/build/core/dataGenerator/DataGeneratorHelper.js +49 -0
  16. package/{src → build}/core/jest/preprocessor/jsPreprocessor.js +7 -9
  17. package/{src → build}/core/jest/runner/jest-runner.js +46 -44
  18. package/build/core/jest/setup/index.js +3 -0
  19. package/build/core/playwright/builtInFixtures/actorContext.js +75 -0
  20. package/build/core/playwright/builtInFixtures/addTags.js +19 -0
  21. package/build/core/playwright/builtInFixtures/cacheLayer.js +13 -0
  22. package/build/core/playwright/builtInFixtures/context.js +32 -0
  23. package/build/core/playwright/builtInFixtures/executionContext.js +17 -0
  24. package/build/core/playwright/builtInFixtures/i18N.js +41 -0
  25. package/build/core/playwright/builtInFixtures/index.js +46 -0
  26. package/build/core/playwright/builtInFixtures/page.js +38 -0
  27. package/build/core/playwright/builtInFixtures/unauthenticatedPage.js +18 -0
  28. package/build/core/playwright/clear-caches.js +49 -0
  29. package/build/core/playwright/codegen.js +55 -0
  30. package/build/core/playwright/configuration/Configuration.js +25 -0
  31. package/build/core/playwright/configuration/ConfigurationHelper.js +43 -0
  32. package/build/core/playwright/configuration/UserArgs.js +12 -0
  33. package/build/core/playwright/constants/browserTypes.js +12 -0
  34. package/build/core/playwright/constants/fileMutexConfig.js +9 -0
  35. package/build/core/playwright/custom-commands.js +7 -0
  36. package/build/core/playwright/env-initializer.js +43 -0
  37. package/build/core/playwright/fixtures.js +24 -0
  38. package/build/core/playwright/helpers/additionalProfiles.js +25 -0
  39. package/build/core/playwright/helpers/auth/accountLogin.js +21 -0
  40. package/build/core/playwright/helpers/auth/checkAuthCookies.js +41 -0
  41. package/build/core/playwright/helpers/auth/getUrlOrigin.js +13 -0
  42. package/build/core/playwright/helpers/auth/getUsers.js +118 -0
  43. package/build/core/playwright/helpers/auth/index.js +76 -0
  44. package/build/core/playwright/helpers/auth/loginDefaultStepsHelper.js +54 -0
  45. package/build/core/playwright/helpers/auth/loginSteps.js +51 -0
  46. package/build/core/playwright/helpers/checkAuthDirectory.js +27 -0
  47. package/build/core/playwright/helpers/configFileNameProvider.js +31 -0
  48. package/build/core/playwright/helpers/customFixturesHelper.js +58 -0
  49. package/build/core/playwright/helpers/fileMutex.js +72 -0
  50. package/build/core/playwright/helpers/getUserFixtures.js +23 -0
  51. package/build/core/playwright/helpers/mergeObjects.js +13 -0
  52. package/build/core/playwright/helpers/parseUserArgs.js +10 -0
  53. package/build/core/playwright/index.js +24 -0
  54. package/build/core/playwright/readConfigFile.js +148 -0
  55. package/build/core/playwright/report-generator.js +42 -0
  56. package/build/core/playwright/runner/Runner.js +22 -0
  57. package/build/core/playwright/runner/RunnerHelper.js +43 -0
  58. package/build/core/playwright/runner/RunnerTypes.js +17 -0
  59. package/build/core/playwright/runner/SpawnRunner.js +113 -0
  60. package/build/core/playwright/setup/Project.js +35 -0
  61. package/build/core/playwright/setup/ProjectConfiguration.js +80 -0
  62. package/build/core/playwright/setup/config-creator.js +89 -0
  63. package/build/core/playwright/setup/config-utils.js +188 -0
  64. package/build/core/playwright/setup/custom-reporter.js +136 -0
  65. package/build/core/playwright/setup/qc-custom-reporter.js +291 -0
  66. package/build/core/playwright/tagProcessor.js +69 -0
  67. package/build/core/playwright/test-runner.js +118 -0
  68. package/build/core/playwright/types.js +44 -0
  69. package/build/core/playwright/validateFeature.js +28 -0
  70. package/build/decorators.d.ts +1 -0
  71. package/build/decorators.js +16 -0
  72. package/build/index.d.ts +78 -0
  73. package/build/index.js +105 -0
  74. package/build/lib/cli.js +78 -0
  75. package/build/lib/post-install.js +25 -0
  76. package/build/lint/index.js +4 -0
  77. package/build/parser/parser.js +205 -0
  78. package/build/parser/sample.feature +34 -0
  79. package/build/parser/sample.spec.js +37 -0
  80. package/build/parser/verifier.js +130 -0
  81. package/build/setup-folder-structure/helper.js +37 -0
  82. package/build/setup-folder-structure/reportEnhancement/addonScript.html +25 -0
  83. package/build/setup-folder-structure/reportEnhancement/reportAlteration.js +25 -0
  84. package/build/setup-folder-structure/samples/accountLogin-sample.js +19 -0
  85. package/build/setup-folder-structure/samples/actors-index.js +2 -0
  86. package/build/setup-folder-structure/samples/auth-setup-sample.js +15 -0
  87. package/build/setup-folder-structure/samples/editions-index.js +3 -0
  88. package/build/setup-folder-structure/samples/free-sample.json +25 -0
  89. package/build/setup-folder-structure/samples/git-ignore.sample.js +37 -0
  90. package/build/setup-folder-structure/samples/settings.json +7 -0
  91. package/build/setup-folder-structure/samples/testSetup-sample.js +14 -0
  92. package/build/setup-folder-structure/samples/uat-config-sample.js +46 -0
  93. package/build/setup-folder-structure/setupProject.js +122 -0
  94. package/build/test/core/playwright/__tests__/tagProcessor.test.js +94 -0
  95. package/build/test/core/playwright/__tests__/validateFeature.test.js +69 -0
  96. package/build/test/core/playwright/buildInFixtures/__tests__/executionContext.test.js +27 -0
  97. package/build/test/core/playwright/configuration/__tests__/Configuration.test.js +53 -0
  98. package/build/test/core/playwright/helpers/__tests__/additionalProfiles.test.js +45 -0
  99. package/build/test/core/playwright/helpers/__tests__/configFileNameProvider.test.js +34 -0
  100. package/build/test/core/playwright/helpers/__tests__/customFixturesHelper.test.js +51 -0
  101. package/build/test/core/playwright/helpers/__tests__/fileMutex.test.js +79 -0
  102. package/build/test/core/playwright/helpers/__tests__/getUsers_ListOfActors.test.js +80 -0
  103. package/build/test/core/playwright/runner/__tests__/RunnerHelper.test.js +16 -0
  104. package/build/test/core/playwright/runner/__tests__/SpawnRunner.test.js +27 -0
  105. package/{src → build}/utils/cliArgsToObject.js +72 -63
  106. package/build/utils/commonUtils.js +17 -0
  107. package/build/utils/fileUtils.js +109 -0
  108. package/build/utils/getFilePath.js +11 -0
  109. package/build/utils/logger.js +28 -0
  110. package/build/utils/rootPath.js +53 -0
  111. package/build/utils/stepDefinitionsFormatter.js +11 -0
  112. package/changelog.md +167 -25
  113. package/jest.config.js +81 -63
  114. package/npm-shrinkwrap.json +11894 -5772
  115. package/package.json +61 -31
  116. package/playwright.config.js +62 -112
  117. package/test-results/.last-run.json +4 -0
  118. package/unit_reports/unit-report.html +260 -0
  119. package/src/core/jest/setup/index.js +0 -165
  120. package/src/core/playwright/codegen.js +0 -60
  121. package/src/core/playwright/custom-commands.js +0 -3
  122. package/src/core/playwright/env-initializer.js +0 -24
  123. package/src/core/playwright/index.js +0 -82
  124. package/src/core/playwright/readConfigFile.js +0 -63
  125. package/src/core/playwright/report-generator.js +0 -45
  126. package/src/core/playwright/setup/config-creator.js +0 -77
  127. package/src/core/playwright/test-runner.js +0 -67
  128. package/src/index.js +0 -9
  129. package/src/lib/cli.js +0 -42
  130. package/src/setup-folder-structure/env-config-sample.json +0 -17
  131. package/src/setup-folder-structure/setupProject.js +0 -99
  132. package/src/setup-folder-structure/uat-config-sample.js +0 -22
  133. package/src/setup-folder-structure/user-example.json +0 -3
  134. package/src/utils/getFilePath.js +0 -9
  135. package/src/utils/logger.js +0 -28
  136. package/src/utils/rootPath.js +0 -51
package/.babelrc ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "presets": [
3
+ [
4
+ "@babel/preset-env",
5
+ {
6
+ "targets": {
7
+ "node": "14"
8
+ },
9
+ // We are adding plugin @babel/plugin-transform-destructuring to ensure babel does not transform the destructing
10
+ // as playwright does not allow parameters without destrucring
11
+ "exclude": ["@babel/plugin-transform-destructuring"]
12
+ }
13
+ ]
14
+ ],
15
+ "plugins": [
16
+ ["@babel/plugin-transform-runtime"],
17
+ ["@babel/plugin-transform-modules-commonjs"]
18
+ ],
19
+ // Ignored as these are setup files needed during init script. Files inside that folder are copied not transformed
20
+ "ignore": [
21
+ "./src/setup-folder-structure/samples",
22
+ "./src/common/**"
23
+ ]
24
+ }
package/.eslintrc.js ADDED
@@ -0,0 +1,31 @@
1
+ module.exports = {
2
+ "env": {
3
+ "node": true,
4
+ "es2021": true
5
+ },
6
+ "extends": "eslint:recommended",
7
+ "overrides": [
8
+ {
9
+ "env": {
10
+ "node": true
11
+ },
12
+ "files": [
13
+ ".eslintrc.{js,cjs}"
14
+ ],
15
+ "parserOptions": {
16
+ "sourceType": "script"
17
+ }
18
+ }
19
+ ],
20
+ "parserOptions": {
21
+ "ecmaVersion": "latest",
22
+ "sourceType": "module"
23
+ },
24
+ "rules": {
25
+ "indent": ["error", 2, { "SwitchCase": 1 }],
26
+ "no-empty-pattern": "off",
27
+ "comma-dangle": ["error", "never"],
28
+ "curly": ["error"],
29
+ "brace-style": "error"
30
+ }
31
+ }
package/.gitlab-ci.yml ADDED
@@ -0,0 +1,206 @@
1
+ image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v3
2
+
3
+ workflow:
4
+ rules:
5
+ - if: $CI_PIPELINE_SOURCE == "merge_request_event"
6
+ when: always
7
+ - if: $CI_PIPELINE_SOURCE == "web"
8
+ when: always
9
+
10
+ stages:
11
+ - build
12
+ - unit
13
+ - uat
14
+
15
+ default:
16
+ cache:
17
+ key: build-cache
18
+ paths:
19
+ - node_modules
20
+ - build
21
+ - npm-shrinkwrap.json
22
+
23
+ # Install dependencies stage
24
+ build:
25
+ stage: build
26
+ script:
27
+ - npm -v
28
+ - node -v
29
+ - npm install --ignore-scripts
30
+ - npm run build
31
+ - npm install
32
+ - npm shrinkwrap
33
+ - npm run build
34
+
35
+ # Unit tests stage
36
+ unit:
37
+ stage: unit
38
+ script:
39
+ - npm run test
40
+ artifacts:
41
+ when: always
42
+ paths:
43
+ - unit_reports
44
+
45
+ # UAT tests stage
46
+ uat-auth:
47
+ stage: uat
48
+ script:
49
+ - cd examples
50
+ - npm install $(npm pack ../../testing-framework | tail -1)
51
+ - output=$(npm run uatauth)
52
+ - echo "$output"
53
+ - node ../ValidateUATReport.js examples
54
+
55
+ artifacts:
56
+ when: always
57
+ paths:
58
+ - examples/uat/playwright-report
59
+
60
+ uat-noauth:
61
+ stage: uat
62
+ script:
63
+ - cd examples
64
+ - npm install $(npm pack ../../testing-framework | tail -1)
65
+ - output=$(npm run uatnoauth)
66
+ - echo "$output"
67
+ - node ../ValidateUATReport.js examples
68
+
69
+ artifacts:
70
+ when: always
71
+ paths:
72
+ - examples/uat/playwright-report
73
+
74
+ uat-profile:
75
+ stage: uat
76
+ script:
77
+ - cd examples
78
+ - npm install $(npm pack ../../testing-framework | tail -1)
79
+ - output=$(npm run uatprofile)
80
+ - echo "$output"
81
+ - node ../ValidateUATReport.js examples
82
+
83
+ artifacts:
84
+ when: always
85
+ paths:
86
+ - examples/uat/playwright-report
87
+
88
+
89
+ uat-unauth:
90
+ stage: uat
91
+ script:
92
+ - cd examples
93
+ - npm install $(npm pack ../../testing-framework | tail -1)
94
+ - output=$(npm run uatunauth)
95
+ - echo "$output"
96
+ - node ../ValidateUATReport.js examples
97
+
98
+
99
+ artifacts:
100
+ when: always
101
+ paths:
102
+ - examples/uat/playwright-report
103
+
104
+ uat-nobdd:
105
+ stage: uat
106
+ script:
107
+ - cd nobdd
108
+ - npm install $(npm pack ../../testing-framework | tail -1)
109
+ - output=$(npm run uatnobdd -- --headless)
110
+ - echo "$output"
111
+ - node ../ValidateUATReport.js nobdd
112
+
113
+
114
+ artifacts:
115
+ when: always
116
+ paths:
117
+ - nobdd/uat/playwright-report
118
+
119
+
120
+ uatmodule:
121
+ stage: uat
122
+ script:
123
+ - cd examples
124
+ - npm install $(npm pack ../../testing-framework | tail -1)
125
+ - output=$(npm run uatmodule)
126
+ - echo "$output"
127
+ - node ../ValidateUATReport.js examples
128
+
129
+
130
+ artifacts:
131
+ when: always
132
+ paths:
133
+ - examples/uat/playwright-report
134
+
135
+ uatconfigmodule:
136
+ stage: uat
137
+ script:
138
+ - cd examples
139
+ - npm install $(npm pack ../../testing-framework | tail -1)
140
+ - output=$(npm run uatconfigmodule)
141
+ - echo "$output"
142
+ - node ../ValidateUATReport.js examples
143
+
144
+ artifacts:
145
+ when: always
146
+ paths:
147
+ - examples/uat/playwright-report
148
+
149
+ uat-smoketest:
150
+ stage: uat
151
+ script:
152
+ - cd examples
153
+ - npm install $(npm pack ../../testing-framework | tail -1)
154
+ - output=$(npm run uat-smoketest)
155
+ - echo "$output"
156
+ - node ../ValidateUATReport.js examples
157
+
158
+ artifacts:
159
+ when: always
160
+ paths:
161
+ - examples/uat/playwright-report
162
+
163
+ uat-multiactor:
164
+ stage: uat
165
+ script:
166
+ - cd examples
167
+ - npm install $(npm pack ../../testing-framework | tail -1)
168
+ - output=$(npm run uat-multiactor)
169
+ - echo "$output"
170
+ - node ../ValidateUATReport.js examples
171
+
172
+ artifacts:
173
+ when: always
174
+ paths:
175
+ - examples/uat/playwright-report
176
+
177
+ uat-data_generator:
178
+ stage: uat
179
+ script:
180
+ - cd examples
181
+ - npm install $(npm pack ../../testing-framework | tail -1)
182
+ - output=$(npm run uat-data_generator)
183
+ - echo "$output"
184
+ - node ../ValidateUATReport.js examples
185
+
186
+ artifacts:
187
+ when: always
188
+ paths:
189
+ - examples/uat/playwright-report
190
+
191
+ uat-search_indexing:
192
+ stage: uat
193
+ script:
194
+ - cd examples
195
+ - npm install $(npm pack ../../testing-framework | tail -1)
196
+ - output=$(npm run uat-search_indexing)
197
+ - echo "$output"
198
+ - node ../ValidateUATReport.js examples
199
+
200
+ artifacts:
201
+ when: always
202
+ paths:
203
+ - examples/uat/playwright-report
204
+
205
+
206
+
package/.prettierrc ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "trailingComma": "none",
3
+ "singleQuote": true,
4
+ "arrowParens": "avoid",
5
+ "jsxSingleQuote": true
6
+ }
package/README.md CHANGED
@@ -1,18 +1,189 @@
1
- # Testing Framework
2
-
3
- ## Framework that abstracts the configuration for playwright and Jest
4
-
5
- - Playwright
6
- - Jest
7
-
8
- ## Cli
9
-
10
- ## Feature Supported
11
-
12
- ### Run TestCase
13
-
14
- - npm run test
15
- ### Generate Report
16
-
17
- - npm run report
18
-
1
+ # Testing Framework
2
+
3
+ ## Framework that abstracts the configuration for playwright and Jest
4
+
5
+ - Playwright
6
+ - Jest
7
+
8
+ ## Cli
9
+
10
+ ## Feature Supported
11
+
12
+ ### Run TestCase
13
+
14
+ - npm run test
15
+
16
+ ### Generate Report
17
+
18
+ - npm run report
19
+
20
+ ### v3.2.11 - 13-10-2025
21
+
22
+ ### Feature
23
+
24
+ - New step a search entity using {string} provided for search indexing, This step will use run time data generation response as input for the indexing
25
+
26
+ ### Issue fix
27
+ - Custom teardown comment provided
28
+
29
+ ### v3.2.10 - 09-10-2025
30
+
31
+ #### Enhancement
32
+ - A teardown option has been introduced in the configuration to manage and clean up login sessions stored in the NFS environment.
33
+
34
+
35
+ ### v3.2.9 - 26-09-2025
36
+
37
+ ### Enhancement
38
+
39
+ - Authentication deatils for data generation can be configured in org level
40
+ - reference link : https://learn.zoho.in/portal/zohocorp/knowledge/manual/client-uat/article/data-generation#_Tocpd3n7yt9ngeg
41
+
42
+
43
+ ### v3.2.8 - 18-09-2025
44
+
45
+ ### Bug fix
46
+
47
+ - Default profile switching handled in Multi actor – Improved handling of default profile switching to ensure smoother execution flow.
48
+
49
+ - QC Report tags issue fixed – Resolved an issue where QC Report tags were not displaying correctly in reports.
50
+
51
+ ### v3.2.7 - 10-09-2025
52
+
53
+ ### Bug fix
54
+ - Fixed a bug where the default profile page was not being handled properly in `this`.
55
+
56
+ ### v3.2.6 - 05-09-2025
57
+
58
+ #### Feature
59
+
60
+ - Multi-actor execution support – now possible to switch between multiple profile agents within scenarios using the predefined step: - `access the {string} profile page`
61
+
62
+ ### Bug fix
63
+ - Fixed the issue where localapp and hcapp UAT were not running properly.
64
+
65
+ ### v3.2.5 - 28-08-2025
66
+
67
+ #### Enhancement
68
+
69
+ - Removed the searchFake dependency from the project level and adopted it inside the framework, reducing project-side maintenance. use this predefined step: - `Given (a search entity)`
70
+
71
+ ### v3.2.4 - 29-07-2025
72
+
73
+ #### Feature
74
+ - Data Generator steps are now supported directly via the framework.
75
+
76
+ ### Bug fix
77
+ - Feature File Root Directory not found issue fixed
78
+
79
+ ### v3.2.3 - 29-07-2025
80
+
81
+ #### Feature
82
+ - Added support for running Smoke Tests in the UAT stage.
83
+
84
+ ### v3.2.0 - 22-06-2025
85
+
86
+ #### Feature
87
+ - Default required spec files are now auto-imported from the library into the project.
88
+
89
+ ### v3.1.13 - 02-07-2025
90
+
91
+ #### Enhancement
92
+ - Below package versions are updated in this release.
93
+ - @cucumber/Cucumber - 11.3.0
94
+ - Playwright/test - 1.53.2
95
+ - Playwright - 1.53.2
96
+ - Playwright-bdd - 8.3.1
97
+ - QC custom reporter changes have been adopted into the framework.
98
+
99
+ ### v3.1.5 - 22-05-2025
100
+
101
+ #### Feature
102
+ - Added support for Module Based Execution UAT stage.
103
+
104
+ ### v3.1.4 - 12-05-2025
105
+
106
+ #### Enhancement
107
+ - Playwright version 1.52.0 adopted in testing framework
108
+
109
+ ### v3.1.3 - 25-04-2025
110
+
111
+ #### Enhancement
112
+ - Playwright version 1.51.0 adopted in testing framework
113
+
114
+ ### v0.2.8 - 26-09-2024
115
+
116
+ #### Feature
117
+ - Added support for writing unitcases for framework implementations
118
+
119
+ ### Bug fix
120
+ - 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.
121
+
122
+
123
+ ### v3.0.8 - 25-12-2024
124
+
125
+ #### Enhancement
126
+ - Added support to disable headless mode using command line arguments
127
+ - Proper validation added for node 14 build process
128
+ - Removed unwanted uat.config.js files in test projects (examples / nobdd)
129
+
130
+ ### v0.2.9.2 - 22-11-2024
131
+
132
+ #### BugFix
133
+ - Implemented synchronization for the login process. This fix will help avoid login session-related failures in UAT.
134
+
135
+ ### v0.3.1 - 13-11-2024
136
+
137
+ #### Issue Fix
138
+ - Adding bddmode to get the fixtures.
139
+
140
+ ### v0.2.9.1 - 14-11-2024
141
+
142
+ #### Enhancement
143
+ - Beta feature Actors and edition configurations are unified
144
+
145
+ ### v0.2.9 - 25-10-2024
146
+
147
+ #### Feature
148
+ - Added support for scenario level tag support
149
+ - Added a new cli optin like uat-validate to validate the feature files using playwright-bdd
150
+ - Mode based configuration implementations
151
+ - @only option enabled in dev pipeline
152
+ - Latest setup related configuration changed for init option
153
+
154
+ ### v0.3.0 - 25-10-2024
155
+
156
+ #### Features
157
+ - Added support for scenario level tag support
158
+ - Updated the configuration for `video` and `trace` to accept Playwright-specific values instead of boolean values.
159
+ - Below package versions are updated in this release.
160
+ - playwright - 1.48.0,
161
+ - playwright-bdd - 7.5.0,
162
+ - @playwright/test - 1.48.0,
163
+ - @cucumber/cucumber - 11.0.1
164
+ - From this version, We adopt the playwright-bdd as library instead of modified source
165
+ - Published on 11-11-2024
166
+
167
+ #### Deprecations
168
+ - **Deprecated**: Passing `video` and `trace` as boolean (`true`/`false`) in project configuration.
169
+ - **New Approach**: Use Playwright values for `video` and `trace` options, such as `'on'`, `'retain-on-failure'`, or `'off'`.
170
+
171
+ ### v0.3.1 - 13-11-2024
172
+
173
+ #### Issue Fix
174
+ - Adding bddmode to get the fixtures.
175
+
176
+ ### v0.3.3 - 27-11-2024
177
+
178
+ #### Feature
179
+ - Custom report integration support (ReportPortal)
180
+
181
+ ### v0.2.9.1 - 14-11-2024
182
+
183
+ #### Enhancement
184
+ - Beta feature Actors and edition configurations are unified
185
+
186
+ ### v0.2.9.2 - 22-11-2024
187
+
188
+ #### BugFix
189
+ - Implemented synchronization for the login process. This fix will help avoid login session-related failures in UAT.
package/bin/cli.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
-
3
- require('../src/lib/cli');
2
+
3
+ require('../build/lib/cli');
@@ -1,16 +1 @@
1
- const path = require('path');
2
- const { spawn } = require('child_process');
3
- const { Logger } = require('../src/utils/logger');
4
- const getFilePathWithExtension = require('../src/utils/getFilePath');
5
-
6
- const playwrightPath = path.resolve('node_modules', '.bin', getFilePathWithExtension('playwright'));
7
- const command = playwrightPath;
8
- const args = ['install'];
9
-
10
- Logger.log(Logger.INFO_TYPE, 'Downloading browsers for running tests');
11
-
12
- const childProcess = spawn(command, args, { stdio: 'inherit' });
13
-
14
- childProcess.on('error', (error) => {
15
- Logger.log(Logger.FAILURE_TYPE, error);
16
- });
1
+ require('../build/lib/post-install');
@@ -0,0 +1,19 @@
1
+ import { createBdd , test } from '@zohodesk/testinglibrary';
2
+ import { generateAndCacheTestData } from './DataGeneratorStepsHelper';
3
+
4
+ const { Given } = createBdd();
5
+
6
+ Given('generate a {string} entity {string} with generator {string}', async ({ page, context, i18N, cacheLayer, executionContext}, module, entityName, generatorName, dataTable) => {
7
+ await generateAndCacheTestData(executionContext, "template", generatorName, dataTable, cacheLayer, entityName);
8
+ });
9
+
10
+ Given('generate a {string} entity {string} with API {string}', async ({ page, context, i18N, cacheLayer, executionContext}, module, entityName, operationId, dataTable) => {
11
+ await generateAndCacheTestData(executionContext, "API", operationId, dataTable, cacheLayer, entityName);
12
+ });
13
+ Given('generate a {string} entity {string} with generator {string} using {string} profile', async ({ page, context, i18N, cacheLayer, executionContext}, module, entityName, generatorName, profile, dataTable) => {
14
+ await generateAndCacheTestData(executionContext, "template", generatorName, dataTable, cacheLayer, entityName, profile);
15
+ });
16
+
17
+ Given('generate a {string} entity {string} with API {string} using {string} profile', async ({ page, context, i18N, cacheLayer, executionContext}, module, entityName, operationId, profile, dataTable) => {
18
+ await generateAndCacheTestData(executionContext, "API", operationId, dataTable, cacheLayer, entityName, profile);
19
+ });
@@ -0,0 +1,19 @@
1
+ import { test } from '@zohodesk/testinglibrary';
2
+ import DataGenerator from '@zohodesk/testinglibrary/DataGenerator';
3
+
4
+ const dataGenerator = new DataGenerator();
5
+
6
+ export async function generateAndCacheTestData(executionContext, type, identifier, dataTable, cacheLayer, entityName, profile = null) {
7
+ let actorInfo;
8
+ const testInfo = test.info();
9
+ const scenarioName = testInfo.title.split('/').pop() || 'Unknown Scenario';
10
+
11
+ if (profile) {
12
+ actorInfo = await dataGenerator.getDataGenUserExecutionContext(executionContext.actorInfo.edition, profile);
13
+ } else {
14
+ actorInfo = executionContext.actorInfo;
15
+ }
16
+
17
+ const generatedData = await dataGenerator.generate(testInfo, actorInfo, type, identifier, scenarioName, dataTable ? dataTable.hashes() : []);
18
+ await cacheLayer.set(entityName, generatedData.data);
19
+ }
@@ -0,0 +1,26 @@
1
+ import { createBdd } from '@zohodesk/testinglibrary';
2
+ const { BeforeScenario, Given } = createBdd();
3
+
4
+ BeforeScenario(async function({ page, context, browser, cacheLayer, executionContext, actorContext }) {
5
+ // This will run before each scenario and set all the fixtures into this context
6
+ this.page = page;
7
+ this.context = context;
8
+ this.browser = browser;
9
+ this.cacheLayer = cacheLayer;
10
+ this.executionContext = executionContext;
11
+ this.setActor = async (role) => {
12
+ const userPage = actorContext.actorsObj[role];
13
+ if (userPage) {
14
+ this.page = userPage.page;
15
+ this.context = userPage.context;
16
+ this.browser = userPage.browser;
17
+ this.executionContext = userPage.executionContext;
18
+ } else {
19
+ throw new Error(`Actor "${role}" not found in user pages.`);
20
+ }
21
+ }
22
+ });
23
+
24
+ Given("access the {string} profile page", async function({ page }, userRole) {
25
+ await this.setActor(userRole);
26
+ });
@@ -0,0 +1,52 @@
1
+ import { expect } from '@zohodesk/testinglibrary';
2
+
3
+ async function executeRpcRequest(page, payload) {
4
+
5
+ const url = new URL(page.url());
6
+ const baseUrl = `${url.protocol}//${url.host}`;
7
+ const invokeURL = `${baseUrl}/api/testing/acceptanceTest/rpc/invoke`;
8
+
9
+ try {
10
+ const response = await page.request.post(invokeURL, {
11
+ headers: {'Content-Type': 'application/json'},
12
+ data: payload
13
+ });
14
+
15
+ if (!response.ok()) {
16
+ throw new Error(`HTTP ${response.status()}: ${response.statusText()}`);
17
+ }
18
+
19
+ const responseData = await response.json();
20
+ expect(responseData.data).toHaveProperty('status', 'success');
21
+
22
+ } catch (error) {
23
+ throw error;
24
+ }
25
+ }
26
+
27
+
28
+ async function entityIdReConstructor(payload) {
29
+
30
+ if (typeof payload !== 'object' || payload === null) {
31
+ throw new Error('Invalid payload. It must be a non-null object.');
32
+ }
33
+
34
+ if (!payload.arguments || (!payload.arguments.entityId)) {
35
+ throw new Error('Invalid payload.arguments.entityId. It must be a non-empty string or array of strings.');
36
+ }
37
+
38
+ const entityId = payload.arguments.entityId;
39
+
40
+ // If it's already an array, validate and clean it
41
+ if (Array.isArray(entityId)) {
42
+ payload.arguments.entityId = entityId.map(id => id.trim());
43
+ }
44
+ // If it's a string, split and convert to array
45
+ else if (typeof entityId === 'string') {
46
+ payload.arguments.entityId = entityId.split(',').map(id => id.trim());
47
+ }
48
+
49
+ return payload;
50
+ }
51
+
52
+ module.exports = { executeRpcRequest, entityIdReConstructor };
@@ -0,0 +1,77 @@
1
+ import {createBdd } from '@zohodesk/testinglibrary';
2
+ import { executeRpcRequest , entityIdReConstructor } from '../helpers/rpcRequestHelper';
3
+ // import jp from 'jsonpath';
4
+
5
+ const { Given } = createBdd();
6
+
7
+
8
+ // Given a search entity
9
+ // | moduleName | entityId | entityName | searchString |
10
+ // | contact | 122000006785675, 122000007141665, 122000006636472 | QA Team | testinguat |
11
+
12
+ Given('a search entity', async ({page}, dataTable)=>{
13
+ const data = dataTable.hashes();
14
+
15
+ for (const row of data) {
16
+
17
+ const { moduleName, entityId, searchString } = row;
18
+ const payload = {
19
+ className: 'applicationDriver.rpc.desk.integrations.search.SearchFakeDataPopulator',
20
+ methodName: 'populateSearchData',
21
+ arguments: {
22
+ module: moduleName,
23
+ searchString: searchString,
24
+ entityId: entityId
25
+ }
26
+ };
27
+ await entityIdReConstructor(payload);
28
+
29
+ await executeRpcRequest(page, payload);
30
+ }
31
+ });
32
+
33
+ // Given data generation step
34
+ // Given a search entity using "C1"
35
+ // | moduleName | searchString | searchEntity (response of the previous data generation step) |
36
+ // | contact | testinguat | $.id |
37
+ // | contact | testinguat | $.ids |
38
+ // | contact | testinguat |
39
+
40
+ Given('a search entity using {string}', async ({page,cacheLayer}, reference,dataTable)=>{
41
+ const data = dataTable.hashes();
42
+
43
+ const row = data[0];
44
+ if (!row || !row.moduleName || !row.searchString) {
45
+ throw new Error('Invalid or missing data in dataTable');
46
+ }
47
+
48
+ const { moduleName, searchEntity, searchString } = row;
49
+
50
+ const searchObj = cacheLayer.get(reference);
51
+ let entityIdValue;
52
+
53
+ if (typeof searchObj === 'string') {
54
+ entityIdValue = searchObj;
55
+ } else {
56
+ const jsonPath = searchEntity?.startsWith?.('$') ? searchEntity : `$.${searchEntity}`;
57
+ const result = null;//jp.query(searchObj, jsonPath);
58
+
59
+ if (!result || result.length === 0) {
60
+ throw new Error(`JSONPath query '${jsonPath}' returned no results from cache object for reference: ${reference}`);
61
+ }
62
+
63
+ entityIdValue = result.length === 1 ? result[0] : result;
64
+ }
65
+
66
+ const payload = {
67
+ className: 'applicationDriver.rpc.desk.integrations.search.SearchFakeDataPopulator',
68
+ methodName: 'populateSearchData',
69
+ arguments: {
70
+ module: moduleName,
71
+ searchString: searchString,
72
+ entityId: entityIdValue
73
+ }
74
+ };
75
+ await entityIdReConstructor(payload);
76
+ await executeRpcRequest(page, payload);
77
+ });