@applitools/eyes-cypress 3.24.0-beta.5 → 3.25.0

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.
Files changed (44) hide show
  1. package/CHANGELOG.md +2191 -2195
  2. package/LICENSE +25 -25
  3. package/README.md +803 -782
  4. package/bin/eyes-setup.js +21 -21
  5. package/commands.js +2 -2
  6. package/dist/browser/spec-driver.js +110 -106
  7. package/dist/plugin/handler.js +55 -55
  8. package/eyes-index.d.ts +34 -34
  9. package/index.js +2 -2
  10. package/package.json +98 -97
  11. package/src/browser/commands.js +188 -188
  12. package/src/browser/eyesCheckMapping.js +104 -103
  13. package/src/browser/eyesOpenMapping.js +60 -60
  14. package/src/browser/makeSend.js +18 -18
  15. package/src/browser/refer.js +57 -57
  16. package/src/browser/sendRequest.js +16 -16
  17. package/src/browser/socket.js +144 -143
  18. package/src/browser/socketCommands.js +81 -81
  19. package/src/browser/spec-driver.ts +117 -111
  20. package/src/pem/server.cert +22 -22
  21. package/src/pem/server.key +27 -27
  22. package/src/plugin/concurrencyMsg.js +8 -8
  23. package/src/plugin/config.js +54 -54
  24. package/src/plugin/defaultPort.js +1 -1
  25. package/src/plugin/errorDigest.js +96 -96
  26. package/src/plugin/getErrorsAndDiffs.js +34 -34
  27. package/src/plugin/handleTestResults.js +35 -39
  28. package/src/plugin/handler.ts +58 -58
  29. package/src/plugin/hooks.js +51 -50
  30. package/src/plugin/isGlobalHooksSupported.js +13 -13
  31. package/src/plugin/pluginExport.js +60 -60
  32. package/src/plugin/server.js +98 -98
  33. package/src/plugin/startPlugin.js +15 -13
  34. package/src/plugin/webSocket.js +130 -130
  35. package/src/setup/addEyesCommands.js +24 -24
  36. package/src/setup/addEyesCypressPlugin.js +15 -15
  37. package/src/setup/getCypressConfig.js +16 -16
  38. package/src/setup/getFilePath.js +22 -22
  39. package/src/setup/handleCommands.js +23 -23
  40. package/src/setup/handlePlugin.js +23 -23
  41. package/src/setup/handleTypeScript.js +21 -21
  42. package/src/setup/isCommandsDefined.js +7 -7
  43. package/src/setup/isPluginDefined.js +7 -7
  44. package/test/fixtures/testAppCopies/.gitignore +1 -1
