@zohodesk/testinglibrary 0.4.9-experimental → 0.4.10-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.
|
@@ -22,30 +22,27 @@ async function performLoginSteps({
|
|
|
22
22
|
const lockFileName = useremail.replace(/[@.]/g, '_');
|
|
23
23
|
const fileMutex = new _fileMutex.default((0, _checkAuthCookies.getAuthFileDirectory)(), lockFileName, _fileMutexConfig.LOGIN_MUTEX_TIMEOUT);
|
|
24
24
|
try {
|
|
25
|
-
|
|
25
|
+
await fileMutex.acquire();
|
|
26
|
+
await (0, _checkAuthCookies.loadCookiesIfPresent)(page, authFile);
|
|
26
27
|
await page.goto(process.env.domain);
|
|
27
28
|
await Promise.race([page.waitForNavigation(), page.waitForLoadState('networkidle'), page.waitForTimeout(5000)]);
|
|
28
29
|
const isAlreadyLoggedIn = await isLoggedIn(page);
|
|
29
|
-
if (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
await
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
await page.goto(process.env.domain);
|
|
37
|
-
await isLoggedIn(page);
|
|
38
|
-
await page.context().storageState({
|
|
39
|
-
path: authFile
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
} finally {
|
|
43
|
-
await fileMutex.release();
|
|
44
|
-
}
|
|
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
|
+
});
|
|
45
37
|
}
|
|
46
38
|
} catch (error) {
|
|
47
|
-
console.error(
|
|
48
|
-
|
|
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
|
+
}
|
|
49
46
|
}
|
|
50
47
|
}
|
|
51
48
|
var _default = exports.default = performLoginSteps;
|