@zohodesk/testinglibrary 0.4.24-experimental → 0.4.26-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/README.md +5 -0
- package/build/core/playwright/builtInFixtures/page.js +44 -45
- package/build/core/playwright/helpers/auth/loginSteps.js +15 -8
- package/build/core/playwright/setup/config-creator.js +10 -5
- package/npm-shrinkwrap.json +2449 -1581
- package/package.json +4 -3
- package/playwright.config.js +0 -48
- package/unit_reports/unit-report.html +0 -260
package/README.md
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
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.default = void 0;
|
|
8
7
|
var _auth = require("../helpers/auth");
|
|
9
|
-
var _getUrlOrigin = _interopRequireDefault(require("../helpers/auth/getUrlOrigin"));
|
|
10
8
|
var _readConfigFile = require("../readConfigFile");
|
|
11
9
|
/* eslint-disable global-require */
|
|
12
10
|
|
|
@@ -34,6 +32,16 @@ function getCustomAccountDetails(tags) {
|
|
|
34
32
|
const {
|
|
35
33
|
testSetup
|
|
36
34
|
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
35
|
+
async function loginSteps(pageDetail) {
|
|
36
|
+
const {
|
|
37
|
+
page
|
|
38
|
+
} = pageDetail;
|
|
39
|
+
if (testSetup.loginSteps && typeof testSetup.loginSteps === 'function') {
|
|
40
|
+
return await testSetup.loginSteps(pageDetail);
|
|
41
|
+
} else {
|
|
42
|
+
await page.goto(process.env.domain);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
37
45
|
async function performDefaultPageSteps({
|
|
38
46
|
context,
|
|
39
47
|
$tags,
|
|
@@ -50,12 +58,10 @@ async function performDefaultPageSteps({
|
|
|
50
58
|
}
|
|
51
59
|
}
|
|
52
60
|
async function verifyPageIsLoaded(page) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (urlOrigin === domainOrigin) {
|
|
56
|
-
return true;
|
|
61
|
+
if (testSetup.validateLogin && typeof testSetup.validateLogin === 'function') {
|
|
62
|
+
return await testSetup.validateLogin(page);
|
|
57
63
|
}
|
|
58
|
-
return
|
|
64
|
+
return true;
|
|
59
65
|
}
|
|
60
66
|
var _default = exports.default = {
|
|
61
67
|
page: async ({
|
|
@@ -63,45 +69,38 @@ var _default = exports.default = {
|
|
|
63
69
|
$tags,
|
|
64
70
|
page
|
|
65
71
|
}, use) => {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
}
|
|
80
|
-
const testPortalDetails = getCustomAccountDetails($tags);
|
|
81
|
-
if (testPortalDetails === null) {
|
|
82
|
-
await performDefaultPageSteps({
|
|
83
|
-
context,
|
|
84
|
-
$tags,
|
|
85
|
-
page
|
|
86
|
-
});
|
|
87
|
-
const user = (0, _auth.getDefaultActor)();
|
|
88
|
-
process.env.actorInfo = JSON.stringify(user);
|
|
89
|
-
await use(page);
|
|
90
|
-
} else {
|
|
91
|
-
await context.clearCookies();
|
|
72
|
+
try {
|
|
73
|
+
//This block is used to skip the login process if the @unauthenticated tag is added to the script
|
|
74
|
+
if ($tags.includes('@unauthenticated')) {
|
|
75
|
+
await context.clearCookies();
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
92
78
|
const {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
79
|
+
isAuthMode
|
|
80
|
+
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
81
|
+
if (!isAuthMode) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const testPortalDetails = getCustomAccountDetails($tags);
|
|
85
|
+
if (testPortalDetails) {
|
|
86
|
+
await context.clearCookies();
|
|
87
|
+
const {
|
|
88
|
+
email
|
|
89
|
+
} = testPortalDetails;
|
|
90
|
+
await (0, _auth.performLoginSteps)({
|
|
91
|
+
page,
|
|
92
|
+
$tags,
|
|
93
|
+
context,
|
|
94
|
+
authFilePrefix: email,
|
|
95
|
+
...testPortalDetails
|
|
96
|
+
}, async () => {
|
|
97
|
+
return await verifyPageIsLoaded(page);
|
|
98
|
+
}, loginSteps);
|
|
99
|
+
process.env.actorInfo = JSON.stringify(testPortalDetails);
|
|
100
|
+
}
|
|
101
|
+
} catch (error) {
|
|
102
|
+
console.error('Error during page', error);
|
|
103
|
+
} finally {
|
|
105
104
|
await performDefaultPageSteps({
|
|
106
105
|
context,
|
|
107
106
|
$tags,
|
|
@@ -8,7 +8,6 @@ exports.default = void 0;
|
|
|
8
8
|
var _path = _interopRequireDefault(require("path"));
|
|
9
9
|
var _fileMutex = _interopRequireDefault(require("../fileMutex"));
|
|
10
10
|
var _fileMutexConfig = require("../../constants/fileMutexConfig");
|
|
11
|
-
var _accountLogin = _interopRequireDefault(require("./accountLogin"));
|
|
12
11
|
var _checkAuthCookies = require("./checkAuthCookies");
|
|
13
12
|
var _checkAuthDirectory = require("../checkAuthDirectory");
|
|
14
13
|
/* eslint-disable no-console */
|
|
@@ -16,11 +15,13 @@ var _checkAuthDirectory = require("../checkAuthDirectory");
|
|
|
16
15
|
async function performLoginSteps({
|
|
17
16
|
page,
|
|
18
17
|
authFilePrefix,
|
|
19
|
-
|
|
20
|
-
password
|
|
21
|
-
|
|
18
|
+
email,
|
|
19
|
+
password,
|
|
20
|
+
context,
|
|
21
|
+
$tags
|
|
22
|
+
}, isLoggedIn, loginSteps) {
|
|
22
23
|
const authFile = _path.default.resolve(_path.default.join((0, _checkAuthCookies.getAuthFileDirectory)(), `${authFilePrefix}-cookies.json`));
|
|
23
|
-
const lockFileName =
|
|
24
|
+
const lockFileName = email.replace(/[@.]/g, '_');
|
|
24
25
|
const fileMutex = new _fileMutex.default((0, _checkAuthDirectory.getLockDirectoryPath)(), lockFileName, _fileMutexConfig.LOGIN_MUTEX_TIMEOUT);
|
|
25
26
|
try {
|
|
26
27
|
await fileMutex.acquire();
|
|
@@ -29,7 +30,13 @@ async function performLoginSteps({
|
|
|
29
30
|
await Promise.race([page.waitForNavigation(), page.waitForLoadState('networkidle'), page.waitForTimeout(5000)]);
|
|
30
31
|
const isAlreadyLoggedIn = await isLoggedIn(page);
|
|
31
32
|
if (!isAlreadyLoggedIn) {
|
|
32
|
-
await (
|
|
33
|
+
await loginSteps({
|
|
34
|
+
page,
|
|
35
|
+
email,
|
|
36
|
+
password,
|
|
37
|
+
context,
|
|
38
|
+
$tags
|
|
39
|
+
});
|
|
33
40
|
await page.goto(process.env.domain);
|
|
34
41
|
await isLoggedIn(page);
|
|
35
42
|
await page.context().storageState({
|
|
@@ -37,12 +44,12 @@ async function performLoginSteps({
|
|
|
37
44
|
});
|
|
38
45
|
}
|
|
39
46
|
} catch (error) {
|
|
40
|
-
console.error(`Error during login for ${
|
|
47
|
+
console.error(`Error during login for ${email}:`, error);
|
|
41
48
|
} finally {
|
|
42
49
|
try {
|
|
43
50
|
await fileMutex.release();
|
|
44
51
|
} catch (releaseError) {
|
|
45
|
-
console.error(`Error releasing lock for ${
|
|
52
|
+
console.error(`Error releasing lock for ${email}:`, releaseError);
|
|
46
53
|
}
|
|
47
54
|
}
|
|
48
55
|
}
|
|
@@ -25,7 +25,8 @@ const {
|
|
|
25
25
|
featureFilesFolder,
|
|
26
26
|
stepDefinitionsFolder,
|
|
27
27
|
testIdAttribute,
|
|
28
|
-
globalTimeout
|
|
28
|
+
globalTimeout,
|
|
29
|
+
customReporter
|
|
29
30
|
} = uatConfig;
|
|
30
31
|
const projects = (0, _configUtils.getProjects)({
|
|
31
32
|
browsers,
|
|
@@ -45,6 +46,13 @@ const use = {
|
|
|
45
46
|
viewport,
|
|
46
47
|
testIdAttribute
|
|
47
48
|
};
|
|
49
|
+
let reporter = [['html', {
|
|
50
|
+
outputFolder: reportPath,
|
|
51
|
+
open: openReportOn
|
|
52
|
+
}], ['list'], ['./custom-reporter.js']];
|
|
53
|
+
if (customReporter) {
|
|
54
|
+
reporter = [customReporter, ...reporter];
|
|
55
|
+
}
|
|
48
56
|
|
|
49
57
|
/**
|
|
50
58
|
* Playwright configuration object
|
|
@@ -57,10 +65,7 @@ function getPlaywrightConfig() {
|
|
|
57
65
|
globalTimeout: globalTimeout || 3600000,
|
|
58
66
|
outputDir: _path.default.join(process.cwd(), 'uat', 'test-results'),
|
|
59
67
|
fullyParallel: true,
|
|
60
|
-
reporter
|
|
61
|
-
outputFolder: reportPath,
|
|
62
|
-
open: openReportOn
|
|
63
|
-
}], ['list'], ['./custom-reporter.js']],
|
|
68
|
+
reporter,
|
|
64
69
|
timeout: testTimeout,
|
|
65
70
|
expect: {
|
|
66
71
|
timeout: expectTimeout
|