@zohodesk/testinglibrary 0.4.37-experimental → 0.4.38-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.
@@ -27,7 +27,7 @@ function getCustomAccountDetails(tags) {
27
27
  const user = (0, _auth.getUserForSelectedEditionAndProfile)(editionInfo, profileInfo, betaFeature, portalInfo);
28
28
  return user;
29
29
  }
30
- return (0, _auth.getDefaultActor)();
30
+ return null;
31
31
  }
32
32
  const {
33
33
  testSetup
@@ -42,9 +42,19 @@ async function loginSteps(pageDetail) {
42
42
  await page.goto(process.env.domain);
43
43
  }
44
44
  }
45
- async function performDefaultPageSteps(testInfo) {
45
+ async function performDefaultPageSteps({
46
+ context,
47
+ $tags,
48
+ page
49
+ }) {
46
50
  if (testSetup.page && typeof testSetup.page === 'function') {
47
- await testSetup.page(testInfo);
51
+ await testSetup.page({
52
+ context,
53
+ $tags,
54
+ page
55
+ });
56
+ } else {
57
+ await page.goto(process.env.domain);
48
58
  }
49
59
  }
50
60
  async function verifyPageIsLoaded(testInfo) {
@@ -58,14 +68,7 @@ var _default = exports.default = {
58
68
  context,
59
69
  $tags,
60
70
  page
61
- }, use, testInfo) => {
62
- let testPortalDetails = getCustomAccountDetails($tags);
63
- let testDetails = {
64
- page,
65
- $tags,
66
- context,
67
- ...testPortalDetails
68
- };
71
+ }, use) => {
69
72
  try {
70
73
  //This block is used to skip the login process if the @unauthenticated tag is added to the script
71
74
  if ($tags.includes('@unauthenticated')) {
@@ -78,17 +81,30 @@ var _default = exports.default = {
78
81
  if (!isAuthMode) {
79
82
  return;
80
83
  }
81
- if (testPortalDetails && testInfo.project.name !== 'setup') {
84
+ const testPortalDetails = getCustomAccountDetails($tags);
85
+ if (testPortalDetails) {
82
86
  await context.clearCookies();
83
- await (0, _auth.performLoginSteps)(testDetails, async testInfo => {
87
+ const {
88
+ email
89
+ } = testPortalDetails;
90
+ await (0, _auth.performLoginSteps)({
91
+ page,
92
+ $tags,
93
+ context,
94
+ ...testPortalDetails
95
+ }, async testInfo => {
84
96
  return await verifyPageIsLoaded(testInfo);
85
97
  }, loginSteps);
86
98
  process.env.actorInfo = JSON.stringify(testPortalDetails);
87
99
  }
88
- } catch (e) {
89
- console.error('Error during page', e);
100
+ } catch (error) {
101
+ console.error('Error during page', error);
90
102
  } finally {
91
- await performDefaultPageSteps(testDetails);
103
+ await performDefaultPageSteps({
104
+ context,
105
+ $tags,
106
+ page
107
+ });
92
108
  await use(page);
93
109
  await context.close();
94
110
  }
@@ -9,6 +9,7 @@ var _path = _interopRequireDefault(require("path"));
9
9
  var _fileUtils = require("../../utils/fileUtils");
10
10
  var _logger = require("../../utils/logger");
11
11
  var _readConfigFile = require("./readConfigFile");
12
+ var _checkAuthDirectory = require("./helpers/checkAuthDirectory");
12
13
  function deleteAuthFiles(authFilePath) {
13
14
  authFilePath = _path.default.resolve(process.cwd(), authFilePath);
14
15
  const authFileFolder = _path.default.dirname(authFilePath);
@@ -24,6 +25,11 @@ function deleteGeneratedFeatures() {
24
25
  _logger.Logger.log(_logger.Logger.INFO_TYPE, `Deleting generated features at ${featuresGenPath}`);
25
26
  (0, _fileUtils.deleteFolder)(featuresGenPath);
26
27
  }
28
+ function deleteLockFiles() {
29
+ const lockFilePath = (0, _checkAuthDirectory.getLockDirectoryPath)();
30
+ _logger.Logger.log(_logger.Logger.INFO_TYPE, `Deleting lock files at ${lockFilePath}`);
31
+ (0, _fileUtils.deleteFolder)(lockFilePath);
32
+ }
27
33
  function clearCaches() {
28
34
  try {
29
35
  const {
@@ -33,6 +39,7 @@ function clearCaches() {
33
39
  deleteAuthFiles(authFilePath);
34
40
  deletePlaywrightReport(reportPath);
35
41
  deleteGeneratedFeatures();
42
+ deleteLockFiles();
36
43
  _logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Caches Cleared. Now you can try running npm run uat');
37
44
  } catch (err) {
38
45
  _logger.Logger.error(err);
@@ -25,9 +25,12 @@ async function performLoginSteps(testInfo, isLoggedIn, loginSteps) {
25
25
  try {
26
26
  await fileMutex.acquire();
27
27
  await (0, _checkAuthCookies.loadCookiesIfPresent)(page, authFile);
28
+ await page.goto(process.env.domain);
29
+ await Promise.race([page.waitForNavigation(), page.waitForLoadState('networkidle'), page.waitForTimeout(5000)]);
28
30
  const isAlreadyLoggedIn = await isLoggedIn(testInfo);
29
31
  if (!isAlreadyLoggedIn) {
30
32
  await loginSteps(testInfo);
33
+ await page.goto(process.env.domain);
31
34
  await isLoggedIn(testInfo);
32
35
  await page.context().storageState({
33
36
  path: authFile
package/build/index.js CHANGED
@@ -70,12 +70,6 @@ Object.defineProperty(exports, "performLoginSteps", {
70
70
  return _index.performLoginSteps;
71
71
  }
72
72
  });
73
- Object.defineProperty(exports, "setup", {
74
- enumerable: true,
75
- get: function () {
76
- return _index.setup;
77
- }
78
- });
79
73
  Object.defineProperty(exports, "test", {
80
74
  enumerable: true,
81
75
  get: function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/testinglibrary",
3
- "version": "0.4.37-experimental",
3
+ "version": "0.4.38-experimental",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {
@@ -22,8 +22,8 @@
22
22
  "license": "ISC",
23
23
  "dependencies": {
24
24
  "@babel/preset-react": "7.22.5",
25
- "@cucumber/cucumber": "11.0.1",
26
- "@playwright/test": "1.48.0",
25
+ "@cucumber/cucumber": "11.2.0",
26
+ "@playwright/test": "1.49.1",
27
27
  "@reportportal/agent-js-playwright": "5.1.11",
28
28
  "@testing-library/jest-dom": "5.11.9",
29
29
  "@testing-library/react": "11.2.7",
@@ -34,9 +34,9 @@
34
34
  "jest": "29.6.2",
35
35
  "jest-environment-jsdom": "29.6.2",
36
36
  "msw": "1.2.3",
37
- "playwright": "1.48.0",
37
+ "playwright": "1.49.1",
38
38
  "supports-color": "8.1.1",
39
- "playwright-bdd": "7.5.0",
39
+ "playwright-bdd": "8.0.1",
40
40
  "proper-lockfile": "4.1.2"
41
41
  },
42
42
  "bin": {