@zohodesk/testinglibrary 0.4.25-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.
|
@@ -32,6 +32,16 @@ function getCustomAccountDetails(tags) {
|
|
|
32
32
|
const {
|
|
33
33
|
testSetup
|
|
34
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
|
+
}
|
|
35
45
|
async function performDefaultPageSteps({
|
|
36
46
|
context,
|
|
37
47
|
$tags,
|
|
@@ -48,8 +58,8 @@ async function performDefaultPageSteps({
|
|
|
48
58
|
}
|
|
49
59
|
}
|
|
50
60
|
async function verifyPageIsLoaded(page) {
|
|
51
|
-
if (testSetup.
|
|
52
|
-
return await testSetup.
|
|
61
|
+
if (testSetup.validateLogin && typeof testSetup.validateLogin === 'function') {
|
|
62
|
+
return await testSetup.validateLogin(page);
|
|
53
63
|
}
|
|
54
64
|
return true;
|
|
55
65
|
}
|
|
@@ -72,20 +82,20 @@ var _default = exports.default = {
|
|
|
72
82
|
return;
|
|
73
83
|
}
|
|
74
84
|
const testPortalDetails = getCustomAccountDetails($tags);
|
|
75
|
-
if (testPortalDetails
|
|
85
|
+
if (testPortalDetails) {
|
|
76
86
|
await context.clearCookies();
|
|
77
87
|
const {
|
|
78
|
-
email
|
|
79
|
-
password
|
|
88
|
+
email
|
|
80
89
|
} = testPortalDetails;
|
|
81
90
|
await (0, _auth.performLoginSteps)({
|
|
82
91
|
page,
|
|
92
|
+
$tags,
|
|
93
|
+
context,
|
|
83
94
|
authFilePrefix: email,
|
|
84
|
-
|
|
85
|
-
password: password
|
|
95
|
+
...testPortalDetails
|
|
86
96
|
}, async () => {
|
|
87
97
|
return await verifyPageIsLoaded(page);
|
|
88
|
-
},
|
|
98
|
+
}, loginSteps);
|
|
89
99
|
process.env.actorInfo = JSON.stringify(testPortalDetails);
|
|
90
100
|
}
|
|
91
101
|
} catch (error) {
|
|
@@ -15,11 +15,13 @@ var _checkAuthDirectory = require("../checkAuthDirectory");
|
|
|
15
15
|
async function performLoginSteps({
|
|
16
16
|
page,
|
|
17
17
|
authFilePrefix,
|
|
18
|
-
|
|
19
|
-
password
|
|
20
|
-
|
|
18
|
+
email,
|
|
19
|
+
password,
|
|
20
|
+
context,
|
|
21
|
+
$tags
|
|
22
|
+
}, isLoggedIn, loginSteps) {
|
|
21
23
|
const authFile = _path.default.resolve(_path.default.join((0, _checkAuthCookies.getAuthFileDirectory)(), `${authFilePrefix}-cookies.json`));
|
|
22
|
-
const lockFileName =
|
|
24
|
+
const lockFileName = email.replace(/[@.]/g, '_');
|
|
23
25
|
const fileMutex = new _fileMutex.default((0, _checkAuthDirectory.getLockDirectoryPath)(), lockFileName, _fileMutexConfig.LOGIN_MUTEX_TIMEOUT);
|
|
24
26
|
try {
|
|
25
27
|
await fileMutex.acquire();
|
|
@@ -28,7 +30,13 @@ async function performLoginSteps({
|
|
|
28
30
|
await Promise.race([page.waitForNavigation(), page.waitForLoadState('networkidle'), page.waitForTimeout(5000)]);
|
|
29
31
|
const isAlreadyLoggedIn = await isLoggedIn(page);
|
|
30
32
|
if (!isAlreadyLoggedIn) {
|
|
31
|
-
await
|
|
33
|
+
await loginSteps({
|
|
34
|
+
page,
|
|
35
|
+
email,
|
|
36
|
+
password,
|
|
37
|
+
context,
|
|
38
|
+
$tags
|
|
39
|
+
});
|
|
32
40
|
await page.goto(process.env.domain);
|
|
33
41
|
await isLoggedIn(page);
|
|
34
42
|
await page.context().storageState({
|
|
@@ -36,12 +44,12 @@ async function performLoginSteps({
|
|
|
36
44
|
});
|
|
37
45
|
}
|
|
38
46
|
} catch (error) {
|
|
39
|
-
console.error(`Error during login for ${
|
|
47
|
+
console.error(`Error during login for ${email}:`, error);
|
|
40
48
|
} finally {
|
|
41
49
|
try {
|
|
42
50
|
await fileMutex.release();
|
|
43
51
|
} catch (releaseError) {
|
|
44
|
-
console.error(`Error releasing lock for ${
|
|
52
|
+
console.error(`Error releasing lock for ${email}:`, releaseError);
|
|
45
53
|
}
|
|
46
54
|
}
|
|
47
55
|
}
|
|
@@ -46,6 +46,13 @@ const use = {
|
|
|
46
46
|
viewport,
|
|
47
47
|
testIdAttribute
|
|
48
48
|
};
|
|
49
|
+
let reporter = [['html', {
|
|
50
|
+
outputFolder: reportPath,
|
|
51
|
+
open: openReportOn
|
|
52
|
+
}], ['list'], ['./custom-reporter.js']];
|
|
53
|
+
if (customReporter) {
|
|
54
|
+
reporter = [customReporter, ...reporter];
|
|
55
|
+
}
|
|
49
56
|
|
|
50
57
|
/**
|
|
51
58
|
* Playwright configuration object
|
|
@@ -58,10 +65,7 @@ function getPlaywrightConfig() {
|
|
|
58
65
|
globalTimeout: globalTimeout || 3600000,
|
|
59
66
|
outputDir: _path.default.join(process.cwd(), 'uat', 'test-results'),
|
|
60
67
|
fullyParallel: true,
|
|
61
|
-
reporter
|
|
62
|
-
outputFolder: reportPath,
|
|
63
|
-
open: openReportOn
|
|
64
|
-
}], ['list'], ['./custom-reporter.js']],
|
|
68
|
+
reporter,
|
|
65
69
|
timeout: testTimeout,
|
|
66
70
|
expect: {
|
|
67
71
|
timeout: expectTimeout
|