@zohodesk/testinglibrary 0.2.3 → 0.2.4

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.
@@ -20,11 +20,19 @@ function replaceI18NValuesWithRegex(i18nStr, values) {
20
20
  }
21
21
  return i18nStr;
22
22
  }
23
+ async function isI18NKeyDefined(key) {
24
+ return new Promise(resolve => {
25
+ if (typeof window.i18n[key] !== 'undefined') {
26
+ resolve();
27
+ }
28
+ });
29
+ }
23
30
  var _default = exports.default = {
24
31
  i18N: async ({
25
32
  page
26
33
  }, use) => {
27
34
  await use(async (key, values) => {
35
+ await page.waitForFunction(isI18NKeyDefined(key));
28
36
  const i18nValue = await page.evaluate(i18nKey => window.i18n[i18nKey], key);
29
37
  const i18nStr = replaceI18NValuesWithRegex(i18nValue, values);
30
38
  return i18nStr;
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.default = void 0;
7
8
  var _auth = require("../helpers/auth");
9
+ var _getUrlOrigin = _interopRequireDefault(require("../helpers/auth/getUrlOrigin"));
8
10
  var _readConfigFile = require("../readConfigFile");
9
11
  /* eslint-disable global-require */
10
12
 
@@ -47,6 +49,14 @@ async function performDefaultPageSteps({
47
49
  await page.goto(process.env.domain);
48
50
  }
49
51
  }
52
+ async function verifyPageIsLoaded(page) {
53
+ const urlOrigin = (0, _getUrlOrigin.default)(page.url());
54
+ const domainOrigin = (0, _getUrlOrigin.default)(process.env.domain);
55
+ if (urlOrigin === domainOrigin) {
56
+ return true;
57
+ }
58
+ return false;
59
+ }
50
60
  var _default = exports.default = {
51
61
  page: async ({
52
62
  context,
@@ -74,7 +84,9 @@ var _default = exports.default = {
74
84
  authFilePrefix: email,
75
85
  useremail: email,
76
86
  password: password
77
- }, async () => page.url().includes(process.env.domain));
87
+ }, async () => {
88
+ return await verifyPageIsLoaded(page);
89
+ });
78
90
  process.env.actorInfo = JSON.stringify(testPortalDetails);
79
91
  await performDefaultPageSteps({
80
92
  context,
@@ -19,7 +19,12 @@ async function performLoginSteps({
19
19
  const authFile = _path.default.resolve(_path.default.join((0, _checkAuthCookies.getAuthFileDirectory)(), `${authFilePrefix}-cookies.json`));
20
20
  await (0, _checkAuthCookies.loadCookiesIfPresent)(page, authFile);
21
21
  await page.goto(process.env.domain);
22
- await page.waitForNavigation();
22
+
23
+ // await page.waitForNavigation();
24
+
25
+ // await page.waitForLoadState('networkidle')
26
+
27
+ await Promise.race([page.waitForNavigation(), page.waitForLoadState('networkidle'), page.waitForTimeout(5000)]);
23
28
  const loginStatus = await isLoggedIn(page);
24
29
  if (!loginStatus) {
25
30
  await (0, _accountLogin.default)(page, useremail, password);
package/changelog.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # Testing Framework
2
2
 
3
3
  ## Framework that abstracts the configuration for playwright and Jest
4
+ # 0.2.4
5
+ - Issue fixes on custom fixtures
6
+ - Page Fixture
7
+ - i18n Fixture
8
+
4
9
  # 0.2.1
5
10
  **Issue Fixes**
6
11
  - Fixes issue in actors configuration
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/testinglibrary",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {