@zohodesk/testinglibrary 0.0.2 → 0.0.3-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.
- package/.babelrc +23 -0
- package/.eslintrc.js +31 -0
- package/.gitlab-ci.yml +163 -0
- package/.prettierrc +6 -0
- package/README.md +81 -1
- package/bin/cli.js +1 -1
- package/bin/postinstall.js +1 -16
- package/{src → build}/core/jest/preprocessor/jsPreprocessor.js +4 -6
- package/{src → build}/core/jest/runner/jest-runner.js +17 -15
- package/build/core/jest/setup/index.js +3 -0
- package/build/core/playwright/builtInFixtures/addTags.js +19 -0
- package/build/core/playwright/builtInFixtures/cacheLayer.js +13 -0
- package/build/core/playwright/builtInFixtures/context.js +32 -0
- package/build/core/playwright/builtInFixtures/executionContext.js +17 -0
- package/build/core/playwright/builtInFixtures/i18N.js +41 -0
- package/build/core/playwright/builtInFixtures/index.js +44 -0
- package/build/core/playwright/builtInFixtures/page.js +101 -0
- package/build/core/playwright/builtInFixtures/unauthenticatedPage.js +18 -0
- package/build/core/playwright/clear-caches.js +49 -0
- package/build/core/playwright/codegen.js +55 -0
- package/build/core/playwright/configuration/Configuration.js +25 -0
- package/build/core/playwright/configuration/ConfigurationHelper.js +43 -0
- package/build/core/playwright/configuration/UserArgs.js +12 -0
- package/build/core/playwright/constants/browserTypes.js +12 -0
- package/build/core/playwright/constants/fileMutexConfig.js +9 -0
- package/build/core/playwright/custom-commands.js +7 -0
- package/build/core/playwright/env-initializer.js +43 -0
- package/build/core/playwright/fixtures.js +24 -0
- package/build/core/playwright/helpers/additionalProfiles.js +18 -0
- package/build/core/playwright/helpers/auth/accountLogin.js +21 -0
- package/build/core/playwright/helpers/auth/checkAuthCookies.js +41 -0
- package/build/core/playwright/helpers/auth/getUrlOrigin.js +13 -0
- package/build/core/playwright/helpers/auth/getUsers.js +118 -0
- package/build/core/playwright/helpers/auth/index.js +76 -0
- package/build/core/playwright/helpers/auth/loginSteps.js +50 -0
- package/build/core/playwright/helpers/checkAuthDirectory.js +27 -0
- package/build/core/playwright/helpers/configFileNameProvider.js +31 -0
- package/build/core/playwright/helpers/fileMutex.js +71 -0
- package/build/core/playwright/helpers/getUserFixtures.js +23 -0
- package/build/core/playwright/helpers/mergeObjects.js +13 -0
- package/build/core/playwright/helpers/parseUserArgs.js +10 -0
- package/build/core/playwright/index.js +24 -0
- package/build/core/playwright/readConfigFile.js +147 -0
- package/build/core/playwright/report-generator.js +42 -0
- package/build/core/playwright/runner/Runner.js +22 -0
- package/build/core/playwright/runner/RunnerHelper.js +43 -0
- package/build/core/playwright/runner/RunnerTypes.js +17 -0
- package/build/core/playwright/runner/SpawnRunner.js +110 -0
- package/build/core/playwright/setup/config-creator.js +113 -0
- package/build/core/playwright/setup/config-utils.js +189 -0
- package/build/core/playwright/setup/custom-reporter.js +136 -0
- package/build/core/playwright/setup/qc-custom-reporter.js +291 -0
- package/build/core/playwright/tagProcessor.js +69 -0
- package/build/core/playwright/test-runner.js +116 -0
- package/build/core/playwright/types.js +44 -0
- package/build/core/playwright/validateFeature.js +28 -0
- package/build/decorators.d.ts +1 -0
- package/build/decorators.js +16 -0
- package/build/index.d.ts +78 -0
- package/build/index.js +105 -0
- package/build/lib/cli.js +78 -0
- package/build/lib/post-install.js +25 -0
- package/build/lint/index.js +4 -0
- package/build/parser/parser.js +205 -0
- package/build/parser/sample.feature +34 -0
- package/build/parser/sample.spec.js +37 -0
- package/build/parser/verifier.js +130 -0
- package/build/setup-folder-structure/helper.js +37 -0
- package/build/setup-folder-structure/reportEnhancement/addonScript.html +25 -0
- package/build/setup-folder-structure/reportEnhancement/reportAlteration.js +25 -0
- package/build/setup-folder-structure/samples/accountLogin-sample.js +19 -0
- package/build/setup-folder-structure/samples/actors-index.js +2 -0
- package/build/setup-folder-structure/samples/auth-setup-sample.js +15 -0
- package/build/setup-folder-structure/samples/editions-index.js +3 -0
- package/build/setup-folder-structure/samples/free-sample.json +25 -0
- package/build/setup-folder-structure/samples/git-ignore.sample.js +37 -0
- package/build/setup-folder-structure/samples/settings.json +7 -0
- package/build/setup-folder-structure/samples/testSetup-sample.js +14 -0
- package/build/setup-folder-structure/samples/uat-config-sample.js +46 -0
- package/build/setup-folder-structure/setupProject.js +122 -0
- package/build/test/core/playwright/__tests__/tagProcessor.test.js +94 -0
- package/build/test/core/playwright/__tests__/validateFeature.test.js +69 -0
- package/build/test/core/playwright/buildInFixtures/__tests__/executionContext.test.js +27 -0
- package/build/test/core/playwright/configuration/__tests__/Configuration.test.js +53 -0
- package/build/test/core/playwright/helpers/__tests__/configFileNameProvider.test.js +34 -0
- package/build/test/core/playwright/helpers/__tests__/fileMutex.test.js +79 -0
- package/build/test/core/playwright/helpers/__tests__/getUsers_ListOfActors.test.js +80 -0
- package/build/test/core/playwright/runner/__tests__/RunnerHelper.test.js +16 -0
- package/build/test/core/playwright/runner/__tests__/SpawnRunner.test.js +27 -0
- package/build/utils/cliArgsToObject.js +72 -0
- package/build/utils/fileUtils.js +89 -0
- package/build/utils/getFilePath.js +11 -0
- package/build/utils/logger.js +57 -0
- package/build/utils/rootPath.js +53 -0
- package/build/utils/stepDefinitionsFormatter.js +11 -0
- package/changelog.md +156 -0
- package/jest.config.js +29 -11
- package/npm-shrinkwrap.json +11537 -4681
- package/package.json +45 -16
- package/playwright.config.js +6 -56
- package/src/core/jest/setup/index.js +0 -165
- package/src/core/playwright/codegen.js +0 -60
- package/src/core/playwright/custom-commands.js +0 -3
- package/src/core/playwright/env-initializer.js +0 -24
- package/src/core/playwright/index.js +0 -82
- package/src/core/playwright/readConfigFile.js +0 -18
- package/src/core/playwright/report-generator.js +0 -43
- package/src/core/playwright/test-runner.js +0 -64
- package/src/index.js +0 -9
- package/src/lib/cli.js +0 -35
- package/src/utils/cliArgsToObject.js +0 -35
- package/src/utils/getFilePath.js +0 -9
- package/src/utils/logger.js +0 -28
- package/src/utils/rootPath.js +0 -51
package/.babelrc
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
]
|
|
23
|
+
}
|
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,163 @@
|
|
|
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
|
+
|
package/.prettierrc
ADDED
package/README.md
CHANGED
|
@@ -15,4 +15,84 @@
|
|
|
15
15
|
### Generate Report
|
|
16
16
|
|
|
17
17
|
- npm run report
|
|
18
|
-
|
|
18
|
+
|
|
19
|
+
## Version History
|
|
20
|
+
|
|
21
|
+
### v0.2.8 - 26-09-2024
|
|
22
|
+
|
|
23
|
+
#### Feature
|
|
24
|
+
- Added support for writing unitcases for framework implementations
|
|
25
|
+
|
|
26
|
+
### Bug fix
|
|
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
|
+
|
|
29
|
+
|
|
30
|
+
## Version History
|
|
31
|
+
|
|
32
|
+
### v3.0.8 - 25-12-2024
|
|
33
|
+
|
|
34
|
+
#### Enhancement
|
|
35
|
+
- Added support to disable headless mode using command line arguments
|
|
36
|
+
- Proper validation added for node 14 build process
|
|
37
|
+
- Removed unwanted uat.config.js files in test projects (examples / nobdd)
|
|
38
|
+
|
|
39
|
+
### v0.2.9.2 - 22-11-2024
|
|
40
|
+
|
|
41
|
+
#### BugFix
|
|
42
|
+
- Implemented synchronization for the login process. This fix will help avoid login session-related failures in UAT.
|
|
43
|
+
|
|
44
|
+
### v0.3.1 - 13-11-2024
|
|
45
|
+
|
|
46
|
+
#### Issue Fix
|
|
47
|
+
- Adding bddmode to get the fixtures.
|
|
48
|
+
|
|
49
|
+
### v0.2.9.1 - 14-11-2024
|
|
50
|
+
|
|
51
|
+
#### Enhancement
|
|
52
|
+
- Beta feature Actors and edition configurations are unified
|
|
53
|
+
|
|
54
|
+
### v0.2.9 - 25-10-2024
|
|
55
|
+
|
|
56
|
+
#### Feature
|
|
57
|
+
- Added support for scenario level tag support
|
|
58
|
+
- Added a new cli optin like uat-validate to validate the feature files using playwright-bdd
|
|
59
|
+
- Mode based configuration implementations
|
|
60
|
+
- @only option enabled in dev pipeline
|
|
61
|
+
- Latest setup related configuration changed for init option
|
|
62
|
+
|
|
63
|
+
### v0.3.0 - 25-10-2024
|
|
64
|
+
|
|
65
|
+
#### Features
|
|
66
|
+
- Added support for scenario level tag support
|
|
67
|
+
- Updated the configuration for `video` and `trace` to accept Playwright-specific values instead of boolean values.
|
|
68
|
+
- Below package versions are updated in this release.
|
|
69
|
+
- playwright - 1.48.0,
|
|
70
|
+
- playwright-bdd - 7.5.0,
|
|
71
|
+
- @playwright/test - 1.48.0,
|
|
72
|
+
- @cucumber/cucumber - 11.0.1
|
|
73
|
+
- From this version, We adopt the playwright-bdd as library instead of modified source
|
|
74
|
+
- Published on 11-11-2024
|
|
75
|
+
|
|
76
|
+
#### Deprecations
|
|
77
|
+
- **Deprecated**: Passing `video` and `trace` as boolean (`true`/`false`) in project configuration.
|
|
78
|
+
- **New Approach**: Use Playwright values for `video` and `trace` options, such as `'on'`, `'retain-on-failure'`, or `'off'`.
|
|
79
|
+
|
|
80
|
+
### v0.3.1 - 13-11-2024
|
|
81
|
+
|
|
82
|
+
#### Issue Fix
|
|
83
|
+
- Adding bddmode to get the fixtures.
|
|
84
|
+
|
|
85
|
+
### v0.3.3 - 27-11-2024
|
|
86
|
+
|
|
87
|
+
#### Feature
|
|
88
|
+
- Custom report integration support (ReportPortal)
|
|
89
|
+
|
|
90
|
+
### v0.2.9.1 - 14-11-2024
|
|
91
|
+
|
|
92
|
+
#### Enhancement
|
|
93
|
+
- Beta feature Actors and edition configurations are unified
|
|
94
|
+
|
|
95
|
+
### v0.2.9.2 - 22-11-2024
|
|
96
|
+
|
|
97
|
+
#### BugFix
|
|
98
|
+
- Implemented synchronization for the login process. This fix will help avoid login session-related failures in UAT.
|
package/bin/cli.js
CHANGED
package/bin/postinstall.js
CHANGED
|
@@ -1,16 +1 @@
|
|
|
1
|
-
|
|
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');
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
+
const babelJest = require('babel-jest');
|
|
3
4
|
module.exports = babelJest.createTransformer({
|
|
4
|
-
presets: [
|
|
5
|
-
require.resolve('@babel/preset-env'),
|
|
6
|
-
require.resolve('@babel/preset-react')
|
|
7
|
-
],
|
|
5
|
+
presets: [require.resolve('@babel/preset-env'), require.resolve('@babel/preset-react')],
|
|
8
6
|
plugins: [require.resolve('babel-plugin-transform-dynamic-import')]
|
|
9
|
-
});
|
|
7
|
+
});
|
|
@@ -1,7 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = createJestRunner;
|
|
8
|
+
var _child_process = require("child_process");
|
|
9
|
+
var _path = _interopRequireDefault(require("path"));
|
|
10
|
+
var _rootPath = require("../../../utils/rootPath");
|
|
11
|
+
/* eslint-disable no-unused-vars */
|
|
1
12
|
// import { run } from 'jest';
|
|
2
13
|
|
|
3
14
|
// function createJestRunner() {
|
|
4
|
-
// let config
|
|
15
|
+
// let config from '../configs/jest.config');
|
|
5
16
|
|
|
6
17
|
// let argv = process.argv.slice(2);
|
|
7
18
|
|
|
@@ -9,25 +20,19 @@
|
|
|
9
20
|
// run(argv);
|
|
10
21
|
// }
|
|
11
22
|
|
|
12
|
-
|
|
13
23
|
// export default createJestRunner;
|
|
14
24
|
|
|
15
|
-
const
|
|
16
|
-
const path = require('path');
|
|
17
|
-
const { getExecutableBinaryPath } = require('../../../utils/rootPath');
|
|
18
|
-
|
|
19
|
-
const jestPath = path.resolve(getExecutableBinaryPath('jest'));
|
|
25
|
+
const jestPath = _path.default.resolve((0, _rootPath.getExecutableBinaryPath)('jest'));
|
|
20
26
|
|
|
21
27
|
// Command and arguments for npx playwright test
|
|
22
28
|
const command = jestPath;
|
|
23
29
|
const args = ['--config', require.resolve('../../../../jest.config.js')];
|
|
24
|
-
|
|
25
|
-
|
|
26
30
|
function createJestRunner() {
|
|
27
31
|
// Spawn the child process
|
|
28
32
|
|
|
29
|
-
const childProcess = spawn(command, args, {
|
|
30
|
-
|
|
33
|
+
const childProcess = (0, _child_process.spawn)(command, args, {
|
|
34
|
+
stdio: 'inherit'
|
|
35
|
+
});
|
|
31
36
|
|
|
32
37
|
// Handling the 'exit' event of the child process
|
|
33
38
|
// childProcess.on('exit', (code, signal) => {
|
|
@@ -38,7 +43,4 @@ function createJestRunner() {
|
|
|
38
43
|
// childProcess.on('error', (err) => {
|
|
39
44
|
// console.error(`Error while spawning child process: ${err.message}`);
|
|
40
45
|
// });
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
module.exports = createJestRunner;
|
|
46
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = exports.default = {
|
|
8
|
+
addTags: [async ({
|
|
9
|
+
$tags
|
|
10
|
+
}, use, testInfo) => {
|
|
11
|
+
testInfo.annotations.push({
|
|
12
|
+
type: 'tags',
|
|
13
|
+
description: $tags.join(', ')
|
|
14
|
+
});
|
|
15
|
+
await use();
|
|
16
|
+
}, {
|
|
17
|
+
auto: true
|
|
18
|
+
}]
|
|
19
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
const cacheMap = new Map();
|
|
8
|
+
var _default = exports.default = {
|
|
9
|
+
// eslint-disable-next-line no-empty-pattern
|
|
10
|
+
cacheLayer: async ({}, use) => {
|
|
11
|
+
await use(cacheMap);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _readConfigFile = require("../readConfigFile");
|
|
8
|
+
const {
|
|
9
|
+
testSetup
|
|
10
|
+
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
11
|
+
async function performDefaultContextSteps({
|
|
12
|
+
context
|
|
13
|
+
}) {
|
|
14
|
+
if (testSetup.context && typeof testSetup.context === 'function') {
|
|
15
|
+
await testSetup.context({
|
|
16
|
+
context
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
var _default = exports.default = {
|
|
21
|
+
context: async ({
|
|
22
|
+
context
|
|
23
|
+
}, use) => {
|
|
24
|
+
await context.addInitScript(() =>
|
|
25
|
+
// eslint-disable-next-line no-undef
|
|
26
|
+
window.localStorage.setItem('isDnBannerHide', true));
|
|
27
|
+
await performDefaultContextSteps({
|
|
28
|
+
context
|
|
29
|
+
});
|
|
30
|
+
await use(context);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _page = require("./page");
|
|
8
|
+
var _default = exports.default = {
|
|
9
|
+
executionContext: async ({
|
|
10
|
+
$tags
|
|
11
|
+
}, use) => {
|
|
12
|
+
let testPortalActorDetails = {
|
|
13
|
+
actorInfo: (0, _page.getCustomAccountDetails)($tags)
|
|
14
|
+
};
|
|
15
|
+
await use(testPortalActorDetails);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
/* eslint-disable no-undef */
|
|
8
|
+
/* eslint-disable no-param-reassign */
|
|
9
|
+
|
|
10
|
+
// Note: We are duplicating below method from @zohodesk/i18n. We are not importing it as react package not yet availble in test environment.
|
|
11
|
+
function replaceI18NValuesWithRegex(i18nStr, values) {
|
|
12
|
+
if (typeof values !== 'undefined') {
|
|
13
|
+
if (Array.isArray(values)) {
|
|
14
|
+
for (let i = 0; i < values.length; i++) {
|
|
15
|
+
i18nStr = i18nStr.replace(new RegExp(`\\{${i}\\}`, 'g'), values[i]);
|
|
16
|
+
}
|
|
17
|
+
} else {
|
|
18
|
+
i18nStr = i18nStr.replace(new RegExp('\\{0\\}', 'g'), values);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return i18nStr;
|
|
22
|
+
}
|
|
23
|
+
async function isI18NKeyDefined(key) {
|
|
24
|
+
return new Promise(resolve => {
|
|
25
|
+
if (typeof window.i18n[key] !== 'undefined') {
|
|
26
|
+
resolve();
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
var _default = exports.default = {
|
|
31
|
+
i18N: async ({
|
|
32
|
+
page
|
|
33
|
+
}, use) => {
|
|
34
|
+
await use(async (key, values) => {
|
|
35
|
+
await page.waitForFunction(isI18NKeyDefined(key));
|
|
36
|
+
const i18nValue = await page.evaluate(i18nKey => window.i18n[i18nKey], key);
|
|
37
|
+
const i18nStr = replaceI18NValuesWithRegex(i18nValue, values);
|
|
38
|
+
return i18nStr;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
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 _page = _interopRequireDefault(require("./page"));
|
|
9
|
+
var _context = _interopRequireDefault(require("./context"));
|
|
10
|
+
var _cacheLayer = _interopRequireDefault(require("./cacheLayer"));
|
|
11
|
+
var _addTags = _interopRequireDefault(require("./addTags"));
|
|
12
|
+
var _i18N = _interopRequireDefault(require("./i18N"));
|
|
13
|
+
var _unauthenticatedPage = _interopRequireDefault(require("./unauthenticatedPage"));
|
|
14
|
+
var _executionContext = _interopRequireDefault(require("./executionContext"));
|
|
15
|
+
function extractTagsFromTitle(text) {
|
|
16
|
+
return text.match(/@\w+/g) || [];
|
|
17
|
+
}
|
|
18
|
+
function getBuiltInFixtures(bddMode) {
|
|
19
|
+
let builtInFixtures = {
|
|
20
|
+
..._page.default,
|
|
21
|
+
..._context.default,
|
|
22
|
+
..._cacheLayer.default,
|
|
23
|
+
..._i18N.default,
|
|
24
|
+
..._unauthenticatedPage.default,
|
|
25
|
+
..._executionContext.default
|
|
26
|
+
};
|
|
27
|
+
if (bddMode) {
|
|
28
|
+
builtInFixtures = {
|
|
29
|
+
...builtInFixtures,
|
|
30
|
+
..._addTags.default
|
|
31
|
+
};
|
|
32
|
+
} else {
|
|
33
|
+
builtInFixtures = {
|
|
34
|
+
...builtInFixtures,
|
|
35
|
+
$tags: async ({}, use, testInfo) => {
|
|
36
|
+
// Extract only the elements after the "@" symbol as tags
|
|
37
|
+
const tags = testInfo.title ? extractTagsFromTitle(testInfo.title) : [];
|
|
38
|
+
await use(tags);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return builtInFixtures;
|
|
43
|
+
}
|
|
44
|
+
var _default = exports.default = getBuiltInFixtures;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
exports.getCustomAccountDetails = getCustomAccountDetails;
|
|
8
|
+
var _auth = require("../helpers/auth");
|
|
9
|
+
var _readConfigFile = require("../readConfigFile");
|
|
10
|
+
/* eslint-disable global-require */
|
|
11
|
+
|
|
12
|
+
//import { additionProfiles } from '../helpers/additionalProfiles';
|
|
13
|
+
|
|
14
|
+
function getTagInputFromSelectedTags(tags, inputString) {
|
|
15
|
+
const selectedTag = [...tags].reverse().find(tag => tag.startsWith(inputString));
|
|
16
|
+
let tagInput = null;
|
|
17
|
+
if (selectedTag) {
|
|
18
|
+
tagInput = selectedTag.split(`${inputString}_`).pop().toLowerCase();
|
|
19
|
+
}
|
|
20
|
+
return tagInput;
|
|
21
|
+
}
|
|
22
|
+
function getCustomAccountDetails(tags) {
|
|
23
|
+
const tagsTobeFiltered = ['@profile', '@edition', '@beta', '@portal', '@additional_profile'];
|
|
24
|
+
const filteredTags = tags.filter(tag => tagsTobeFiltered.some(prefix => tag.startsWith(prefix)));
|
|
25
|
+
if (filteredTags && filteredTags.length > 0) {
|
|
26
|
+
const portalInfo = getTagInputFromSelectedTags(filteredTags, '@portal');
|
|
27
|
+
const betaFeature = getTagInputFromSelectedTags(filteredTags, '@beta');
|
|
28
|
+
const profileInfo = getTagInputFromSelectedTags(filteredTags, '@profile');
|
|
29
|
+
const editionInfo = getTagInputFromSelectedTags(filteredTags, '@edition');
|
|
30
|
+
const user = (0, _auth.getUserForSelectedEditionAndProfile)(editionInfo, profileInfo, betaFeature, portalInfo);
|
|
31
|
+
return user;
|
|
32
|
+
}
|
|
33
|
+
return (0, _auth.getDefaultActor)();
|
|
34
|
+
}
|
|
35
|
+
const {
|
|
36
|
+
testSetup
|
|
37
|
+
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
38
|
+
async function loginSteps(pageDetail) {
|
|
39
|
+
const {
|
|
40
|
+
page
|
|
41
|
+
} = pageDetail;
|
|
42
|
+
if (testSetup.loginSteps && typeof testSetup.loginSteps === 'function') {
|
|
43
|
+
return await testSetup.loginSteps(pageDetail);
|
|
44
|
+
} else {
|
|
45
|
+
await page.goto(process.env.domain);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async function performDefaultPageSteps(testInfo) {
|
|
49
|
+
if (testSetup.page && typeof testSetup.page === 'function') {
|
|
50
|
+
await testSetup.page(testInfo);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
async function verifyPageIsLoaded(testInfo) {
|
|
54
|
+
if (testSetup.validateLogin && typeof testSetup.validateLogin === 'function') {
|
|
55
|
+
return await testSetup.validateLogin(testInfo);
|
|
56
|
+
}
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
var _default = exports.default = {
|
|
60
|
+
page: async ({
|
|
61
|
+
context,
|
|
62
|
+
$tags,
|
|
63
|
+
page,
|
|
64
|
+
executionContext
|
|
65
|
+
}, use, testInfo) => {
|
|
66
|
+
let testPortalDetails = executionContext.actorInfo;
|
|
67
|
+
let testDetails = {
|
|
68
|
+
page,
|
|
69
|
+
$tags,
|
|
70
|
+
context,
|
|
71
|
+
...testPortalDetails
|
|
72
|
+
};
|
|
73
|
+
try {
|
|
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
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const {
|
|
80
|
+
isAuthMode
|
|
81
|
+
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
82
|
+
if (!isAuthMode) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const projectName = testInfo.project.name;
|
|
86
|
+
if (testPortalDetails && projectName !== 'setup' && projectName !== 'cleanup') {
|
|
87
|
+
await context.clearCookies();
|
|
88
|
+
await (0, _auth.performLoginSteps)(testDetails, async testInfo => {
|
|
89
|
+
return await verifyPageIsLoaded(testInfo);
|
|
90
|
+
}, loginSteps);
|
|
91
|
+
process.env.actorInfo = JSON.stringify(testPortalDetails);
|
|
92
|
+
}
|
|
93
|
+
} catch (e) {
|
|
94
|
+
console.error('Error during page', e);
|
|
95
|
+
} finally {
|
|
96
|
+
await performDefaultPageSteps(testDetails);
|
|
97
|
+
await use(page);
|
|
98
|
+
await context.close();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
};
|