@@ -1,103 +1,104 @@
1
- function eyesCheckMapValues({args}) {
2
- return toCheckWindowConfiguration(args);
3
- }
4
-
5
- function toCheckWindowConfiguration(config = {}) {
6
- const mappedValues = [
7
- 'tag',
8
- 'hooks',
9
- 'ignore',
10
- 'floating',
11
- 'strict',
12
- 'layout',
13
- 'content',
14
- 'accessibility',
15
- 'region',
16
- 'selector',
17
- ];
18
-
19
- let regionSettings = {};
20
- let shadowDomSettings = {};
21
- const checkSettings = {
22
- name: config.tag,
23
- scriptHooks: config.hooks,
24
- ignoreRegions: config.ignore,
25
- floatingRegions: convertFloatingRegion(config.floating),
26
- strictRegions: config.strict,
27
- layoutRegions: config.layout,
28
- contentRegions: config.content,
29
- accessibilityRegions: convertAccessabilityRegions(config.accessibility),
30
- };
31
-
32
- if (config.target === 'region') {
33
- if (!Array.isArray(config.selector)) {
34
- if (!config.hasOwnProperty('selector')) {
35
- regionSettings = {
36
- region: config.region,
37
- };
38
- } else {
39
- regionSettings = {
40
- region: config.selector,
41
- };
42
- }
43
- } else {
44
- const selectors = config.selector;
45
- for (let i = selectors.length - 1; i > -1; i--) {
46
- if (i === selectors.length - 1) {
47
- shadowDomSettings['shadow'] = selectors[i].selector;
48
- } else {
49
- const prevSettings = Object.assign({}, shadowDomSettings);
50
- shadowDomSettings['selector'] = selectors[i].selector;
51
- if (!prevSettings.hasOwnProperty('selector')) {
52
- shadowDomSettings['shadow'] = prevSettings.shadow;
53
- } else {
54
- shadowDomSettings['shadow'] = prevSettings;
55
- }
56
- }
57
- }
58
- regionSettings = {region: shadowDomSettings};
59
- }
60
- }
61
-
62
- for (const val of mappedValues) {
63
- if (config.hasOwnProperty(val)) {
64
- delete config[val];
65
- }
66
- }
67
-
68
- return Object.assign({}, checkSettings, regionSettings, config);
69
- }
70
-
71
- function convertAccessabilityRegions(accessibilityRegions) {
72
- if (!accessibilityRegions) return accessibilityRegions;
73
-
74
- return accessibilityRegions.map(region => ({
75
- region: region.selector,
76
- type: region.accessibilityType,
77
- }))
78
- }
79
-
80
- function convertFloatingRegion(floatingRegions){
81
- if(!floatingRegions) return floatingRegions
82
-
83
- return floatingRegions.map(region => {
84
- const floatingRegion = {
85
- maxDownOffset: region.maxDownOffset || 0,
86
- maxLeftOffset: region.maxLeftOffset || 0,
87
- maxUpOffset: region.maxUpOffset || 0,
88
- maxRightOffset: region.maxRightOffset || 0
89
- }
90
- if(region.hasOwnProperty('selector')){
91
- floatingRegion.region = region.selector
92
- } else {
93
- floatingRegion.region = {
94
- top: region.top,
95
- left: region.left,
96
- width: region.width,
97
- height: region.height,
98
- }
99
- }
100
- })
101
- }
102
-
103
- module.exports = {eyesCheckMapValues};
1
+ function eyesCheckMapValues({args}) {
2
+ return toCheckWindowConfiguration(args);
3
+ }
4
+
5
+ function toCheckWindowConfiguration(config = {}) {
6
+ const mappedValues = [
7
+ 'tag',
8
+ 'hooks',
9
+ 'ignore',
10
+ 'floating',
11
+ 'strict',
12
+ 'layout',
13
+ 'content',
14
+ 'accessibility',
15
+ 'region',
16
+ 'selector',
17
+ ];
18
+
19
+ let regionSettings = {};
20
+ let shadowDomSettings = {};
21
+ const checkSettings = {
22
+ name: config.tag,
23
+ scriptHooks: config.hooks,
24
+ ignoreRegions: config.ignore,
25
+ floatingRegions: convertFloatingRegion(config.floating),
26
+ strictRegions: config.strict,
27
+ layoutRegions: config.layout,
28
+ contentRegions: config.content,
29
+ accessibilityRegions: convertAccessabilityRegions(config.accessibility),
30
+ };
31
+
32
+ if (config.target === 'region') {
33
+ if (!Array.isArray(config.selector)) {
34
+ if (!config.hasOwnProperty('selector')) {
35
+ regionSettings = {
36
+ region: config.region,
37
+ };
38
+ } else {
39
+ regionSettings = {
40
+ region: config.selector,
41
+ };
42
+ }
43
+ } else {
44
+ const selectors = config.selector;
45
+ for (let i = selectors.length - 1; i > -1; i--) {
46
+ if (i === selectors.length - 1) {
47
+ shadowDomSettings['shadow'] = selectors[i].selector;
48
+ } else {
49
+ const prevSettings = Object.assign({}, shadowDomSettings);
50
+ shadowDomSettings['selector'] = selectors[i].selector;
51
+ if (!prevSettings.hasOwnProperty('selector')) {
52
+ shadowDomSettings['shadow'] = prevSettings.shadow;
53
+ } else {
54
+ shadowDomSettings['shadow'] = prevSettings;
55
+ }
56
+ }
57
+ }
58
+ regionSettings = {region: shadowDomSettings};
59
+ }
60
+ }
61
+
62
+ for (const val of mappedValues) {
63
+ if (config.hasOwnProperty(val)) {
64
+ delete config[val];
65
+ }
66
+ }
67
+
68
+ return Object.assign({}, checkSettings, regionSettings, config);
69
+ }
70
+
71
+ function convertAccessabilityRegions(accessibilityRegions) {
72
+ if (!accessibilityRegions) return accessibilityRegions;
73
+
74
+ return accessibilityRegions.map(region => ({
75
+ region: region.selector,
76
+ type: region.accessibilityType,
77
+ }));
78
+ }
79
+
80
+ function convertFloatingRegion(floatingRegions) {
81
+ if (!floatingRegions) return floatingRegions;
82
+
83
+ return floatingRegions.map(region => {
84
+ const floatingRegion = {
85
+ maxDownOffset: region.maxDownOffset || 0,
86
+ maxLeftOffset: region.maxLeftOffset || 0,
87
+ maxUpOffset: region.maxUpOffset || 0,
88
+ maxRightOffset: region.maxRightOffset || 0,
89
+ };
90
+ if (region.hasOwnProperty('selector')) {
91
+ floatingRegion.region = region.selector;
92
+ } else {
93
+ floatingRegion.region = {
94
+ top: region.top,
95
+ left: region.left,
96
+ width: region.width,
97
+ height: region.height,
98
+ };
99
+ }
100
+ return floatingRegion;
101
+ });
102
+ }
103
+
104
+ module.exports = {eyesCheckMapValues};
@@ -1,60 +1,60 @@
1
- function eyesOpenMapValues({args, appliConfFile, testName, shouldUseBrowserHooks}) {
2
- let browsersInfo = args.browser || appliConfFile.browser;
3
- let accessibilitySettings = args.accessibilityValidation || appliConfFile.accessibilityValidation;
4
- const mappedValues = [
5
- 'accessibilityValidation',
6
- 'browser',
7
- 'useDom',
8
- 'matchLevel',
9
- 'enablePatterns',
10
- 'ignoreDisplacements',
11
- 'ignoreCaret',
12
- ];
13
-
14
- if (browsersInfo) {
15
- if (Array.isArray(browsersInfo)) {
16
- browsersInfo.forEach(fillDefaultBrowserName);
17
- } else {
18
- fillDefaultBrowserName(browsersInfo);
19
- browsersInfo = [browsersInfo];
20
- }
21
- }
22
-
23
- const defaultMatchSettings = {
24
- accessibilitySettings,
25
- matchLevel: args.matchLevel || appliConfFile.matchLevel,
26
- ignoreCaret: args.ignoreCaret || appliConfFile.ignoreCaret,
27
- useDom: args.useDom || appliConfFile.useDom,
28
- enablePatterns: args.enablePatterns || appliConfFile.enablePatterns,
29
- ignoreDisplacements: args.ignoreDisplacements || appliConfFile.ignoreDisplacements,
30
- };
31
-
32
- for (const val of mappedValues) {
33
- if (args.hasOwnProperty(val)) {
34
- delete args[val];
35
- }
36
- if (appliConfFile.hasOwnProperty(val)) {
37
- delete appliConfFile[val];
38
- }
39
- }
40
-
41
- const mappedArgs = {
42
- ...args,
43
- browsersInfo,
44
- defaultMatchSettings,
45
- };
46
-
47
- return Object.assign(
48
- {testName, dontCloseBatches: !shouldUseBrowserHooks},
49
- appliConfFile,
50
- mappedArgs,
51
- );
52
- }
53
-
54
- function fillDefaultBrowserName(browser) {
55
- if (!browser.name && !browser.iosDeviceInfo && !browser.chromeEmulationInfo) {
56
- browser.name = 'chrome';
57
- }
58
- }
59
-
60
- module.exports = {eyesOpenMapValues};
1
+ function eyesOpenMapValues({args, appliConfFile, testName, shouldUseBrowserHooks}) {
2
+ let browsersInfo = args.browser || appliConfFile.browser;
3
+ let accessibilitySettings = args.accessibilityValidation || appliConfFile.accessibilityValidation;
4
+ const mappedValues = [
5
+ 'accessibilityValidation',
6
+ 'browser',
7
+ 'useDom',
8
+ 'matchLevel',
9
+ 'enablePatterns',
10
+ 'ignoreDisplacements',
11
+ 'ignoreCaret',
12
+ ];
13
+
14
+ if (browsersInfo) {
15
+ if (Array.isArray(browsersInfo)) {
16
+ browsersInfo.forEach(fillDefaultBrowserName);
17
+ } else {
18
+ fillDefaultBrowserName(browsersInfo);
19
+ browsersInfo = [browsersInfo];
20
+ }
21
+ }
22
+
23
+ const defaultMatchSettings = {
24
+ accessibilitySettings,
25
+ matchLevel: args.matchLevel || appliConfFile.matchLevel,
26
+ ignoreCaret: args.ignoreCaret || appliConfFile.ignoreCaret,
27
+ useDom: args.useDom || appliConfFile.useDom,
28
+ enablePatterns: args.enablePatterns || appliConfFile.enablePatterns,
29
+ ignoreDisplacements: args.ignoreDisplacements || appliConfFile.ignoreDisplacements,
30
+ };
31
+
32
+ for (const val of mappedValues) {
33
+ if (args.hasOwnProperty(val)) {
34
+ delete args[val];
35
+ }
36
+ if (appliConfFile.hasOwnProperty(val)) {
37
+ delete appliConfFile[val];
38
+ }
39
+ }
40
+
41
+ const mappedArgs = {
42
+ ...args,
43
+ browsersInfo,
44
+ defaultMatchSettings,
45
+ };
46
+
47
+ return Object.assign(
48
+ {testName, dontCloseBatches: !shouldUseBrowserHooks},
49
+ appliConfFile,
50
+ mappedArgs,
51
+ );
52
+ }
53
+
54
+ function fillDefaultBrowserName(browser) {
55
+ if (!browser.name && !browser.iosDeviceInfo && !browser.chromeEmulationInfo) {
56
+ browser.name = 'chrome';
57
+ }
58
+ }
59
+
60
+ module.exports = {eyesOpenMapValues};
@@ -1,18 +1,18 @@
1
- 'use strict';
2
-
3
- function makeSend(port, fetch) {
4
- return function send({
5
- command,
6
- data,
7
- method = 'POST',
8
- headers = {'Content-Type': 'application/json'},
9
- }) {
10
- return fetch(`https://localhost:${port}/eyes/${command}`, {
11
- method,
12
- body: headers['Content-Type'] === 'application/json' ? JSON.stringify(data) : data,
13
- headers,
14
- });
15
- };
16
- }
17
-
18
- module.exports = makeSend;
1
+ 'use strict';
2
+
3
+ function makeSend(port, fetch) {
4
+ return function send({
5
+ command,
6
+ data,
7
+ method = 'POST',
8
+ headers = {'Content-Type': 'application/json'},
9
+ }) {
10
+ return fetch(`https://localhost:${port}/eyes/${command}`, {
11
+ method,
12
+ body: headers['Content-Type'] === 'application/json' ? JSON.stringify(data) : data,
13
+ headers,
14
+ });
15
+ };
16
+ }
17
+
18
+ module.exports = makeSend;
@@ -1,57 +1,57 @@
1
- const uuid = require('uuid');
2
-
3
- const REF_ID = 'applitools-ref-id';
4
- class Refer {
5
- constructor(check) {
6
- this.store = new Map();
7
- this.relation = new Map();
8
- this.check = check;
9
- }
10
-
11
- isRef(ref) {
12
- return Boolean(ref && ref[REF_ID]);
13
- }
14
-
15
- ref(value, parentRef) {
16
- if (this.check(value)) {
17
- const ref = uuid.v4();
18
- this.store.set(ref, value);
19
- if (parentRef) {
20
- let childRefs = this.relation.get(parentRef[REF_ID]);
21
- if (!childRefs) {
22
- childRefs = new Set();
23
- this.relation.set(parentRef[REF_ID], childRefs);
24
- }
25
- childRefs.add({[REF_ID]: ref});
26
- }
27
- return {[REF_ID]: ref};
28
- } else if (Array.isArray(value)) {
29
- return value.map(value => this.ref(value, parentRef));
30
- } else if (typeof value === 'object' && value !== null) {
31
- return Object.entries(value).reduce((obj, [key, value]) => {
32
- return Object.assign(obj, {[key]: this.ref(value, parentRef)});
33
- }, {});
34
- } else {
35
- return value;
36
- }
37
- }
38
-
39
- deref(ref) {
40
- if (this.isRef(ref)) {
41
- return this.store.get(ref[REF_ID]);
42
- } else {
43
- return ref;
44
- }
45
- }
46
-
47
- destroy(ref) {
48
- if (!this.isRef(ref)) return;
49
- const childRefs = this.relation.get(ref[REF_ID]);
50
- if (childRefs) {
51
- childRefs.forEach(childRef => this.destroy(childRef));
52
- }
53
- this.store.delete(ref[REF_ID]);
54
- }
55
- }
56
-
57
- module.exports = Refer;
1
+ const uuid = require('uuid');
2
+
3
+ const REF_ID = 'applitools-ref-id';
4
+ class Refer {
5
+ constructor(check) {
6
+ this.store = new Map();
7
+ this.relation = new Map();
8
+ this.check = check;
9
+ }
10
+
11
+ isRef(ref) {
12
+ return Boolean(ref && ref[REF_ID]);
13
+ }
14
+
15
+ ref(value, parentRef) {
16
+ if (this.check(value)) {
17
+ const ref = uuid.v4();
18
+ this.store.set(ref, value);
19
+ if (parentRef) {
20
+ let childRefs = this.relation.get(parentRef[REF_ID]);
21
+ if (!childRefs) {
22
+ childRefs = new Set();
23
+ this.relation.set(parentRef[REF_ID], childRefs);
24
+ }
25
+ childRefs.add({[REF_ID]: ref});
26
+ }
27
+ return {[REF_ID]: ref};
28
+ } else if (Array.isArray(value)) {
29
+ return value.map(value => this.ref(value, parentRef));
30
+ } else if (typeof value === 'object' && value !== null) {
31
+ return Object.entries(value).reduce((obj, [key, value]) => {
32
+ return Object.assign(obj, {[key]: this.ref(value, parentRef)});
33
+ }, {});
34
+ } else {
35
+ return value;
36
+ }
37
+ }
38
+
39
+ deref(ref) {
40
+ if (this.isRef(ref)) {
41
+ return this.store.get(ref[REF_ID]);
42
+ } else {
43
+ return ref;
44
+ }
45
+ }
46
+
47
+ destroy(ref) {
48
+ if (!this.isRef(ref)) return;
49
+ const childRefs = this.relation.get(ref[REF_ID]);
50
+ if (childRefs) {
51
+ childRefs.forEach(childRef => this.destroy(childRef));
52
+ }
53
+ this.store.delete(ref[REF_ID]);
54
+ }
55
+ }
56
+
57
+ module.exports = Refer;
@@ -1,16 +1,16 @@
1
- 'use strict';
2
-
3
- function makeSendRequest(send) {
4
- return function sendRequest(args) {
5
- return send(args)
6
- .then(resp => resp.json())
7
- .then(body => {
8
- if (!body.success) {
9
- throw new Error(body.error);
10
- }
11
- return body.result;
12
- });
13
- };
14
- }
15
-
16
- module.exports = makeSendRequest;
1
+ 'use strict';
2
+
3
+ function makeSendRequest(send) {
4
+ return function sendRequest(args) {
5
+ return send(args)
6
+ .then(resp => resp.json())
7
+ .then(body => {
8
+ if (!body.success) {
9
+ throw new Error(body.error);
10
+ }
11
+ return body.result;
12
+ });
13
+ };
14
+ }
15
+
16
+ module.exports = makeSendRequest;