@applitools/eyes-cypress 3.28.1 → 3.28.2
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 +7 -0
- package/dist/browser/spec-driver.js +2 -5
- package/index.d.ts +7 -6
- package/package.json +8 -8
- package/src/browser/eyesCheckMapping.js +10 -2
- package/src/browser/spec-driver.ts +33 -41
package/CHANGELOG.md
CHANGED
|
@@ -12,6 +12,13 @@
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
+
## 3.28.2 - 2023/1/17
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
### Bug fixes
|
|
19
|
+
- Fix types to include region options when passing an element
|
|
20
|
+
- Add support for region options for coded floating and accessibility when using elements
|
|
21
|
+
|
|
15
22
|
## 3.28.1 - 2023/1/5
|
|
16
23
|
|
|
17
24
|
### Features
|
|
@@ -3,9 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
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;
|
|
4
4
|
function executeScript(context, script, arg) {
|
|
5
5
|
let scriptToExecute;
|
|
6
|
-
if (script.includes('dom-snapshot') ||
|
|
7
|
-
script.includes('dom-capture') ||
|
|
8
|
-
script.includes('dom-shared')) {
|
|
6
|
+
if (script.includes('dom-snapshot') || script.includes('dom-capture') || script.includes('dom-shared')) {
|
|
9
7
|
scriptToExecute = script;
|
|
10
8
|
}
|
|
11
9
|
else {
|
|
@@ -26,7 +24,6 @@ function parentContext(context) {
|
|
|
26
24
|
if (!context) {
|
|
27
25
|
throw new Error('Context is not accessible');
|
|
28
26
|
}
|
|
29
|
-
;
|
|
30
27
|
return context === mainContext() ? context : context.defaultView.frameElement.ownerDocument;
|
|
31
28
|
}
|
|
32
29
|
exports.parentContext = parentContext;
|
|
@@ -43,7 +40,7 @@ function getViewportSize() {
|
|
|
43
40
|
const currWindow = cy.state('window');
|
|
44
41
|
const viewportSize = {
|
|
45
42
|
width: currWindow.innerWidth || currWindow.document.documentElement.clientWidth || currWindow.document.body.clientWidth,
|
|
46
|
-
height: currWindow.innerHeight || currWindow.document.documentElement.clientHeight || currWindow.document.body.clientHeight
|
|
43
|
+
height: currWindow.innerHeight || currWindow.document.documentElement.clientHeight || currWindow.document.body.clientHeight,
|
|
47
44
|
};
|
|
48
45
|
return viewportSize;
|
|
49
46
|
}
|
package/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ type MaybeArray<T> = T | T[]
|
|
|
6
6
|
type LegacyRegion = {left: number; top: number; width: number; height: number}
|
|
7
7
|
type Selector = {selector: string; type?: 'css' | 'xpath', nodeType?: 'element' | 'shadow-root'} | 'string'
|
|
8
8
|
type Element = HTMLElement | JQuery<HTMLElement>
|
|
9
|
+
type ElementWithOptions = {element: Element, regionId?: string, padding?: any}
|
|
9
10
|
|
|
10
11
|
interface CypressCheckSettings extends api.CheckSettingsAutomationPlain<Element, Selector>{
|
|
11
12
|
tag?: CypressCheckSettings['name']
|
|
@@ -14,12 +15,12 @@ interface CypressCheckSettings extends api.CheckSettingsAutomationPlain<Element,
|
|
|
14
15
|
selector?: Selector
|
|
15
16
|
element?: Element
|
|
16
17
|
|
|
17
|
-
ignore?: MaybeArray<NonNullable<CypressCheckSettings['ignoreRegions']>[number] | LegacyRegion>
|
|
18
|
-
layout?: MaybeArray<NonNullable<CypressCheckSettings['layoutRegions']>[number] | LegacyRegion>
|
|
19
|
-
content?: MaybeArray<NonNullable<CypressCheckSettings['contentRegions']>[number] | LegacyRegion>
|
|
20
|
-
strict?: MaybeArray<NonNullable<CypressCheckSettings['strictRegions']>[number] | LegacyRegion>
|
|
21
|
-
floating?: MaybeArray<NonNullable<CypressCheckSettings['floatingRegions']>[number] | ((
|
|
22
|
-
accessibility?: MaybeArray<NonNullable<CypressCheckSettings['accessibilityRegions']>[number] | ((
|
|
18
|
+
ignore?: MaybeArray<NonNullable<CypressCheckSettings['ignoreRegions']>[number] | LegacyRegion | ElementWithOptions>
|
|
19
|
+
layout?: MaybeArray<NonNullable<CypressCheckSettings['layoutRegions']>[number] | LegacyRegion| ElementWithOptions>
|
|
20
|
+
content?: MaybeArray<NonNullable<CypressCheckSettings['contentRegions']>[number] | LegacyRegion| ElementWithOptions>
|
|
21
|
+
strict?: MaybeArray<NonNullable<CypressCheckSettings['strictRegions']>[number] | LegacyRegion | ElementWithOptions>
|
|
22
|
+
floating?: MaybeArray<NonNullable<CypressCheckSettings['floatingRegions']>[number] | ((ElementWithOptions | Selector | LegacyRegion) & {maxUpOffset?: number; maxDownOffset?: number; maxLeftOffset?: number; maxRightOffset?: number})>
|
|
23
|
+
accessibility?: MaybeArray<NonNullable<CypressCheckSettings['accessibilityRegions']>[number] | ((ElementWithOptions | Selector | LegacyRegion) & {accessibilityType?: api.AccessibilityRegionTypePlain})>
|
|
23
24
|
scriptHooks?: CypressCheckSettings['hooks']
|
|
24
25
|
ignoreCaret?: boolean
|
|
25
26
|
ignoreDisplacements?: boolean
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applitools/eyes-cypress",
|
|
3
|
-
"version": "3.28.
|
|
3
|
+
"version": "3.28.2",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git://github.com/applitools/eyes.sdk.javascript1.git",
|
|
@@ -56,11 +56,11 @@
|
|
|
56
56
|
}
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@applitools/core": "1.
|
|
60
|
-
"@applitools/eyes-api": "1.
|
|
59
|
+
"@applitools/core": "1.4.0",
|
|
60
|
+
"@applitools/eyes-api": "1.12.0",
|
|
61
61
|
"@applitools/eyes-universal": "2.18.0",
|
|
62
62
|
"@applitools/functional-commons": "1.6.0",
|
|
63
|
-
"@applitools/logger": "1.1.
|
|
63
|
+
"@applitools/logger": "1.1.40",
|
|
64
64
|
"chalk": "3.0.0",
|
|
65
65
|
"semver": "7.3.8",
|
|
66
66
|
"uuid": "8.3.2",
|
|
@@ -68,13 +68,13 @@
|
|
|
68
68
|
"ws": "8.5.0"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
|
-
"@applitools/bongo": "^2.2.
|
|
71
|
+
"@applitools/bongo": "^2.2.2",
|
|
72
72
|
"@applitools/scripts": "1.2.0",
|
|
73
73
|
"@applitools/sdk-coverage-tests": "^2.7.10",
|
|
74
74
|
"@applitools/snaptdout": "1.0.1",
|
|
75
|
-
"@applitools/test-server": "1.1.
|
|
76
|
-
"@applitools/test-utils": "1.5.
|
|
77
|
-
"@applitools/utils": "1.3.
|
|
75
|
+
"@applitools/test-server": "1.1.20",
|
|
76
|
+
"@applitools/test-utils": "1.5.8",
|
|
77
|
+
"@applitools/utils": "1.3.26",
|
|
78
78
|
"@types/node": "12",
|
|
79
79
|
"@types/which": "^2.0.1",
|
|
80
80
|
"@types/ws": "^8.2.2",
|
|
@@ -131,6 +131,9 @@ function eyesCheckMapValues({args, refer}) {
|
|
|
131
131
|
|
|
132
132
|
function convertAccessabilityRegions(accessibilityRegions) {
|
|
133
133
|
if (!accessibilityRegions) return accessibilityRegions
|
|
134
|
+
if (!Array.isArray(accessibilityRegions)) {
|
|
135
|
+
accessibilityRegions = [accessibilityRegions]
|
|
136
|
+
}
|
|
134
137
|
const accessibility = []
|
|
135
138
|
|
|
136
139
|
accessibilityRegions.map(region => {
|
|
@@ -142,8 +145,9 @@ function eyesCheckMapValues({args, refer}) {
|
|
|
142
145
|
accessibility.push(accessabilityRegion)
|
|
143
146
|
} else if (region.hasOwnProperty('element')) {
|
|
144
147
|
const elements = refElements(region.element)
|
|
148
|
+
delete region['element']
|
|
145
149
|
for (const element of elements) {
|
|
146
|
-
accessibility.push(Object.assign({}, accessabilityRegion, {region: element}))
|
|
150
|
+
accessibility.push(Object.assign({}, region, accessabilityRegion, {region: element}))
|
|
147
151
|
}
|
|
148
152
|
} else if (region.hasOwnProperty('region')) {
|
|
149
153
|
region.type = region.region.accessibilityType
|
|
@@ -165,6 +169,9 @@ function eyesCheckMapValues({args, refer}) {
|
|
|
165
169
|
|
|
166
170
|
function convertFloatingRegion(floatingRegions) {
|
|
167
171
|
if (!floatingRegions) return floatingRegions
|
|
172
|
+
if (!Array.isArray(floatingRegions)) {
|
|
173
|
+
floatingRegions = [floatingRegions]
|
|
174
|
+
}
|
|
168
175
|
const floating = []
|
|
169
176
|
|
|
170
177
|
for (const region of floatingRegions) {
|
|
@@ -179,8 +186,9 @@ function eyesCheckMapValues({args, refer}) {
|
|
|
179
186
|
floating.push(floatingRegion)
|
|
180
187
|
} else if (region.hasOwnProperty('element')) {
|
|
181
188
|
const elements = refElements(region.element)
|
|
189
|
+
delete region['element']
|
|
182
190
|
for (const element of elements) {
|
|
183
|
-
floating.push(Object.assign({}, floatingRegion, {region: element}))
|
|
191
|
+
floating.push(Object.assign({}, region, floatingRegion, {region: element}))
|
|
184
192
|
}
|
|
185
193
|
} else if (region.hasOwnProperty('region')) {
|
|
186
194
|
floating.push(region)
|
|
@@ -1,24 +1,19 @@
|
|
|
1
1
|
type EyesSelector = {selector: string; type?: string}
|
|
2
|
-
export type Selector = (string | EyesSelector) & {__applitoolsBrand?: never}
|
|
3
|
-
export type Context = Document & {__applitoolsBrand?: never}
|
|
4
|
-
export type Element = HTMLElement & {__applitoolsBrand?: never}
|
|
5
|
-
|
|
6
|
-
export function executeScript(context: Context, script: string, arg: any): any {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
scriptToExecute = prepScirpt.concat(' return func(arg)')
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const executor = new context.defaultView.Function('arg', scriptToExecute);
|
|
21
|
-
return executor(arg)
|
|
2
|
+
export type Selector = (string | EyesSelector) & {__applitoolsBrand?: never}
|
|
3
|
+
export type Context = Document & {__applitoolsBrand?: never}
|
|
4
|
+
export type Element = HTMLElement & {__applitoolsBrand?: never}
|
|
5
|
+
|
|
6
|
+
export function executeScript(context: Context, script: string, arg: any): any {
|
|
7
|
+
let scriptToExecute
|
|
8
|
+
if (script.includes('dom-snapshot') || script.includes('dom-capture') || script.includes('dom-shared')) {
|
|
9
|
+
scriptToExecute = script
|
|
10
|
+
} else {
|
|
11
|
+
const prepScirpt = script.replace('function(arg)', 'function func(arg)')
|
|
12
|
+
scriptToExecute = prepScirpt.concat(' return func(arg)')
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const executor = new context.defaultView.Function('arg', scriptToExecute)
|
|
16
|
+
return executor(arg)
|
|
22
17
|
}
|
|
23
18
|
|
|
24
19
|
export function mainContext(): Context {
|
|
@@ -30,14 +25,13 @@ export function parentContext(context: Context): Context {
|
|
|
30
25
|
// because Cypress doesn't support cross origin iframe, then childContext might return null, and then the input to parentContext might be null
|
|
31
26
|
if (!context) {
|
|
32
27
|
throw new Error('Context is not accessible')
|
|
33
|
-
}
|
|
34
|
-
|
|
28
|
+
}
|
|
29
|
+
|
|
35
30
|
return context === mainContext() ? context : context.defaultView.frameElement.ownerDocument
|
|
36
31
|
}
|
|
37
32
|
|
|
38
33
|
export function childContext(_context: Context, element: HTMLIFrameElement): Context {
|
|
39
|
-
if(element.contentDocument)
|
|
40
|
-
return element.contentDocument
|
|
34
|
+
if (element.contentDocument) return element.contentDocument
|
|
41
35
|
else {
|
|
42
36
|
throw new Error('Context is not accessible')
|
|
43
37
|
}
|
|
@@ -47,48 +41,47 @@ export function getViewportSize(): Object {
|
|
|
47
41
|
//@ts-ignore
|
|
48
42
|
const currWindow = cy.state('window')
|
|
49
43
|
const viewportSize = {
|
|
50
|
-
width:
|
|
51
|
-
height: currWindow.innerHeight || currWindow.document.documentElement.clientHeight || currWindow.document.body.clientHeight
|
|
52
|
-
}
|
|
53
|
-
return viewportSize
|
|
44
|
+
width: currWindow.innerWidth || currWindow.document.documentElement.clientWidth || currWindow.document.body.clientWidth,
|
|
45
|
+
height: currWindow.innerHeight || currWindow.document.documentElement.clientHeight || currWindow.document.body.clientHeight,
|
|
46
|
+
}
|
|
47
|
+
return viewportSize
|
|
54
48
|
}
|
|
55
49
|
|
|
56
50
|
export function setViewportSize(vs: any): void {
|
|
57
51
|
//@ts-ignore
|
|
58
|
-
Cypress.action('cy:viewport:changed', {
|
|
52
|
+
Cypress.action('cy:viewport:changed', {viewportWidth: vs.size.width, viewportHeight: vs.size.height})
|
|
59
53
|
}
|
|
60
54
|
|
|
61
55
|
export function transformSelector(selector: Selector): Selector {
|
|
62
56
|
if (selector.hasOwnProperty('selector') && (!selector.hasOwnProperty('type') || (selector as EyesSelector).type === 'css')) {
|
|
63
57
|
return (selector as EyesSelector).selector
|
|
64
|
-
}
|
|
58
|
+
}
|
|
65
59
|
return selector
|
|
66
60
|
}
|
|
67
61
|
|
|
68
62
|
export function findElement(context: Context, selector: Selector, parent?: Element) {
|
|
69
|
-
const eyesSelector =
|
|
63
|
+
const eyesSelector = selector as EyesSelector
|
|
70
64
|
const root = parent ?? context
|
|
71
65
|
const sel = typeof selector === 'string' ? selector : eyesSelector.selector
|
|
72
66
|
if (typeof selector !== 'string' && eyesSelector.type === 'xpath') {
|
|
73
|
-
return context.evaluate(sel, context, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue
|
|
67
|
+
return context.evaluate(sel, context, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue
|
|
74
68
|
} else {
|
|
75
69
|
return root.querySelector(sel)
|
|
76
70
|
}
|
|
77
71
|
}
|
|
78
72
|
|
|
79
|
-
export function findElements(context: Context, selector: Selector, parent: Element){
|
|
80
|
-
const eyesSelector =
|
|
73
|
+
export function findElements(context: Context, selector: Selector, parent: Element) {
|
|
74
|
+
const eyesSelector = selector as EyesSelector
|
|
81
75
|
const root = parent ?? context
|
|
82
76
|
const sel = typeof selector === 'string' ? selector : eyesSelector.selector
|
|
83
77
|
if (typeof selector !== 'string' && eyesSelector.type === 'xpath') {
|
|
84
|
-
const results = []
|
|
85
|
-
const queryResult = document.evaluate(sel, context,
|
|
86
|
-
null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
|
|
78
|
+
const results = []
|
|
79
|
+
const queryResult = document.evaluate(sel, context, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null)
|
|
87
80
|
|
|
88
81
|
for (let i = 0; i < queryResult.snapshotLength; i++) {
|
|
89
|
-
|
|
82
|
+
results.push(queryResult.snapshotItem(i))
|
|
90
83
|
}
|
|
91
|
-
return results
|
|
84
|
+
return results
|
|
92
85
|
} else {
|
|
93
86
|
return root.querySelectorAll(sel)
|
|
94
87
|
}
|
|
@@ -107,9 +100,8 @@ export function getCookies(): Array<any> {
|
|
|
107
100
|
return Cypress.automation('get:cookies', {})
|
|
108
101
|
}
|
|
109
102
|
|
|
110
|
-
|
|
111
103
|
// export function takeScreenshot(page: Driver): Promise<Buffer>;
|
|
112
104
|
|
|
113
105
|
// export function visit(page: Driver, url: string): Promise<void>; (??)
|
|
114
106
|
|
|
115
|
-
// export function isStaleElementError(err: any): boolean;
|
|
107
|
+
// export function isStaleElementError(err: any): boolean;
|