@zohodesk/testinglibrary 2.9.1 → 3.0.2
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/.gitlab-ci.yml +16 -23
- package/README.md +32 -1
- package/build/core/playwright/constants/fileMutexConfig.js +11 -0
- package/build/core/playwright/fixtures.js +24 -0
- package/build/core/playwright/helpers/auth/checkAuthCookies.js +2 -8
- package/build/core/playwright/helpers/auth/loginSteps.js +25 -18
- package/build/core/playwright/helpers/checkAuthDirectory.js +17 -0
- package/build/core/playwright/helpers/fileMutex.js +58 -0
- package/build/core/playwright/index.js +10 -23
- package/build/core/playwright/setup/config-creator.js +3 -3
- package/build/core/playwright/setup/config-utils.js +8 -25
- package/build/core/playwright/test-runner.js +1 -1
- package/build/decorators.d.ts +1 -1
- package/build/decorators.js +1 -1
- package/build/setup-folder-structure/samples/actors-index.js +2 -0
- package/build/setup-folder-structure/samples/auth-setup-sample.js +14 -66
- 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/settings.json +7 -0
- package/build/setup-folder-structure/setupProject.js +18 -5
- package/build/test/core/playwright/helpers/__tests__/fileMutex.test.js +94 -0
- package/nobdd/uat/conf/default/actors/index.js +1 -4
- package/nobdd/uat/conf/default/settings.json +1 -1
- package/nobdd/uat/conf/nobdd/uat.config.js +11 -4
- package/nobdd/uat/env-config.json +3 -3
- package/nobdd/uat/fixtures/setup.teardown.js +2 -1
- package/nobdd/uat/modules/nobdd/steps/VerifyNoBDD.feature.spec.js +3 -3
- package/nobdd/uat.config.js +8 -3
- package/package.json +8 -7
- package/build/bdd-framework/cli/commands/env.js +0 -42
- package/build/bdd-framework/cli/commands/export.js +0 -62
- package/build/bdd-framework/cli/commands/test.js +0 -64
- package/build/bdd-framework/cli/index.js +0 -11
- package/build/bdd-framework/cli/options.js +0 -19
- package/build/bdd-framework/cli/worker.js +0 -13
- package/build/bdd-framework/config/configDir.js +0 -35
- package/build/bdd-framework/config/enrichReporterData.js +0 -23
- package/build/bdd-framework/config/env.js +0 -50
- package/build/bdd-framework/config/index.js +0 -94
- package/build/bdd-framework/config/lang.js +0 -14
- package/build/bdd-framework/cucumber/buildStepDefinition.js +0 -43
- package/build/bdd-framework/cucumber/createTestStep.js +0 -43
- package/build/bdd-framework/cucumber/formatter/EventDataCollector.js +0 -126
- package/build/bdd-framework/cucumber/formatter/GherkinDocumentParser.js +0 -72
- package/build/bdd-framework/cucumber/formatter/PickleParser.js +0 -25
- package/build/bdd-framework/cucumber/formatter/durationHelpers.js +0 -13
- package/build/bdd-framework/cucumber/formatter/getColorFns.js +0 -57
- package/build/bdd-framework/cucumber/formatter/index.js +0 -16
- package/build/bdd-framework/cucumber/formatter/locationHelpers.js +0 -16
- package/build/bdd-framework/cucumber/loadConfig.js +0 -17
- package/build/bdd-framework/cucumber/loadFeatures.js +0 -70
- package/build/bdd-framework/cucumber/loadSnippetBuilder.js +0 -20
- package/build/bdd-framework/cucumber/loadSteps.js +0 -47
- package/build/bdd-framework/cucumber/resolveFeaturePaths.js +0 -62
- package/build/bdd-framework/cucumber/stepArguments.js +0 -21
- package/build/bdd-framework/cucumber/types.js +0 -5
- package/build/bdd-framework/cucumber/valueChecker.js +0 -23
- package/build/bdd-framework/decorators.js +0 -18
- package/build/bdd-framework/gen/fixtures.js +0 -48
- package/build/bdd-framework/gen/formatter.js +0 -167
- package/build/bdd-framework/gen/i18n.js +0 -39
- package/build/bdd-framework/gen/index.js +0 -197
- package/build/bdd-framework/gen/specialTags.js +0 -70
- package/build/bdd-framework/gen/testFile.js +0 -470
- package/build/bdd-framework/gen/testMeta.js +0 -60
- package/build/bdd-framework/gen/testNode.js +0 -35
- package/build/bdd-framework/gen/testPoms.js +0 -133
- package/build/bdd-framework/hooks/scenario.js +0 -130
- package/build/bdd-framework/hooks/worker.js +0 -89
- package/build/bdd-framework/index.js +0 -52
- package/build/bdd-framework/playwright/fixtureParameterNames.js +0 -93
- package/build/bdd-framework/playwright/getLocationInFile.js +0 -79
- package/build/bdd-framework/playwright/loadConfig.js +0 -42
- package/build/bdd-framework/playwright/loadUtils.js +0 -33
- package/build/bdd-framework/playwright/testTypeImpl.js +0 -79
- package/build/bdd-framework/playwright/transform.js +0 -88
- package/build/bdd-framework/playwright/types.js +0 -12
- package/build/bdd-framework/playwright/utils.js +0 -56
- package/build/bdd-framework/reporter/cucumber/base.js +0 -52
- package/build/bdd-framework/reporter/cucumber/custom.js +0 -73
- package/build/bdd-framework/reporter/cucumber/helper.js +0 -12
- package/build/bdd-framework/reporter/cucumber/html.js +0 -40
- package/build/bdd-framework/reporter/cucumber/index.js +0 -74
- package/build/bdd-framework/reporter/cucumber/json.js +0 -312
- package/build/bdd-framework/reporter/cucumber/junit.js +0 -205
- package/build/bdd-framework/reporter/cucumber/message.js +0 -20
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/AttachmentMapper.js +0 -82
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Builder.js +0 -197
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/GherkinDocument.js +0 -43
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/GherkinDocumentClone.js +0 -52
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/GherkinDocuments.js +0 -105
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Hook.js +0 -70
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Meta.js +0 -45
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Pickles.js +0 -27
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Projects.js +0 -38
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestCase.js +0 -128
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestCaseRun.js +0 -154
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestCaseRunHooks.js +0 -123
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestStepAttachments.js +0 -67
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestStepRun.js +0 -114
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/index.js +0 -30
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/pwStepUtils.js +0 -70
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/timing.js +0 -35
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/types.js +0 -5
- package/build/bdd-framework/run/StepInvoker.js +0 -69
- package/build/bdd-framework/run/bddData/index.js +0 -59
- package/build/bdd-framework/run/bddData/types.js +0 -5
- package/build/bdd-framework/run/bddFixtures.js +0 -192
- package/build/bdd-framework/run/bddWorld.js +0 -79
- package/build/bdd-framework/run/bddWorldInternal.js +0 -11
- package/build/bdd-framework/snippets/index.js +0 -132
- package/build/bdd-framework/snippets/snippetSyntax.js +0 -43
- package/build/bdd-framework/snippets/snippetSyntaxDecorators.js +0 -26
- package/build/bdd-framework/snippets/snippetSyntaxTs.js +0 -18
- package/build/bdd-framework/stepDefinitions/createBdd.js +0 -66
- package/build/bdd-framework/stepDefinitions/decorators/class.js +0 -68
- package/build/bdd-framework/stepDefinitions/decorators/steps.js +0 -99
- package/build/bdd-framework/stepDefinitions/defineStep.js +0 -62
- package/build/bdd-framework/stepDefinitions/stepConfig.js +0 -24
- package/build/bdd-framework/steps/createBdd.js +0 -78
- package/build/bdd-framework/steps/decorators/class.js +0 -68
- package/build/bdd-framework/steps/decorators/steps.js +0 -98
- package/build/bdd-framework/steps/defineStep.js +0 -62
- package/build/bdd-framework/steps/stepConfig.js +0 -24
- package/build/bdd-framework/utils/AutofillMap.js +0 -20
- package/build/bdd-framework/utils/exit.js +0 -62
- package/build/bdd-framework/utils/index.js +0 -93
- package/build/bdd-framework/utils/jsStringWrap.js +0 -44
- package/build/bdd-framework/utils/logger.js +0 -30
- package/build/bdd-framework/utils/stripAnsiEscapes.js +0 -20
- package/build/setup-folder-structure/samples/authUsers-sample.json +0 -9
- package/build/setup-folder-structure/samples/env-config-sample.json +0 -21
- package/nobdd/uat/conf/default/actors/beta/custom-module.json +0 -24
- package/nobdd/uat/conf/default/actors/beta/index.js +0 -6
- package/nobdd/uat/conf/default/actors/beta/parent-child.json +0 -24
- package/npm-shrinkwrap.json +0 -6475
package/.gitlab-ci.yml
CHANGED
|
@@ -1,29 +1,35 @@
|
|
|
1
|
-
image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:
|
|
1
|
+
image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v3
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
workflow:
|
|
4
|
+
rules:
|
|
5
|
+
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
|
6
|
+
when: always
|
|
7
|
+
- if: $CI_PIPELINE_SOURCE == "web"
|
|
8
|
+
when: always
|
|
6
9
|
|
|
7
10
|
stages:
|
|
8
11
|
- build
|
|
9
12
|
- unit
|
|
10
13
|
- uat
|
|
11
14
|
|
|
15
|
+
default:
|
|
16
|
+
cache:
|
|
17
|
+
key: build-cache
|
|
18
|
+
paths:
|
|
19
|
+
- node_modules
|
|
20
|
+
- build
|
|
21
|
+
|
|
12
22
|
# Install dependencies stage
|
|
13
23
|
build:
|
|
14
24
|
stage: build
|
|
15
|
-
image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v2
|
|
16
25
|
script:
|
|
26
|
+
- npm install --ignore-scripts
|
|
27
|
+
- npm run build
|
|
17
28
|
- npm install
|
|
18
|
-
artifacts:
|
|
19
|
-
paths:
|
|
20
|
-
- node_modules/
|
|
21
|
-
|
|
22
29
|
|
|
23
30
|
# Unit tests stage
|
|
24
31
|
unit:
|
|
25
32
|
stage: unit
|
|
26
|
-
image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v2
|
|
27
33
|
script:
|
|
28
34
|
- npm run test
|
|
29
35
|
artifacts:
|
|
@@ -34,10 +40,7 @@ unit:
|
|
|
34
40
|
# UAT tests stage
|
|
35
41
|
uat-auth:
|
|
36
42
|
stage: uat
|
|
37
|
-
image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v2
|
|
38
43
|
script:
|
|
39
|
-
- npm install
|
|
40
|
-
- npm run build
|
|
41
44
|
- cd examples
|
|
42
45
|
- npm install $(npm pack ../../testing-framework | tail -1)
|
|
43
46
|
- output=$(npm run uatauth)
|
|
@@ -53,10 +56,7 @@ uat-auth:
|
|
|
53
56
|
|
|
54
57
|
uat-noauth:
|
|
55
58
|
stage: uat
|
|
56
|
-
image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v2
|
|
57
59
|
script:
|
|
58
|
-
- npm install
|
|
59
|
-
- npm run build
|
|
60
60
|
- cd examples
|
|
61
61
|
- npm install $(npm pack ../../testing-framework | tail -1)
|
|
62
62
|
- output=$(npm run uatnoauth)
|
|
@@ -72,10 +72,7 @@ uat-noauth:
|
|
|
72
72
|
|
|
73
73
|
uat-profile:
|
|
74
74
|
stage: uat
|
|
75
|
-
image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v2
|
|
76
75
|
script:
|
|
77
|
-
- npm install
|
|
78
|
-
- npm run build
|
|
79
76
|
- cd examples
|
|
80
77
|
- npm install $(npm pack ../../testing-framework | tail -1)
|
|
81
78
|
- output=$(npm run uatprofile)
|
|
@@ -91,10 +88,7 @@ uat-profile:
|
|
|
91
88
|
|
|
92
89
|
uat-nobdd:
|
|
93
90
|
stage: uat
|
|
94
|
-
image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v2
|
|
95
91
|
script:
|
|
96
|
-
- npm install
|
|
97
|
-
- npm run build
|
|
98
92
|
- cd nobdd
|
|
99
93
|
- npm install $(npm pack ../../testing-framework | tail -1)
|
|
100
94
|
- output=$(npm run uatnobdd)
|
|
@@ -108,4 +102,3 @@ uat-nobdd:
|
|
|
108
102
|
when: always
|
|
109
103
|
paths:
|
|
110
104
|
- nobdd/uat/playwright-report
|
|
111
|
-
|
package/README.md
CHANGED
|
@@ -26,15 +26,46 @@
|
|
|
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
|
-
|
|
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
|
|
40
|
+
|
|
41
|
+
### v0.3.0 - 25-10-2024
|
|
42
|
+
|
|
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.
|
|
36
62
|
|
|
37
63
|
### v0.2.9.1 - 14-11-2024
|
|
38
64
|
|
|
39
65
|
#### Enhancement
|
|
40
66
|
- Beta feature Actors and edition configurations are unified
|
|
67
|
+
|
|
68
|
+
### v0.2.9.2 - 22-11-2024
|
|
69
|
+
|
|
70
|
+
#### BugFix
|
|
71
|
+
- Implemented synchronization for the login process. This fix will help avoid login session-related failures in UAT.
|
|
@@ -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
|
+
};
|
|
@@ -10,6 +10,7 @@ exports.verifyIfCookieFileExists = verifyIfCookieFileExists;
|
|
|
10
10
|
var _path = _interopRequireDefault(require("path"));
|
|
11
11
|
var _fs = require("fs");
|
|
12
12
|
var _readConfigFile = require("../../readConfigFile");
|
|
13
|
+
var _checkAuthDirectory = require("../checkAuthDirectory");
|
|
13
14
|
var _logger = require("../../../../utils/logger");
|
|
14
15
|
/* eslint-disable no-console */
|
|
15
16
|
|
|
@@ -23,13 +24,7 @@ function getAuthFileDirectory() {
|
|
|
23
24
|
return _path.default.resolve(_path.default.join(uatDirectory, 'playwright', '.auth'));
|
|
24
25
|
}
|
|
25
26
|
function verifyIfCookieFileExists(authFile) {
|
|
26
|
-
|
|
27
|
-
if (!(0, _fs.existsSync)(authDirectory)) {
|
|
28
|
-
console.log('Creating auth directory for the first time setup...');
|
|
29
|
-
(0, _fs.mkdirSync)(authDirectory, {
|
|
30
|
-
recursive: true
|
|
31
|
-
});
|
|
32
|
-
}
|
|
27
|
+
(0, _checkAuthDirectory.createAuthDirectoryIfNotExist)();
|
|
33
28
|
if (!(0, _fs.existsSync)(authFile)) {
|
|
34
29
|
console.log('creating auth file..');
|
|
35
30
|
(0, _fs.writeFileSync)(authFile, JSON.stringify(authContent, null, 2));
|
|
@@ -41,7 +36,6 @@ function convertCookiesToParse(cookies, authFilePath) {
|
|
|
41
36
|
} catch (err) {
|
|
42
37
|
_logger.Logger.error(err);
|
|
43
38
|
throw new Error(` Error while parsing cookies ${err} \n${_path.default.resolve(process.cwd(), authFilePath)} File is Empty`);
|
|
44
|
-
// process.exit()
|
|
45
39
|
}
|
|
46
40
|
}
|
|
47
41
|
async function loadCookiesIfPresent(page, authFile) {
|
|
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _path = _interopRequireDefault(require("path"));
|
|
9
|
+
var _fileMutex = _interopRequireDefault(require("../fileMutex"));
|
|
10
|
+
var _fileMutexConfig = require("../../constants/fileMutexConfig");
|
|
9
11
|
var _accountLogin = _interopRequireDefault(require("./accountLogin"));
|
|
10
12
|
var _checkAuthCookies = require("./checkAuthCookies");
|
|
11
13
|
/* eslint-disable no-console */
|
|
@@ -17,25 +19,30 @@ async function performLoginSteps({
|
|
|
17
19
|
password
|
|
18
20
|
}, isLoggedIn) {
|
|
19
21
|
const authFile = _path.default.resolve(_path.default.join((0, _checkAuthCookies.getAuthFileDirectory)(), `${authFilePrefix}-cookies.json`));
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// await page.waitForLoadState('networkidle')
|
|
26
|
-
|
|
27
|
-
await Promise.race([page.waitForNavigation(), page.waitForLoadState('networkidle'), page.waitForTimeout(5000)]);
|
|
28
|
-
const loginStatus = await isLoggedIn(page);
|
|
29
|
-
if (!loginStatus) {
|
|
30
|
-
await (0, _accountLogin.default)(page, useremail, password);
|
|
22
|
+
const lockFileName = useremail.replace(/[@.]/g, '_');
|
|
23
|
+
const fileMutex = new _fileMutex.default((0, _checkAuthCookies.getAuthFileDirectory)(), lockFileName, _fileMutexConfig.LOGIN_MUTEX_TIMEOUT);
|
|
24
|
+
try {
|
|
25
|
+
await fileMutex.acquire();
|
|
26
|
+
await (0, _checkAuthCookies.loadCookiesIfPresent)(page, authFile);
|
|
31
27
|
await page.goto(process.env.domain);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
28
|
+
await Promise.race([page.waitForNavigation(), page.waitForLoadState('networkidle'), page.waitForTimeout(5000)]);
|
|
29
|
+
const isAlreadyLoggedIn = await isLoggedIn(page);
|
|
30
|
+
if (!isAlreadyLoggedIn) {
|
|
31
|
+
await (0, _accountLogin.default)(page, useremail, password);
|
|
32
|
+
await page.goto(process.env.domain);
|
|
33
|
+
await isLoggedIn(page);
|
|
34
|
+
await page.context().storageState({
|
|
35
|
+
path: authFile
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
} catch (error) {
|
|
39
|
+
console.error(`Error during login for ${useremail}:`, error);
|
|
40
|
+
} finally {
|
|
41
|
+
try {
|
|
42
|
+
await fileMutex.release();
|
|
43
|
+
} catch (releaseError) {
|
|
44
|
+
console.error(`Error releasing lock for ${useremail}:`, releaseError);
|
|
45
|
+
}
|
|
39
46
|
}
|
|
40
47
|
}
|
|
41
48
|
var _default = exports.default = performLoginSteps;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createAuthDirectoryIfNotExist = createAuthDirectoryIfNotExist;
|
|
7
|
+
var _fs = require("fs");
|
|
8
|
+
var _checkAuthCookies = require("./auth/checkAuthCookies");
|
|
9
|
+
function createAuthDirectoryIfNotExist() {
|
|
10
|
+
const authDirectory = (0, _checkAuthCookies.getAuthFileDirectory)();
|
|
11
|
+
if (!(0, _fs.existsSync)(authDirectory)) {
|
|
12
|
+
console.log('Creating auth directory for the first time setup...');
|
|
13
|
+
(0, _fs.mkdirSync)(authDirectory, {
|
|
14
|
+
recursive: true
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
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 _path = _interopRequireDefault(require("path"));
|
|
9
|
+
var _lockfile = _interopRequireDefault(require("lockfile"));
|
|
10
|
+
var _fs = require("fs");
|
|
11
|
+
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
|
12
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
13
|
+
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
|
14
|
+
var _getLockFilePath = /*#__PURE__*/new WeakSet();
|
|
15
|
+
var _createDirectoryIfNotExist = /*#__PURE__*/new WeakSet();
|
|
16
|
+
class FileMutex {
|
|
17
|
+
constructor(directory, lockFileName, timeout) {
|
|
18
|
+
_classPrivateMethodInitSpec(this, _createDirectoryIfNotExist);
|
|
19
|
+
_classPrivateMethodInitSpec(this, _getLockFilePath);
|
|
20
|
+
this.directory = directory;
|
|
21
|
+
this.lockFileName = lockFileName;
|
|
22
|
+
this.timeout = timeout;
|
|
23
|
+
}
|
|
24
|
+
async acquire() {
|
|
25
|
+
_classPrivateMethodGet(this, _createDirectoryIfNotExist, _createDirectoryIfNotExist2).call(this);
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
_lockfile.default.lock(_classPrivateMethodGet(this, _getLockFilePath, _getLockFilePath2).call(this), this.timeout, err => {
|
|
28
|
+
if (err) {
|
|
29
|
+
reject(err);
|
|
30
|
+
} else {
|
|
31
|
+
resolve();
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
async release() {
|
|
37
|
+
return new Promise((resolve, reject) => {
|
|
38
|
+
_lockfile.default.unlock(_classPrivateMethodGet(this, _getLockFilePath, _getLockFilePath2).call(this), err => {
|
|
39
|
+
if (err) {
|
|
40
|
+
reject(err);
|
|
41
|
+
} else {
|
|
42
|
+
resolve();
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function _getLockFilePath2() {
|
|
49
|
+
return _path.default.resolve(_path.default.join(this.directory, `/${this.lockFileName}.lock`));
|
|
50
|
+
}
|
|
51
|
+
function _createDirectoryIfNotExist2() {
|
|
52
|
+
if (!(0, _fs.existsSync)(this.directory)) {
|
|
53
|
+
(0, _fs.mkdirSync)(this.directory, {
|
|
54
|
+
recursive: true
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
var _default = exports.default = FileMutex;
|
|
@@ -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
|
-
|
|
6
|
+
exports.createBdd = void 0;
|
|
7
|
+
Object.defineProperty(exports, "expect", {
|
|
8
8
|
enumerable: true,
|
|
9
9
|
get: function () {
|
|
10
|
-
return
|
|
10
|
+
return _test.expect;
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
|
-
Object.defineProperty(exports, "
|
|
13
|
+
Object.defineProperty(exports, "test", {
|
|
14
14
|
enumerable: true,
|
|
15
15
|
get: function () {
|
|
16
|
-
return
|
|
16
|
+
return _playwrightBdd.test;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
|
-
|
|
20
|
-
var _bddFramework = require("../../bdd-framework");
|
|
19
|
+
var _playwrightBdd = require("playwright-bdd");
|
|
21
20
|
var _test = require("@playwright/test");
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
|
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
|
|
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
|
|
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,
|
|
152
|
-
|
|
153
|
-
|
|
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
|
}
|
|
@@ -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(
|
|
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');
|
package/build/decorators.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from '
|
|
1
|
+
export * from 'playwright-bdd/decorators';
|
package/build/decorators.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
var _decorators = require("
|
|
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;
|
|
@@ -1,73 +1,21 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
2
|
import { test as setup, expect } from '@zohodesk/testinglibrary';
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import {
|
|
4
|
+
performLoginSteps,
|
|
5
|
+
getDefaultActor
|
|
6
|
+
} from '@zohodesk/testinglibrary/helpers';
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const user = getDefaultActor();
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
});
|
|
18
|
+
//Implement performLoginSteps here
|
|
19
|
+
const { email, password } = user;
|
|
20
|
+
await performLoginSteps({ },verifyPageIsLoaded );
|
|
21
|
+
});
|
|
@@ -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
|
+
|