@zohodesk/testinglibrary 2.9.2 → 2.9.4
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 +21 -0
- package/build/bdd-framework/cucumber/formatter/EventDataCollector.js +1 -1
- package/build/bdd-framework/reporter/cucumber/json.js +1 -1
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Meta.js +1 -1
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestStepAttachments.js +1 -1
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestStepRun.js +1 -1
- package/build/core/playwright/builtInFixtures/page.js +7 -0
- package/build/core/playwright/constants/fileMutexConfig.js +7 -3
- package/build/core/playwright/helpers/auth/loginSteps.js +2 -1
- package/build/core/playwright/helpers/checkAuthDirectory.js +10 -0
- package/build/core/playwright/helpers/fileMutex.js +28 -33
- 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/tagProcessor.js +18 -28
- package/build/core/playwright/test-runner.js +8 -34
- package/build/test/core/playwright/helpers/__tests__/fileMutex.test.js +45 -68
- 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/package.json +2 -2
- package/nobdd/README.md +0 -1
- package/nobdd/package.json +0 -17
- package/nobdd/src/App.js +0 -7
- package/nobdd/uat/conf/default/actors/editions/enterprise.json +0 -24
- package/nobdd/uat/conf/default/actors/editions/index.js +0 -4
- package/nobdd/uat/conf/default/actors/index.js +0 -2
- package/nobdd/uat/conf/default/settings.json +0 -6
- package/nobdd/uat/conf/nobdd/uat.config.js +0 -36
- package/nobdd/uat/env-config.json +0 -20
- package/nobdd/uat/fixtures/auth.setup.js +0 -44
- package/nobdd/uat/fixtures/setup.teardown.js +0 -33
- package/nobdd/uat/modules/nobdd/steps/VerifyNoBDD.feature.spec.js +0 -16
- package/nobdd/uat/shared/commands/_index-custom-fixtures.js +0 -9
- package/nobdd/uat/shared/commands/i18n.js +0 -25
- package/nobdd/uat/shared/commands/unauthenticatedPage.js +0 -8
- package/nobdd/uat/shared/index.js +0 -7
- package/nobdd/uat/shared/onboardings/onboardingUpdate.js +0 -44
- package/nobdd/uat/shared/url-helpers/getUrlOrigin.js +0 -6
- package/nobdd/uat.config.js +0 -36
package/.gitlab-ci.yml
CHANGED
|
@@ -86,6 +86,27 @@ uat-profile:
|
|
|
86
86
|
paths:
|
|
87
87
|
- examples/uat/playwright-report
|
|
88
88
|
|
|
89
|
+
|
|
90
|
+
uat-unauth:
|
|
91
|
+
stage: uat
|
|
92
|
+
image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v2
|
|
93
|
+
script:
|
|
94
|
+
- npm install
|
|
95
|
+
- npm run build
|
|
96
|
+
- cd examples
|
|
97
|
+
- npm install $(npm pack ../../testing-framework | tail -1)
|
|
98
|
+
- output=$(npm run uatunauth)
|
|
99
|
+
- echo "$output"
|
|
100
|
+
- if [[ "$output" == *"failed"* ]]; then
|
|
101
|
+
- exit 1
|
|
102
|
+
- fi
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
artifacts:
|
|
106
|
+
when: always
|
|
107
|
+
paths:
|
|
108
|
+
- examples/uat/playwright-report
|
|
109
|
+
|
|
89
110
|
uat-nobdd:
|
|
90
111
|
stage: uat
|
|
91
112
|
script:
|
|
@@ -7,7 +7,7 @@ exports.default = void 0;
|
|
|
7
7
|
var messages = _interopRequireWildcard(require("@cucumber/messages"));
|
|
8
8
|
var _valueChecker = require("../valueChecker");
|
|
9
9
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
10
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
10
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
11
11
|
/**
|
|
12
12
|
* Groups Cucumber messages for easier access.
|
|
13
13
|
* Based on Cucumber, with some changes due to strictNullChecks errors.
|
|
@@ -16,7 +16,7 @@ var _locationHelpers = require("../../cucumber/formatter/locationHelpers");
|
|
|
16
16
|
var _GherkinDocument = require("./messagesBuilder/GherkinDocument");
|
|
17
17
|
var _Projects = require("./messagesBuilder/Projects");
|
|
18
18
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
19
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
19
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
20
20
|
/**
|
|
21
21
|
* Cucumber json reporter.
|
|
22
22
|
* Based on: https://github.com/cucumber/cucumber-js/blob/main/src/formatter/json_formatter.ts
|
|
@@ -9,7 +9,7 @@ var _os = _interopRequireDefault(require("os"));
|
|
|
9
9
|
var messages = _interopRequireWildcard(require("@cucumber/messages"));
|
|
10
10
|
var _utils = require("../../../utils");
|
|
11
11
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
12
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
12
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
13
|
/**
|
|
14
14
|
* Builds meta message.
|
|
15
15
|
* See: https://github.com/cucumber/cucumber-js/blob/main/src/cli/helpers.ts#L100
|
|
@@ -9,7 +9,7 @@ var _fs = _interopRequireDefault(require("fs"));
|
|
|
9
9
|
var messages = _interopRequireWildcard(require("@cucumber/messages"));
|
|
10
10
|
var _path = _interopRequireDefault(require("path"));
|
|
11
11
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
12
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
12
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
13
|
/**
|
|
14
14
|
* Class for getting attachment messages for a particular step.
|
|
15
15
|
*/
|
|
@@ -9,7 +9,7 @@ var _stripAnsiEscapes = require("../../../utils/stripAnsiEscapes");
|
|
|
9
9
|
var _timing = require("./timing");
|
|
10
10
|
var _TestStepAttachments = require("./TestStepAttachments");
|
|
11
11
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
12
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
12
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
13
|
class TestStepRun {
|
|
14
14
|
testCaseRun;
|
|
15
15
|
testStep;
|
|
@@ -70,6 +70,13 @@ var _default = exports.default = {
|
|
|
70
70
|
await use(page);
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
|
+
|
|
74
|
+
//This block is used to skip the login process if the @unauthenticated tag is added to the script
|
|
75
|
+
if ($tags.includes('@unauthenticated')) {
|
|
76
|
+
await context.clearCookies();
|
|
77
|
+
await use(page);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
73
80
|
const testPortalDetails = getCustomAccountDetails($tags);
|
|
74
81
|
if (testPortalDetails === null) {
|
|
75
82
|
await performDefaultPageSteps({
|
|
@@ -5,7 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.LOGIN_MUTEX_TIMEOUT = void 0;
|
|
7
7
|
const LOGIN_MUTEX_TIMEOUT = exports.LOGIN_MUTEX_TIMEOUT = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
stale: 100000,
|
|
9
|
+
retries: {
|
|
10
|
+
retries: 10,
|
|
11
|
+
factor: 1,
|
|
12
|
+
minTimeout: 10000,
|
|
13
|
+
maxTimeout: 20000
|
|
14
|
+
}
|
|
11
15
|
};
|
|
@@ -10,6 +10,7 @@ var _fileMutex = _interopRequireDefault(require("../fileMutex"));
|
|
|
10
10
|
var _fileMutexConfig = require("../../constants/fileMutexConfig");
|
|
11
11
|
var _accountLogin = _interopRequireDefault(require("./accountLogin"));
|
|
12
12
|
var _checkAuthCookies = require("./checkAuthCookies");
|
|
13
|
+
var _checkAuthDirectory = require("../checkAuthDirectory");
|
|
13
14
|
/* eslint-disable no-console */
|
|
14
15
|
|
|
15
16
|
async function performLoginSteps({
|
|
@@ -20,7 +21,7 @@ async function performLoginSteps({
|
|
|
20
21
|
}, isLoggedIn) {
|
|
21
22
|
const authFile = _path.default.resolve(_path.default.join((0, _checkAuthCookies.getAuthFileDirectory)(), `${authFilePrefix}-cookies.json`));
|
|
22
23
|
const lockFileName = useremail.replace(/[@.]/g, '_');
|
|
23
|
-
const fileMutex = new _fileMutex.default((0,
|
|
24
|
+
const fileMutex = new _fileMutex.default((0, _checkAuthDirectory.getLockDirectoryPath)(), lockFileName, _fileMutexConfig.LOGIN_MUTEX_TIMEOUT);
|
|
24
25
|
try {
|
|
25
26
|
await fileMutex.acquire();
|
|
26
27
|
await (0, _checkAuthCookies.loadCookiesIfPresent)(page, authFile);
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.createAuthDirectoryIfNotExist = createAuthDirectoryIfNotExist;
|
|
8
|
+
exports.getLockDirectoryPath = getLockDirectoryPath;
|
|
7
9
|
var _fs = require("fs");
|
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
|
8
11
|
var _checkAuthCookies = require("./auth/checkAuthCookies");
|
|
12
|
+
var _readConfigFile = require("../readConfigFile");
|
|
9
13
|
function createAuthDirectoryIfNotExist() {
|
|
10
14
|
const authDirectory = (0, _checkAuthCookies.getAuthFileDirectory)();
|
|
11
15
|
if (!(0, _fs.existsSync)(authDirectory)) {
|
|
@@ -14,4 +18,10 @@ function createAuthDirectoryIfNotExist() {
|
|
|
14
18
|
recursive: true
|
|
15
19
|
});
|
|
16
20
|
}
|
|
21
|
+
}
|
|
22
|
+
function getLockDirectoryPath() {
|
|
23
|
+
const {
|
|
24
|
+
uatDirectory
|
|
25
|
+
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
26
|
+
return _path.default.resolve(_path.default.join(uatDirectory, 'playwright', '.lock'));
|
|
17
27
|
}
|
|
@@ -6,49 +6,44 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _path = _interopRequireDefault(require("path"));
|
|
9
|
-
var
|
|
9
|
+
var _properLockfile = _interopRequireDefault(require("proper-lockfile"));
|
|
10
10
|
var _fs = require("fs");
|
|
11
|
-
function _classPrivateMethodInitSpec(
|
|
12
|
-
function _checkPrivateRedeclaration(
|
|
13
|
-
function
|
|
14
|
-
var
|
|
15
|
-
var _createDirectoryIfNotExist = /*#__PURE__*/new WeakSet();
|
|
11
|
+
function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
|
|
12
|
+
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
|
|
13
|
+
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
|
14
|
+
var _FileMutex_brand = /*#__PURE__*/new WeakSet();
|
|
16
15
|
class FileMutex {
|
|
17
|
-
constructor(directory, lockFileName,
|
|
18
|
-
_classPrivateMethodInitSpec(this,
|
|
19
|
-
_classPrivateMethodInitSpec(this, _getLockFilePath);
|
|
16
|
+
constructor(directory, lockFileName, options = {}) {
|
|
17
|
+
_classPrivateMethodInitSpec(this, _FileMutex_brand);
|
|
20
18
|
this.directory = directory;
|
|
21
|
-
this.lockFileName = lockFileName;
|
|
22
|
-
this.
|
|
19
|
+
this.lockFileName = lockFileName + ".lock";
|
|
20
|
+
this.options = options;
|
|
23
21
|
}
|
|
24
22
|
async acquire() {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
23
|
+
_assertClassBrand(_FileMutex_brand, this, _createDirectoryIfNotExist).call(this);
|
|
24
|
+
const lockFilePath = _path.default.resolve(this.directory, this.lockFileName);
|
|
25
|
+
try {
|
|
26
|
+
if (!(0, _fs.existsSync)(lockFilePath)) {
|
|
27
|
+
console.log(`[DEBUG] Creating missing lock file:`, this.lockFileName);
|
|
28
|
+
(0, _fs.writeFileSync)(lockFilePath, 'locked');
|
|
29
|
+
}
|
|
30
|
+
await _properLockfile.default.lock(_assertClassBrand(_FileMutex_brand, this, _getLockFilePath).call(this), this.options);
|
|
31
|
+
} catch (err) {
|
|
32
|
+
throw new Error(`Failed to acquire lock after ${this.options.retries.retries} attempts: ${err.message}`);
|
|
33
|
+
}
|
|
35
34
|
}
|
|
36
35
|
async release() {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
resolve();
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
});
|
|
36
|
+
try {
|
|
37
|
+
await _properLockfile.default.unlock(_assertClassBrand(_FileMutex_brand, this, _getLockFilePath).call(this));
|
|
38
|
+
} catch (err) {
|
|
39
|
+
throw new Error(`Failed to release lock: ${err.message}`);
|
|
40
|
+
}
|
|
46
41
|
}
|
|
47
42
|
}
|
|
48
|
-
function
|
|
49
|
-
return _path.default.resolve(_path.default.join(this.directory,
|
|
43
|
+
function _getLockFilePath() {
|
|
44
|
+
return _path.default.resolve(_path.default.join(this.directory, this.lockFileName));
|
|
50
45
|
}
|
|
51
|
-
function
|
|
46
|
+
function _createDirectoryIfNotExist() {
|
|
52
47
|
if (!(0, _fs.existsSync)(this.directory)) {
|
|
53
48
|
(0, _fs.mkdirSync)(this.directory, {
|
|
54
49
|
recursive: true
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
class Runner {
|
|
4
|
+
constructor(config) {
|
|
5
|
+
this.tagArgs = "";
|
|
6
|
+
this.userArgs = "";
|
|
7
|
+
this.config = config;
|
|
8
|
+
}
|
|
9
|
+
setUserArgs(userArgs) {
|
|
10
|
+
this.userArgs = userArgs;
|
|
11
|
+
}
|
|
12
|
+
setTagArgs(tagArgs) {
|
|
13
|
+
this.tagArgs = tagArgs;
|
|
14
|
+
}
|
|
15
|
+
setConfig(config) {
|
|
16
|
+
this.config = config;
|
|
17
|
+
}
|
|
18
|
+
run() {
|
|
19
|
+
throw new Error("Method 'run()' must be implemented.");
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
module.exports = Runner;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _RunnerTypes = _interopRequireDefault(require("./RunnerTypes"));
|
|
9
|
+
var _configUtils = require("../setup/config-utils");
|
|
10
|
+
var _cliArgsToObject = require("../../../utils/cliArgsToObject");
|
|
11
|
+
var _browserTypes = require("../constants/browserTypes");
|
|
12
|
+
var _customCommands = require("../custom-commands");
|
|
13
|
+
class RunnerHelper {
|
|
14
|
+
static createRunner(type, runnerObj) {
|
|
15
|
+
const runnerClass = _RunnerTypes.default.getRunnerClass(type, runnerObj);
|
|
16
|
+
if (!runnerClass) {
|
|
17
|
+
throw new Error("Invalid runner type");
|
|
18
|
+
}
|
|
19
|
+
return runnerClass;
|
|
20
|
+
}
|
|
21
|
+
static getPlaywrightArgs(userArgsObject, debug, bddMode, tagArgs, headless) {
|
|
22
|
+
const {
|
|
23
|
+
browsers = null
|
|
24
|
+
} = userArgsObject;
|
|
25
|
+
let browserList = (0, _configUtils.getBrowsersList)(browsers);
|
|
26
|
+
const playwrightArgs = (0, _cliArgsToObject.objectToCliArgs)(userArgsObject, key => !_customCommands.CUSTOM_COMMANDS.includes(key));
|
|
27
|
+
if (debug) {
|
|
28
|
+
playwrightArgs.push('--debug');
|
|
29
|
+
}
|
|
30
|
+
if (!bddMode && tagArgs) {
|
|
31
|
+
playwrightArgs.push('--grep');
|
|
32
|
+
playwrightArgs.push(tagArgs);
|
|
33
|
+
}
|
|
34
|
+
if (!headless && !userArgsObject.headed) {
|
|
35
|
+
playwrightArgs.push('--headed');
|
|
36
|
+
}
|
|
37
|
+
if (browserList && browserList.length > 0) {
|
|
38
|
+
browserList.map(browser => playwrightArgs.push(`--project=${_browserTypes.BROWSER_PROJECT_MAPPING[browser.toUpperCase()]}`));
|
|
39
|
+
}
|
|
40
|
+
return playwrightArgs;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
var _default = exports.default = RunnerHelper;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _SpawnRunner = _interopRequireDefault(require("./SpawnRunner"));
|
|
5
|
+
class RunnerTypes {
|
|
6
|
+
static getRunnerClass(type, runnerObj) {
|
|
7
|
+
const RunnerClass = this.runnerTypes[type];
|
|
8
|
+
if (!RunnerClass) {
|
|
9
|
+
throw new Error("Invalid runner type");
|
|
10
|
+
}
|
|
11
|
+
return new RunnerClass(runnerObj);
|
|
12
|
+
}
|
|
13
|
+
static runnerTypes = {
|
|
14
|
+
spawn: _SpawnRunner.default //require("./SpawnRunner"), // used lazy loading to reduce circular dependencies
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
module.exports = RunnerTypes;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _readConfigFile = require("../readConfigFile");
|
|
5
|
+
var _rootPath = require("../../../utils/rootPath");
|
|
6
|
+
var _path = _interopRequireDefault(require("path"));
|
|
7
|
+
var _logger = require("../../../utils/logger");
|
|
8
|
+
var _child_process = require("child_process");
|
|
9
|
+
var _RunnerHelper = _interopRequireDefault(require("./RunnerHelper"));
|
|
10
|
+
var _Runner = _interopRequireDefault(require("./Runner"));
|
|
11
|
+
class SpawnRunner extends _Runner.default {
|
|
12
|
+
constructor(runnerObj) {
|
|
13
|
+
super(runnerObj);
|
|
14
|
+
this.runnerObj = runnerObj;
|
|
15
|
+
}
|
|
16
|
+
run() {
|
|
17
|
+
const {
|
|
18
|
+
config
|
|
19
|
+
} = this.runnerObj;
|
|
20
|
+
let promises = [];
|
|
21
|
+
const {
|
|
22
|
+
bddMode
|
|
23
|
+
} = config.getAll();
|
|
24
|
+
if (bddMode) {
|
|
25
|
+
promises.push(this.runPreprocessing());
|
|
26
|
+
}
|
|
27
|
+
Promise.all(promises).then(() => this.runPlaywright()).catch(err => {
|
|
28
|
+
_logger.Logger.error(err);
|
|
29
|
+
process.exit();
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
runPreprocessing() {
|
|
33
|
+
const {
|
|
34
|
+
tagArgs
|
|
35
|
+
} = this.runnerObj;
|
|
36
|
+
const configPath = (0, _readConfigFile.isUserConfigFileAvailable)() ? _path.default.resolve(__dirname, '../', 'setup', 'config-creator.js') : _path.default.resolve('../', '../', '../', '../', 'playwrightConfig.js');
|
|
37
|
+
const beforeCommand = 'node';
|
|
38
|
+
const bddGenPath = _path.default.resolve(__dirname, '../', '../', '../', 'bdd-framework', 'cli', 'index.js');
|
|
39
|
+
const beforeArgs = [bddGenPath, '-c', require.resolve(configPath)];
|
|
40
|
+
if (tagArgs) {
|
|
41
|
+
beforeArgs.push('--tags');
|
|
42
|
+
beforeArgs.push(tagArgs);
|
|
43
|
+
}
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
const childProcessForPreprocessing = (0, _child_process.spawn)(beforeCommand, beforeArgs, {
|
|
46
|
+
stdio: 'inherit',
|
|
47
|
+
env: {
|
|
48
|
+
...process.env
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
childProcessForPreprocessing.on('error', data => {
|
|
52
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, data);
|
|
53
|
+
reject(data);
|
|
54
|
+
});
|
|
55
|
+
childProcessForPreprocessing.on('exit', code => {
|
|
56
|
+
if (code === 0) {
|
|
57
|
+
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Feature Files Processed Successfully');
|
|
58
|
+
resolve();
|
|
59
|
+
} else {
|
|
60
|
+
reject(`BddGen exited with code ${code}`);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
runPlaywright() {
|
|
66
|
+
const {
|
|
67
|
+
tagArgs,
|
|
68
|
+
config,
|
|
69
|
+
userArgs
|
|
70
|
+
} = this.runnerObj;
|
|
71
|
+
const {
|
|
72
|
+
debug,
|
|
73
|
+
bddMode = false,
|
|
74
|
+
headless = false
|
|
75
|
+
} = config.getAll();
|
|
76
|
+
const playwrightArgs = _RunnerHelper.default.getPlaywrightArgs(userArgs, debug, bddMode, tagArgs, headless);
|
|
77
|
+
const playwrightPath = _path.default.resolve((0, _rootPath.getExecutableBinaryPath)('playwright'));
|
|
78
|
+
const command = playwrightPath;
|
|
79
|
+
const configPath = (0, _readConfigFile.isUserConfigFileAvailable)() ? _path.default.resolve(__dirname, '../', 'setup', 'config-creator.js') : _path.default.resolve('../', '../', '../', '../', 'playwrightConfig.js');
|
|
80
|
+
const args = ['test', '--config', require.resolve(configPath)].concat(playwrightArgs);
|
|
81
|
+
return new Promise((resolve, reject) => {
|
|
82
|
+
const childProcessForRunningPlaywright = (0, _child_process.spawn)(command, args, {
|
|
83
|
+
stdio: 'inherit',
|
|
84
|
+
env: {
|
|
85
|
+
...process.env
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
childProcessForRunningPlaywright.on('error', error => {
|
|
89
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, error);
|
|
90
|
+
});
|
|
91
|
+
childProcessForRunningPlaywright.on('exit', (code, signal) => {
|
|
92
|
+
if (code !== 0) {
|
|
93
|
+
reject(`Child Process Exited with Code ${code} and Signal ${signal}`);
|
|
94
|
+
} else {
|
|
95
|
+
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Test Ran Successfully');
|
|
96
|
+
resolve();
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
process.on('exit', () => {
|
|
100
|
+
childProcessForRunningPlaywright.kill();
|
|
101
|
+
reject('Terminating Playwright Process...');
|
|
102
|
+
});
|
|
103
|
+
process.on('SIGINT', () => {
|
|
104
|
+
childProcessForRunningPlaywright.kill();
|
|
105
|
+
reject('Cleaning up...');
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
module.exports = SpawnRunner;
|
|
@@ -1,23 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _logger = require("../../utils/logger");
|
|
4
|
-
function _classPrivateMethodInitSpec(
|
|
5
|
-
function _checkPrivateRedeclaration(
|
|
6
|
-
function
|
|
7
|
-
var
|
|
8
|
-
var _parseEdition = /*#__PURE__*/new WeakSet();
|
|
9
|
-
var _processSingleEdition = /*#__PURE__*/new WeakSet();
|
|
10
|
-
var _processMultipleEditions = /*#__PURE__*/new WeakSet();
|
|
11
|
-
var _getEditionArgs = /*#__PURE__*/new WeakSet();
|
|
12
|
-
var _buildEditionTags = /*#__PURE__*/new WeakSet();
|
|
4
|
+
function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
|
|
5
|
+
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
|
|
6
|
+
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
|
7
|
+
var _TagProcessor_brand = /*#__PURE__*/new WeakSet();
|
|
13
8
|
class TagProcessor {
|
|
14
9
|
constructor(editionOrder) {
|
|
15
|
-
_classPrivateMethodInitSpec(this,
|
|
16
|
-
_classPrivateMethodInitSpec(this, _getEditionArgs);
|
|
17
|
-
_classPrivateMethodInitSpec(this, _processMultipleEditions);
|
|
18
|
-
_classPrivateMethodInitSpec(this, _processSingleEdition);
|
|
19
|
-
_classPrivateMethodInitSpec(this, _parseEdition);
|
|
20
|
-
_classPrivateMethodInitSpec(this, _buildTagsString);
|
|
10
|
+
_classPrivateMethodInitSpec(this, _TagProcessor_brand);
|
|
21
11
|
this.editionOrder = editionOrder;
|
|
22
12
|
}
|
|
23
13
|
processTags(userArgs) {
|
|
@@ -25,36 +15,36 @@ class TagProcessor {
|
|
|
25
15
|
const edition = userArgs['edition'] || null;
|
|
26
16
|
if (!edition) return tagArgs;
|
|
27
17
|
const editionsArray = edition.split(',');
|
|
28
|
-
const editionTags = editionsArray.length === 1 ?
|
|
18
|
+
const editionTags = editionsArray.length === 1 ? _assertClassBrand(_TagProcessor_brand, this, _processSingleEdition).call(this, editionsArray[0], tagArgs) : _assertClassBrand(_TagProcessor_brand, this, _processMultipleEditions).call(this, editionsArray, tagArgs);
|
|
29
19
|
return editionTags;
|
|
30
20
|
}
|
|
31
21
|
}
|
|
32
|
-
function
|
|
22
|
+
function _buildTagsString(tags, editionTags) {
|
|
33
23
|
return tags && tags !== '' ? `${tags} and not (${editionTags})` : `not (${editionTags})`;
|
|
34
24
|
}
|
|
35
|
-
function
|
|
25
|
+
function _parseEdition(edition) {
|
|
36
26
|
if (edition.startsWith('<=')) return ['<=', edition.slice(2)];
|
|
37
27
|
if (edition.startsWith('>=')) return ['>=', edition.slice(2)];
|
|
38
28
|
if (edition.startsWith('<')) return ['<', edition.slice(1)];
|
|
39
29
|
if (edition.startsWith('>')) return ['>', edition.slice(1)];
|
|
40
30
|
return [null, edition];
|
|
41
31
|
}
|
|
42
|
-
function
|
|
43
|
-
const editionArgs =
|
|
32
|
+
function _processSingleEdition(selectedEdition, tagArgs) {
|
|
33
|
+
const editionArgs = _assertClassBrand(_TagProcessor_brand, this, _getEditionArgs).call(this, selectedEdition);
|
|
44
34
|
if (editionArgs && editionArgs.length > 0) {
|
|
45
|
-
const editionTags =
|
|
46
|
-
return
|
|
35
|
+
const editionTags = _assertClassBrand(_TagProcessor_brand, this, _buildEditionTags).call(this, editionArgs, 'or');
|
|
36
|
+
return _assertClassBrand(_TagProcessor_brand, this, _buildTagsString).call(this, tagArgs, editionTags);
|
|
47
37
|
}
|
|
48
38
|
_logger.Logger.log(_logger.Logger.INFO_TYPE, `No matching editions for ${selectedEdition} found. Running with default edition`);
|
|
49
39
|
return tagArgs;
|
|
50
40
|
}
|
|
51
|
-
function
|
|
41
|
+
function _processMultipleEditions(editionsArray, tagArgs) {
|
|
52
42
|
const filteredEditions = this.editionOrder.filter(edition => !editionsArray.includes(edition));
|
|
53
|
-
const editionTags =
|
|
54
|
-
return
|
|
43
|
+
const editionTags = _assertClassBrand(_TagProcessor_brand, this, _buildEditionTags).call(this, filteredEditions, 'or');
|
|
44
|
+
return _assertClassBrand(_TagProcessor_brand, this, _buildTagsString).call(this, tagArgs, editionTags);
|
|
55
45
|
}
|
|
56
|
-
function
|
|
57
|
-
const [operator, editionValue] =
|
|
46
|
+
function _getEditionArgs(selectedEdition) {
|
|
47
|
+
const [operator, editionValue] = _assertClassBrand(_TagProcessor_brand, this, _parseEdition).call(this, selectedEdition.toLowerCase());
|
|
58
48
|
const index = this.editionOrder.findIndex(edition => edition.toLowerCase() === editionValue);
|
|
59
49
|
if (index === -1) {
|
|
60
50
|
_logger.Logger.log(_logger.Logger.INFO_TYPE, `No matching editions for ${selectedEdition} found. Running with default edition`);
|
|
@@ -73,7 +63,7 @@ function _getEditionArgs2(selectedEdition) {
|
|
|
73
63
|
return this.editionOrder.filter((_, i) => i !== index);
|
|
74
64
|
}
|
|
75
65
|
}
|
|
76
|
-
function
|
|
66
|
+
function _buildEditionTags(editionArgs, operator = 'or') {
|
|
77
67
|
return editionArgs.map(edition => `@edition_${edition}`).join(` ${operator} `);
|
|
78
68
|
}
|
|
79
69
|
module.exports = TagProcessor;
|
|
@@ -20,27 +20,8 @@ var _browserTypes = require("./constants/browserTypes");
|
|
|
20
20
|
var _ConfigurationHelper = require("./configuration/ConfigurationHelper");
|
|
21
21
|
var _Configuration = _interopRequireDefault(require("./configuration/Configuration"));
|
|
22
22
|
var _UserArgs = _interopRequireDefault(require("./configuration/UserArgs"));
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
browsers = null
|
|
26
|
-
} = userArgsObject;
|
|
27
|
-
let browserList = (0, _configUtils.getBrowsersList)(browsers);
|
|
28
|
-
const playwrightArgs = (0, _cliArgsToObject.objectToCliArgs)(userArgsObject, key => !_customCommands.CUSTOM_COMMANDS.includes(key));
|
|
29
|
-
if (debug) {
|
|
30
|
-
playwrightArgs.push('--debug');
|
|
31
|
-
}
|
|
32
|
-
if (!bddMode && tagArgs) {
|
|
33
|
-
playwrightArgs.push('--grep');
|
|
34
|
-
playwrightArgs.push(tagArgs);
|
|
35
|
-
}
|
|
36
|
-
if (!headless && !userArgsObject.headed) {
|
|
37
|
-
playwrightArgs.push('--headed');
|
|
38
|
-
}
|
|
39
|
-
if (browserList && browserList.length > 0) {
|
|
40
|
-
browserList.map(browser => playwrightArgs.push(`--project=${_browserTypes.BROWSER_PROJECT_MAPPING[browser.toUpperCase()]}`));
|
|
41
|
-
}
|
|
42
|
-
return playwrightArgs;
|
|
43
|
-
}
|
|
23
|
+
var _RunnerHelper = _interopRequireDefault(require("./runner/RunnerHelper"));
|
|
24
|
+
var _Runner = _interopRequireDefault(require("./runner/Runner"));
|
|
44
25
|
function runPreprocessing(tagArgs, configPath) {
|
|
45
26
|
const beforeCommand = 'node';
|
|
46
27
|
const bddGenPath = _path.default.resolve(__dirname, '../', '../', 'bdd-framework', 'cli', 'index.js');
|
|
@@ -124,18 +105,11 @@ function main() {
|
|
|
124
105
|
const userArgsObject = userArgConfig.getAll();
|
|
125
106
|
const tagProcessor = new _tagProcessor.default(editionOrder);
|
|
126
107
|
const tagArgs = tagProcessor.processTags(userArgsObject);
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
if (bddMode) {
|
|
134
|
-
promises.push(runPreprocessing(tagArgs, configPath));
|
|
135
|
-
}
|
|
136
|
-
Promise.all(promises).then(() => runPlaywright(command, args)).catch(err => {
|
|
137
|
-
_logger.Logger.error(err);
|
|
138
|
-
process.exit();
|
|
139
|
-
});
|
|
108
|
+
const runnerObj = new _Runner.default();
|
|
109
|
+
runnerObj.setTagArgs(tagArgs);
|
|
110
|
+
runnerObj.setUserArgs(userArgsObject);
|
|
111
|
+
runnerObj.setConfig(uatConfig);
|
|
112
|
+
const runner = _RunnerHelper.default.createRunner('spawn', runnerObj);
|
|
113
|
+
runner.run();
|
|
140
114
|
}
|
|
141
115
|
var _default = exports.default = main;
|
|
@@ -2,93 +2,70 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
var _fileMutex = _interopRequireDefault(require("../../../../../core/playwright/helpers/fileMutex"));
|
|
5
|
-
var
|
|
5
|
+
var _properLockfile = _interopRequireDefault(require("proper-lockfile"));
|
|
6
6
|
var _path = _interopRequireDefault(require("path"));
|
|
7
7
|
var _fs = _interopRequireDefault(require("fs"));
|
|
8
|
-
jest.mock('lockfile');
|
|
8
|
+
jest.mock('proper-lockfile');
|
|
9
9
|
jest.mock('fs');
|
|
10
10
|
describe('FileMutex', () => {
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
retries:
|
|
16
|
-
|
|
11
|
+
const directory = '/tmp/locks';
|
|
12
|
+
const lockFileName = 'test-lock';
|
|
13
|
+
const options = {
|
|
14
|
+
stale: 10000,
|
|
15
|
+
retries: {
|
|
16
|
+
retries: 5,
|
|
17
|
+
factor: 1,
|
|
18
|
+
minTimeout: 5000,
|
|
19
|
+
maxTimeout: 8000
|
|
20
|
+
}
|
|
17
21
|
};
|
|
22
|
+
const lockFilePath = _path.default.resolve(directory, lockFileName + '.lock');
|
|
18
23
|
let fileMutex;
|
|
19
24
|
beforeEach(() => {
|
|
20
|
-
fileMutex = new _fileMutex.default(
|
|
21
|
-
});
|
|
22
|
-
afterEach(() => {
|
|
25
|
+
fileMutex = new _fileMutex.default(directory, lockFileName, options);
|
|
23
26
|
jest.clearAllMocks();
|
|
24
27
|
});
|
|
25
28
|
describe('acquire', () => {
|
|
26
|
-
it('should
|
|
27
|
-
const expectedPath = _path.default.resolve(_path.default.join(mockDirectory, `./${mockFileName}.lock`));
|
|
28
|
-
_lockfile.default.lock.mockImplementation((lockPath, options, callback) => {
|
|
29
|
-
expect(lockPath).toBe(expectedPath);
|
|
30
|
-
expect(options).toEqual(mockTimeout);
|
|
31
|
-
callback(null);
|
|
32
|
-
});
|
|
33
|
-
await expect(fileMutex.acquire()).resolves.toBeUndefined();
|
|
34
|
-
expect(_lockfile.default.lock).toHaveBeenCalledWith(expectedPath, mockTimeout, expect.any(Function));
|
|
35
|
-
});
|
|
36
|
-
it('should reject when lockfile.lock fails', async () => {
|
|
37
|
-
const mockError = new Error('Lock failed');
|
|
38
|
-
_lockfile.default.lock.mockImplementation((lockPath, options, callback) => {
|
|
39
|
-
expect(lockPath).toBe(_path.default.resolve(_path.default.join(mockDirectory, `./${mockFileName}.lock`)));
|
|
40
|
-
expect(options).toEqual(mockTimeout);
|
|
41
|
-
callback(mockError);
|
|
42
|
-
});
|
|
43
|
-
await expect(fileMutex.acquire()).rejects.toThrow('Lock failed');
|
|
44
|
-
expect(_lockfile.default.lock).toHaveBeenCalled();
|
|
45
|
-
});
|
|
46
|
-
it('should create the directory if it does not exist and acquire the lock', async () => {
|
|
29
|
+
it('should create the directory if it does not exist', async () => {
|
|
47
30
|
_fs.default.existsSync.mockReturnValue(false);
|
|
48
|
-
_fs.default.mkdirSync.mockImplementation((
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
});
|
|
54
|
-
_lockfile.default.lock.mockImplementation((lockPath, options, callback) => {
|
|
55
|
-
expect(lockPath).toBe(_path.default.resolve(_path.default.join(mockDirectory, `./${mockFileName}.lock`)));
|
|
56
|
-
expect(options).toEqual(mockTimeout);
|
|
57
|
-
callback(null);
|
|
58
|
-
});
|
|
59
|
-
await expect(fileMutex.acquire()).resolves.toBeUndefined();
|
|
60
|
-
expect(_fs.default.existsSync).toHaveBeenCalledWith(mockDirectory);
|
|
61
|
-
expect(_fs.default.mkdirSync).toHaveBeenCalledWith(mockDirectory, {
|
|
31
|
+
_fs.default.mkdirSync.mockImplementation(() => {});
|
|
32
|
+
_properLockfile.default.lock.mockResolvedValue();
|
|
33
|
+
await fileMutex.acquire();
|
|
34
|
+
expect(_fs.default.existsSync).toHaveBeenCalledWith(directory);
|
|
35
|
+
expect(_fs.default.mkdirSync).toHaveBeenCalledWith(directory, {
|
|
62
36
|
recursive: true
|
|
63
37
|
});
|
|
64
|
-
expect(_lockfile.default.lock).toHaveBeenCalled();
|
|
65
38
|
});
|
|
66
|
-
it('should
|
|
39
|
+
it('should create the lock file if it does not exist', async () => {
|
|
40
|
+
_fs.default.existsSync.mockImplementation(filePath => filePath !== lockFilePath);
|
|
41
|
+
_fs.default.writeFileSync.mockImplementation(() => {});
|
|
42
|
+
_properLockfile.default.lock.mockResolvedValue();
|
|
43
|
+
await fileMutex.acquire();
|
|
44
|
+
expect(_fs.default.existsSync).toHaveBeenCalledWith(lockFilePath);
|
|
45
|
+
expect(_fs.default.writeFileSync).toHaveBeenCalledWith(lockFilePath, 'locked');
|
|
46
|
+
});
|
|
47
|
+
it('should acquire the lock using proper-lockfile', async () => {
|
|
67
48
|
_fs.default.existsSync.mockReturnValue(true);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
49
|
+
_properLockfile.default.lock.mockResolvedValue();
|
|
50
|
+
await fileMutex.acquire();
|
|
51
|
+
expect(_properLockfile.default.lock).toHaveBeenCalledWith(lockFilePath, options);
|
|
52
|
+
});
|
|
53
|
+
it('should throw an error if lock acquisition fails', async () => {
|
|
54
|
+
const errorMessage = 'Lock acquisition failed';
|
|
55
|
+
_properLockfile.default.lock.mockRejectedValue(new Error(errorMessage));
|
|
56
|
+
await expect(fileMutex.acquire()).rejects.toThrow(`Failed to acquire lock after ${options.retries.retries} attempts: ${errorMessage}`);
|
|
74
57
|
});
|
|
75
58
|
});
|
|
76
59
|
describe('release', () => {
|
|
77
|
-
it('should
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
});
|
|
82
|
-
await expect(fileMutex.release()).resolves.toBeUndefined();
|
|
83
|
-
expect(_lockfile.default.unlock).toHaveBeenCalledWith(expectedPath, expect.any(Function));
|
|
60
|
+
it('should release the lock using proper-lockfile', async () => {
|
|
61
|
+
_properLockfile.default.unlock.mockResolvedValue();
|
|
62
|
+
await fileMutex.release();
|
|
63
|
+
expect(_properLockfile.default.unlock).toHaveBeenCalledWith(lockFilePath);
|
|
84
64
|
});
|
|
85
|
-
it('should
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
});
|
|
90
|
-
await expect(fileMutex.release()).rejects.toThrow('Unlock failed');
|
|
91
|
-
expect(_lockfile.default.unlock).toHaveBeenCalled();
|
|
65
|
+
it('should throw an error if lock release fails', async () => {
|
|
66
|
+
const errorMessage = 'Lock release failed';
|
|
67
|
+
_properLockfile.default.unlock.mockRejectedValue(new Error(errorMessage));
|
|
68
|
+
await expect(fileMutex.release()).rejects.toThrow(`Failed to release lock: ${errorMessage}`);
|
|
92
69
|
});
|
|
93
70
|
});
|
|
94
71
|
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _RunnerHelper = _interopRequireDefault(require("../../../../../core/playwright/runner/RunnerHelper"));
|
|
5
|
+
var _SpawnRunner = _interopRequireDefault(require("../../../../../core/playwright/runner/SpawnRunner"));
|
|
6
|
+
describe('RunnerHelper', () => {
|
|
7
|
+
describe('createRunner', () => {
|
|
8
|
+
it('should throw error on invalid runner type', () => {
|
|
9
|
+
expect(() => _RunnerHelper.default.createRunner('invalid-type', {})).toThrow("Invalid runner type");
|
|
10
|
+
});
|
|
11
|
+
it('should create a valid runner class', () => {
|
|
12
|
+
const runnerInstance = _RunnerHelper.default.createRunner('spawn', {});
|
|
13
|
+
expect(runnerInstance).toBeInstanceOf(_SpawnRunner.default); // Directly pass the result
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _RunnerHelper = _interopRequireDefault(require("../../../../../core/playwright/runner/RunnerHelper"));
|
|
5
|
+
var _Runner = _interopRequireDefault(require("../../../../../core/playwright/runner/Runner"));
|
|
6
|
+
var _Configuration = _interopRequireDefault(require("../../../../../core/playwright/configuration/Configuration"));
|
|
7
|
+
jest.mock('child_process');
|
|
8
|
+
jest.mock('../../../../../utils/logger');
|
|
9
|
+
describe('SpawnRunner', () => {
|
|
10
|
+
let spawnRunner;
|
|
11
|
+
const runnerObj = new _Runner.default();
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
const config = new _Configuration.default({});
|
|
14
|
+
config.add("bddMode", true);
|
|
15
|
+
runnerObj.setConfig(config);
|
|
16
|
+
runnerObj.setTagArgs(["--headed"]);
|
|
17
|
+
spawnRunner = _RunnerHelper.default.createRunner('spawn', runnerObj);
|
|
18
|
+
});
|
|
19
|
+
describe('run', () => {
|
|
20
|
+
it('should call runPreprocessing when bddMode is true', () => {
|
|
21
|
+
const runPreprocessingSpy = jest.spyOn(spawnRunner, 'runPreprocessing').mockResolvedValue();
|
|
22
|
+
const runPlaywrightSpy = jest.spyOn(spawnRunner, 'runPlaywright').mockResolvedValue();
|
|
23
|
+
spawnRunner.run();
|
|
24
|
+
expect(runPreprocessingSpy).toHaveBeenCalled();
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zohodesk/testinglibrary",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"fast-glob": "3.3.1",
|
|
33
33
|
"jest": "29.6.2",
|
|
34
34
|
"jest-environment-jsdom": "29.6.2",
|
|
35
|
-
"lockfile": "^1.0.4",
|
|
36
35
|
"msw": "1.2.3",
|
|
37
36
|
"playwright": "1.42.1",
|
|
37
|
+
"proper-lockfile": "4.1.2",
|
|
38
38
|
"supports-color": "8.1.1"
|
|
39
39
|
},
|
|
40
40
|
"bin": {
|
package/nobdd/README.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
npm install $(npm pack ../ | tail -1)
|
package/nobdd/package.json
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "testingframeworknobdd",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"description": "collection of examples that we can use for testing",
|
|
5
|
-
"keywords": [],
|
|
6
|
-
"author": "",
|
|
7
|
-
"license": "ISC",
|
|
8
|
-
"scripts": {
|
|
9
|
-
"uat": "ZDTestingFramework test --mode=dev --headed",
|
|
10
|
-
"uatnobdd": "ZDTestingFramework test --mode=nobdd",
|
|
11
|
-
"uat-ci": "ZDTestingFramework test --mode=ci --headed",
|
|
12
|
-
"uat-clean": "ZDTestingFramework clearCaches",
|
|
13
|
-
"uat-debug": "ZDTestingFramework test --mode=dev --debug",
|
|
14
|
-
"uat-report": "ZDTestingFramework report --port=9009",
|
|
15
|
-
"codegen": "ZDTestingFramework codegen deskclientapp.localzoho.com/agent"
|
|
16
|
-
}
|
|
17
|
-
}
|
package/nobdd/src/App.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"id": "1",
|
|
4
|
-
"edition": "enterprise",
|
|
5
|
-
"orgName": "zohodeskteam",
|
|
6
|
-
"profiles": [
|
|
7
|
-
{
|
|
8
|
-
"profile": "admin",
|
|
9
|
-
"email": "solairaj.m+26jun2023@zohotest.com",
|
|
10
|
-
"password": "Demo@1201"
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
"profile": "agent",
|
|
14
|
-
"email": "anitha.m+agentat@zohotest.com",
|
|
15
|
-
"password": "Desk@1234"
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
"profile": "lightagent",
|
|
19
|
-
"email": "anitha.m+admin@zohotest.com",
|
|
20
|
-
"password": "Moon@2018"
|
|
21
|
-
}
|
|
22
|
-
]
|
|
23
|
-
}
|
|
24
|
-
]
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
const customFixtures = require('../../shared/commands/_index-custom-fixtures');
|
|
2
|
-
|
|
3
|
-
const { getDefaultActor } = require('@zohodesk/testinglibrary/helpers');
|
|
4
|
-
|
|
5
|
-
function getPrimaryCookiePath() {
|
|
6
|
-
const { email } = getDefaultActor();
|
|
7
|
-
return `uat/playwright/.auth/${email}-cookies.json`;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Represents the user configuration object.
|
|
12
|
-
* @typedef {import('@zohodesk/testinglibrary').UserConfig} UserConfig
|
|
13
|
-
*/
|
|
14
|
-
module.exports = {
|
|
15
|
-
headless: false,
|
|
16
|
-
retries:1,
|
|
17
|
-
openReportOn: 'never',
|
|
18
|
-
browsers: ['Chrome'],
|
|
19
|
-
isAuthMode: true,
|
|
20
|
-
authFilePath: getPrimaryCookiePath(),
|
|
21
|
-
trace: 'retain-on-failure',
|
|
22
|
-
video: 'retain-on-failure',
|
|
23
|
-
retries:1,
|
|
24
|
-
bddMode: false,
|
|
25
|
-
expectTimeout: 10 * 1000,
|
|
26
|
-
testTimeout: 60 * 1000,
|
|
27
|
-
globalTimeout: 2 * 60 * 60 * 1000,
|
|
28
|
-
featureFilesFolder: 'feature-files',
|
|
29
|
-
stepDefinitionsFolder: 'steps',
|
|
30
|
-
viewport: { width: 1280, height: 720 },
|
|
31
|
-
testIdAttribute: 'data-id',
|
|
32
|
-
editionOrder: ['Free', 'Express', 'Standard', 'Professional', 'Enterprise'],
|
|
33
|
-
additionalPages: {
|
|
34
|
-
...customFixtures
|
|
35
|
-
}
|
|
36
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"dev": {
|
|
3
|
-
"domain": "https://zdesk-devops16.csez.zohocorpin.com:31025/agent",
|
|
4
|
-
"orgName": "org-name",
|
|
5
|
-
"deptName": "dept-name",
|
|
6
|
-
"moduleName": "module-name"
|
|
7
|
-
},
|
|
8
|
-
"prod": {
|
|
9
|
-
"domain": "https://zdesk-devops16.csez.zohocorpin.com:31025/agent",
|
|
10
|
-
"orgName": "sangeetha.t@zohocorp.com",
|
|
11
|
-
"deptName": "sangeethat",
|
|
12
|
-
"moduleName": "sangeethat"
|
|
13
|
-
},
|
|
14
|
-
"ci": {
|
|
15
|
-
"domain": "https://zdesk-devops16.csez.zohocorpin.com:31025/agent",
|
|
16
|
-
"orgName": "clientcicdk8",
|
|
17
|
-
"deptName": "clientcicdk8",
|
|
18
|
-
"moduleName": "tickets"
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
import {
|
|
3
|
-
test as setup,
|
|
4
|
-
expect
|
|
5
|
-
} from '@zohodesk/testinglibrary';
|
|
6
|
-
import {
|
|
7
|
-
getDefaultActor,
|
|
8
|
-
getUserForSelectedEditionAndProfile,
|
|
9
|
-
performLoginSteps
|
|
10
|
-
} from '@zohodesk/testinglibrary/helpers'
|
|
11
|
-
import { SETUP_HOME_PAGE_SELECTORS } from '../modules/Setup/dom-selectors/SetupSelectors';
|
|
12
|
-
import getUrlOrigin from '../shared/url-helpers/getUrlOrigin';
|
|
13
|
-
|
|
14
|
-
const { edition, profile } = getDefaultActor();
|
|
15
|
-
|
|
16
|
-
const user = getUserForSelectedEditionAndProfile(edition, profile);
|
|
17
|
-
|
|
18
|
-
async function verifyPageIsLoaded(page) {
|
|
19
|
-
const urlOrigin = getUrlOrigin(page.url());
|
|
20
|
-
const domainOrigin = getUrlOrigin(process.env.domain);
|
|
21
|
-
if (urlOrigin === domainOrigin) {
|
|
22
|
-
await expect(
|
|
23
|
-
page
|
|
24
|
-
.locator('header')
|
|
25
|
-
.getByLabel(SETUP_HOME_PAGE_SELECTORS.SETUP_ICON_LABEL)
|
|
26
|
-
).toBeVisible();
|
|
27
|
-
return true;
|
|
28
|
-
}
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
setup(`${user.edition} - Authentication`, async ({ page }) => {
|
|
33
|
-
const { email, password } = user;
|
|
34
|
-
await performLoginSteps(
|
|
35
|
-
{
|
|
36
|
-
page,
|
|
37
|
-
authFilePrefix: email,
|
|
38
|
-
useremail: email,
|
|
39
|
-
password: password
|
|
40
|
-
},
|
|
41
|
-
verifyPageIsLoaded
|
|
42
|
-
);
|
|
43
|
-
//await completeOnboardings({ page });
|
|
44
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import {
|
|
4
|
-
test as teardown,
|
|
5
|
-
expect
|
|
6
|
-
} from '@zohodesk/testinglibrary';
|
|
7
|
-
import { isDevelopmentSetup, loadCookiesIfPresent } from '@zohodesk/testinglibrary/helpers'
|
|
8
|
-
import getUrlOrigin from '../shared/url-helpers/getUrlOrigin';
|
|
9
|
-
|
|
10
|
-
// We are adding teardown logic only in CI mode
|
|
11
|
-
if (!isDevelopmentSetup()) {
|
|
12
|
-
teardown(`Log out scenarios`, async ({ page }) => {
|
|
13
|
-
const authDirectory = path.resolve(
|
|
14
|
-
process.cwd(),
|
|
15
|
-
'uat',
|
|
16
|
-
'playwright',
|
|
17
|
-
'.auth'
|
|
18
|
-
);
|
|
19
|
-
const files = fs.readdirSync(authDirectory);
|
|
20
|
-
const promises = files.map(async file => {
|
|
21
|
-
const authFilePath = path.join(authDirectory, file);
|
|
22
|
-
await loadCookiesIfPresent(page, authFilePath);
|
|
23
|
-
const domainOrigin = getUrlOrigin(process.env.domain);
|
|
24
|
-
const logoutURL = `${domainOrigin}/support/logout.sas`;
|
|
25
|
-
await page.goto(logoutURL);
|
|
26
|
-
await page.waitForNavigation();
|
|
27
|
-
await expect(page.locator('[id="signin_flow"]')).toBeVisible();
|
|
28
|
-
await fs.rmSync(authFilePath);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
await Promise.all(promises);
|
|
32
|
-
});
|
|
33
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { test, expect } from "@zohodesk/testinglibrary";
|
|
2
|
-
|
|
3
|
-
test.describe("Verify no authentication required @nobdd", () => {
|
|
4
|
-
|
|
5
|
-
test("Verify the page is not logged in", async ({ page }) => {
|
|
6
|
-
|
|
7
|
-
await page.goto(process.env.domain);
|
|
8
|
-
|
|
9
|
-
await page.waitForSelector('#login');
|
|
10
|
-
|
|
11
|
-
const isLoggedIn = await page.isVisible('#login');
|
|
12
|
-
expect(isLoggedIn).toBe(true);
|
|
13
|
-
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-param-reassign */
|
|
2
|
-
|
|
3
|
-
// Note: We are duplicating below method from @zohodesk/i18n. We are not importing it as react package not yet availble in test environment.
|
|
4
|
-
function replaceI18NValuesWithRegex(i18nStr, values) {
|
|
5
|
-
if (typeof values !== 'undefined') {
|
|
6
|
-
if (Array.isArray(values)) {
|
|
7
|
-
for (let i = 0; i < values.length; i++) {
|
|
8
|
-
i18nStr = i18nStr.replace(new RegExp(`\\{${i}\\}`, 'g'), values[i]);
|
|
9
|
-
}
|
|
10
|
-
} else {
|
|
11
|
-
i18nStr = i18nStr.replace(new RegExp('\\{0\\}', 'g'), values);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
return i18nStr;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
module.exports = {
|
|
18
|
-
i18N: async ({ page }, use) => {
|
|
19
|
-
await use(async (key, values) => {
|
|
20
|
-
const i18nValue = await page.evaluate((i18nKey) => window.i18n[i18nKey], key);
|
|
21
|
-
const i18nStr = replaceI18NValuesWithRegex(i18nValue, values)
|
|
22
|
-
return i18nStr;
|
|
23
|
-
})
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
async function get_cookie(page) {
|
|
2
|
-
return page.evaluate(async () => {
|
|
3
|
-
const results = document.cookie.match(`crmcsr=(.*?)(;|$)`);
|
|
4
|
-
if (results) {
|
|
5
|
-
return unescape(results[1]);
|
|
6
|
-
}
|
|
7
|
-
return null;
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
async function getOnboardings({ page, cookieVal }) {
|
|
12
|
-
return page.evaluate(
|
|
13
|
-
async (cookieVal) =>
|
|
14
|
-
fetch('/api/v1/onboardingStatus', {
|
|
15
|
-
method: 'GET',
|
|
16
|
-
headers: {
|
|
17
|
-
orgId: window.currentOrg.id,
|
|
18
|
-
'X-ZCSRF-TOKEN': `crmcsrfparam=${cookieVal}`
|
|
19
|
-
}
|
|
20
|
-
}).then((r) => (r.ok ? r.json() : Promise.reject(r))),
|
|
21
|
-
cookieVal
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
async function completeOnboardings({ page }) {
|
|
26
|
-
const cookieVal = await get_cookie(page);
|
|
27
|
-
const onboardings = await getOnboardings({ page });
|
|
28
|
-
if (onboardings.pending.length) {
|
|
29
|
-
await page.evaluate(
|
|
30
|
-
async ({ cookieVal, onboardings }) =>
|
|
31
|
-
fetch('/api/v1/onboardingStatus/markComplete', {
|
|
32
|
-
method: 'POST',
|
|
33
|
-
headers: {
|
|
34
|
-
orgId: window.currentOrg.id,
|
|
35
|
-
'X-ZCSRF-TOKEN': `crmcsrfparam=${cookieVal}`
|
|
36
|
-
},
|
|
37
|
-
body: JSON.stringify({ items: onboardings.pending })
|
|
38
|
-
}),
|
|
39
|
-
{ cookieVal, onboardings }
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
module.exports = completeOnboardings;
|
package/nobdd/uat.config.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
const customFixtures = require('./uat/shared/commands/_index-custom-fixtures');
|
|
2
|
-
|
|
3
|
-
const { getDefaultActor } = require('@zohodesk/testinglibrary/helpers');
|
|
4
|
-
|
|
5
|
-
function getPrimaryCookiePath() {
|
|
6
|
-
const { email } = getDefaultActor();
|
|
7
|
-
return `uat/playwright/.auth/${email}-cookies.json`;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Represents the user configuration object.
|
|
12
|
-
* @typedef {import('@zohodesk/testinglibrary').UserConfig} UserConfig
|
|
13
|
-
*/
|
|
14
|
-
module.exports = {
|
|
15
|
-
headless: false,
|
|
16
|
-
retries:1,
|
|
17
|
-
openReportOn: 'never',
|
|
18
|
-
browsers: ['Chrome'],
|
|
19
|
-
isAuthMode: true,
|
|
20
|
-
authFilePath: getPrimaryCookiePath(),
|
|
21
|
-
trace: 'retain-on-failure',
|
|
22
|
-
video: 'retain-on-failure',
|
|
23
|
-
retries:1,
|
|
24
|
-
bddMode: false,
|
|
25
|
-
expectTimeout: 10 * 1000,
|
|
26
|
-
testTimeout: 60 * 1000,
|
|
27
|
-
globalTimeout: 2 * 60 * 60 * 1000,
|
|
28
|
-
featureFilesFolder: 'feature-files',
|
|
29
|
-
stepDefinitionsFolder: 'steps',
|
|
30
|
-
viewport: { width: 1280, height: 720 },
|
|
31
|
-
testIdAttribute: 'data-id',
|
|
32
|
-
editionOrder: ['Free', 'Express', 'Standard', 'Professional', 'Enterprise'],
|
|
33
|
-
additionalPages: {
|
|
34
|
-
...customFixtures
|
|
35
|
-
}
|
|
36
|
-
};
|