@zohodesk/testinglibrary 0.4.9-experimental → 0.4.11-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.
@@ -5,7 +5,7 @@ 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
- "wait": 30000,
8
+ "wait": 50000,
9
9
  "retries": 10,
10
10
  "stale": 300000
11
11
  };
@@ -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
- const cookiesExist = await (0, _checkAuthCookies.loadCookiesIfPresent)(page, authFile);
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 (cookiesExist && isAlreadyLoggedIn) {
30
- console.log('Account is already logged in. Skipping lock.');
31
- } else {
32
- await fileMutex.acquire();
33
- try {
34
- if (!isAlreadyLoggedIn) {
35
- await (0, _accountLogin.default)(page, useremail, password);
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('Error during login:', error);
48
- await fileMutex.release();
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/testinglibrary",
3
- "version": "0.4.9-experimental",
3
+ "version": "0.4.11-experimental",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {