@applitools/eyes-cypress 3.40.6 → 3.40.7

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,53 @@
1
1
  # Changelog
2
2
 
3
+ ## [3.40.7](https://github.com/applitools/eyes.sdk.javascript1/compare/js/eyes-cypress@3.40.6...js/eyes-cypress@3.40.7) (2024-01-30)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * losing root context after layout breakpoints reload ([#2113](https://github.com/applitools/eyes.sdk.javascript1/issues/2113)) ([afa1473](https://github.com/applitools/eyes.sdk.javascript1/commit/afa14735e5539ab0f79aa610e6ec1ea8989a5922))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * @applitools/snippets bumped to 2.4.25
14
+ #### Bug Fixes
15
+
16
+ * losing root context after layout breakpoints reload ([#2113](https://github.com/applitools/eyes.sdk.javascript1/issues/2113)) ([afa1473](https://github.com/applitools/eyes.sdk.javascript1/commit/afa14735e5539ab0f79aa610e6ec1ea8989a5922))
17
+ * @applitools/driver bumped to 1.16.2
18
+ #### Bug Fixes
19
+
20
+ * losing root context after layout breakpoints reload ([#2113](https://github.com/applitools/eyes.sdk.javascript1/issues/2113)) ([afa1473](https://github.com/applitools/eyes.sdk.javascript1/commit/afa14735e5539ab0f79aa610e6ec1ea8989a5922))
21
+
22
+
23
+
24
+ * @applitools/spec-driver-webdriver bumped to 1.0.55
25
+
26
+ * @applitools/spec-driver-selenium bumped to 1.5.69
27
+
28
+ * @applitools/spec-driver-puppeteer bumped to 1.3.5
29
+
30
+ * @applitools/screenshoter bumped to 3.8.21
31
+
32
+ * @applitools/nml-client bumped to 1.6.5
33
+
34
+ * @applitools/ec-client bumped to 1.7.23
35
+
36
+ * @applitools/core bumped to 4.7.0
37
+ #### Features
38
+
39
+ * added support of proxy server url env var ([#2159](https://github.com/applitools/eyes.sdk.javascript1/issues/2159)) ([2f69c3d](https://github.com/applitools/eyes.sdk.javascript1/commit/2f69c3d37d7af9be1f459fd3d5f41b361161b5bf))
40
+
41
+
42
+ #### Bug Fixes
43
+
44
+ * losing root context after layout breakpoints reload ([#2113](https://github.com/applitools/eyes.sdk.javascript1/issues/2113)) ([afa1473](https://github.com/applitools/eyes.sdk.javascript1/commit/afa14735e5539ab0f79aa610e6ec1ea8989a5922))
45
+
46
+
47
+
48
+ * @applitools/eyes bumped to 1.13.6
49
+
50
+
3
51
  ## [3.40.6](https://github.com/applitools/eyes.sdk.javascript1/compare/js/eyes-cypress@3.40.5...js/eyes-cypress@3.40.6) (2024-01-16)
4
52
 
5
53
 
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCookies = exports.getUrl = exports.getTitle = exports.findElements = exports.findElement = exports.transformSelector = exports.setViewportSize = exports.getViewportSize = exports.childContext = exports.parentContext = exports.mainContext = exports.executeScript = void 0;
3
+ exports.reload = exports.getCookies = exports.getUrl = exports.getTitle = exports.findElements = exports.findElement = exports.transformSelector = exports.setViewportSize = exports.getViewportSize = exports.childContext = exports.parentContext = exports.mainContext = exports.executeScript = void 0;
4
4
  function executeScript(context, script, arg) {
5
5
  let scriptToExecute;
6
6
  if (script.includes('dom-snapshot') || script.includes('dom-capture') || script.includes('dom-shared')) {
@@ -12,7 +12,7 @@ function executeScript(context, script, arg) {
12
12
  }
13
13
  if (!context.defaultView) {
14
14
  // after reload the window is null
15
- context = fallBackToMainContext();
15
+ context = mainContext();
16
16
  }
17
17
  const executor = new context.defaultView.Function('arg', scriptToExecute);
18
18
  return executor(arg);
@@ -20,7 +20,10 @@ function executeScript(context, script, arg) {
20
20
  exports.executeScript = executeScript;
21
21
  function mainContext() {
22
22
  //@ts-ignore
23
- return cy.state('window').document;
23
+ const win = cy.state('window');
24
+ // after reload the marker may be lost
25
+ win.parent.document['applitools-marker'] = 'root-context';
26
+ return win.document;
24
27
  }
25
28
  exports.mainContext = mainContext;
26
29
  function parentContext(context) {
@@ -30,7 +33,7 @@ function parentContext(context) {
30
33
  }
31
34
  else if (!context.defaultView) {
32
35
  // after reload the window is null
33
- return fallBackToMainContext();
36
+ return mainContext();
34
37
  }
35
38
  return context === mainContext() ? context : context.defaultView.frameElement.ownerDocument;
36
39
  }
@@ -104,7 +107,7 @@ exports.getTitle = getTitle;
104
107
  function getUrl(context) {
105
108
  if (context && !context.location) {
106
109
  // after reload, the location is null
107
- context = fallBackToMainContext();
110
+ context = mainContext();
108
111
  }
109
112
  return context.location.href;
110
113
  }
@@ -114,12 +117,14 @@ function getCookies() {
114
117
  return Cypress.automation('get:cookies', {});
115
118
  }
116
119
  exports.getCookies = getCookies;
117
- function fallBackToMainContext() {
118
- const context = mainContext();
119
- //@ts-ignore
120
- context['applitools-marker'] = 'root-context';
121
- return context;
120
+ function reload() {
121
+ return new Promise(resolve => {
122
+ cy.once('window:load', resolve);
123
+ //@ts-ignore
124
+ return cy.state('window').location.reload();
125
+ });
122
126
  }
127
+ exports.reload = reload;
123
128
  // export function takeScreenshot(page: Driver): Promise<Buffer>;
124
129
  // export function visit(page: Driver, url: string): Promise<void>; (??)
125
130
  // export function isStaleElementError(err: any): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/eyes-cypress",
3
- "version": "3.40.6",
3
+ "version": "3.40.7",
4
4
  "homepage": "https://applitools.com/docs/api-ref/sdk-api/cypress/",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "main": "./index.js",
@@ -42,6 +42,7 @@
42
42
  "test:ts:run:13": "yarn cypress13 run --project ./test/e2e/ts --config-file ./cypress-13.config.ts",
43
43
  "test:ts:run": "yarn cypress$APPLITOOLS_FRAMEWORK_VERSION run --project ./test/e2e/ts --config-file ./cypress-$APPLITOOLS_FRAMEWORK_VERSION.config.ts",
44
44
  "test:coverage": "cd test/generic && yarn && MOCHA_GROUP=coverage APPLITOOLS_BATCH_NAME='JS Coverage Tests: eyes-cypress' APPLITOOLS_BATCH_ID=$(uuidgen) npx cypress run",
45
+ "test:coverage:chrome": "cd test/generic && yarn && MOCHA_GROUP=coverage APPLITOOLS_BATCH_NAME='JS Coverage Tests: eyes-cypress' APPLITOOLS_BATCH_ID=$(uuidgen) npx cypress run --browser chrome",
45
46
  "test:e2e": "MOCHA_GROUP=e2e mkdir -p test/fixtures/testAppCopies && run --top-level mocha --no-timeouts --parallel --jobs ${MOCHA_JOBS:-2} 'test/e2e/**/*.test.js'",
46
47
  "test:components": "cd test/components && yarn && npx cypress run --component",
47
48
  "cypress": "cypress open --config-file test/fixtures/cypress-play.json",
@@ -53,8 +54,8 @@
53
54
  "setup": "run --top-level xvfb:setup"
54
55
  },
55
56
  "dependencies": {
56
- "@applitools/core": "4.6.0",
57
- "@applitools/eyes": "1.13.5",
57
+ "@applitools/core": "4.7.0",
58
+ "@applitools/eyes": "1.13.6",
58
59
  "@applitools/functional-commons": "1.6.0",
59
60
  "@applitools/logger": "2.0.14",
60
61
  "@applitools/utils": "1.7.0",
@@ -66,7 +67,7 @@
66
67
  },
67
68
  "devDependencies": {
68
69
  "@applitools/api-extractor": "^1.2.22",
69
- "@applitools/bongo": "^5.7.6",
70
+ "@applitools/bongo": "^5.9.0",
70
71
  "@applitools/generic": "^3.5.2",
71
72
  "@applitools/snaptdout": "^1.0.1",
72
73
  "@applitools/test-server": "^1.2.2",
@@ -159,7 +159,6 @@ Cypress.Commands.add('eyesCheckWindow', (args = {}) =>
159
159
  cy.then({timeout: 86400000}, () => {
160
160
  if (isCurrentTestDisabled) return
161
161
 
162
- setRootContext()
163
162
  const target = refer.ref(cy.state('window').document)
164
163
 
165
164
  Cypress.log({name: 'Eyes: check window'})
@@ -203,5 +202,5 @@ Cypress.Commands.add('debugHistory', async function () {
203
202
  })
204
203
 
205
204
  function setRootContext() {
206
- cy.state('window').document['applitools-marker'] = 'root-context'
205
+ cy.state('window').parent.document['applitools-marker'] = 'root-context'
207
206
  }
@@ -45,6 +45,10 @@ function socketCommands(socket, refer) {
45
45
  return await spec.getCookies()
46
46
  })
47
47
 
48
+ socket.command('Driver.reload', async () => {
49
+ await spec.reload()
50
+ })
51
+
48
52
  // utils
49
53
 
50
54
  function derefArgs(arg) {
@@ -13,7 +13,7 @@ export function executeScript(context: Context, script: string, arg: any): any {
13
13
  }
14
14
  if (!context.defaultView) {
15
15
  // after reload the window is null
16
- context = fallBackToMainContext()
16
+ context = mainContext()
17
17
  }
18
18
  const executor = new context.defaultView.Function('arg', scriptToExecute)
19
19
  return executor(arg)
@@ -21,7 +21,10 @@ export function executeScript(context: Context, script: string, arg: any): any {
21
21
 
22
22
  export function mainContext(): Context {
23
23
  //@ts-ignore
24
- return cy.state('window').document
24
+ const win = cy.state('window')
25
+ // after reload the marker may be lost
26
+ win.parent.document['applitools-marker'] = 'root-context'
27
+ return win.document
25
28
  }
26
29
 
27
30
  export function parentContext(context: Context): Context {
@@ -30,7 +33,7 @@ export function parentContext(context: Context): Context {
30
33
  throw new Error('Context is not accessible')
31
34
  } else if (!context.defaultView) {
32
35
  // after reload the window is null
33
- return fallBackToMainContext()
36
+ return mainContext()
34
37
  }
35
38
 
36
39
  return context === mainContext() ? context : context.defaultView.frameElement.ownerDocument
@@ -107,7 +110,7 @@ export function getTitle(context: Context): string {
107
110
  export function getUrl(context: Context): string {
108
111
  if (context && !context.location) {
109
112
  // after reload, the location is null
110
- context = fallBackToMainContext()
113
+ context = mainContext()
111
114
  }
112
115
  return context.location.href
113
116
  }
@@ -117,11 +120,12 @@ export function getCookies(): Array<any> {
117
120
  return Cypress.automation('get:cookies', {})
118
121
  }
119
122
 
120
- function fallBackToMainContext(): Context {
121
- const context = mainContext()
122
- //@ts-ignore
123
- context['applitools-marker'] = 'root-context'
124
- return context
123
+ export function reload(): Promise<void> {
124
+ return new Promise(resolve => {
125
+ cy.once('window:load', resolve)
126
+ //@ts-ignore
127
+ return cy.state('window').location.reload()
128
+ })
125
129
  }
126
130
 
127
131
  // export function takeScreenshot(page: Driver): Promise<Buffer>;