@applitools/eyes-cypress 3.30.2 → 3.31.1
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 +13 -0
- package/dist/browser/mergeCypressConfigs.js +11 -0
- package/dist/browser/transformCypressCheckSettings.js +281 -0
- package/dist/browser/transformCypressConfig.js +58 -0
- package/dist/browser/utils.js +55 -0
- package/dist/plugin/config.js +10 -1
- package/dist/plugin/configParams.js +1 -0
- package/dist/plugin/index.js +1 -1
- package/dist/plugin/server.js +5 -2
- package/package.json +8 -10
- package/src/browser/commands.js +20 -26
- package/src/browser/mergeCypressConfigs.ts +15 -0
- package/src/browser/transformCypressCheckSettings.ts +263 -0
- package/src/browser/transformCypressConfig.ts +56 -0
- package/src/browser/utils.ts +33 -0
- package/src/expose.ts +60 -31
- package/src/plugin/config.ts +10 -1
- package/src/plugin/configParams.ts +1 -0
- package/src/plugin/index.ts +2 -1
- package/src/plugin/server.ts +6 -2
- package/types/expose.d.ts +256 -208
- package/src/browser/eyesCheckMapping.js +0 -281
- package/src/browser/eyesOpenMapping.js +0 -95
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
/* global Node */
|
|
2
|
-
function eyesCheckMapValues({openToCheckSettingsArgs, args, refer, appliConfFile}) {
|
|
3
|
-
if (typeof args === `string`) {
|
|
4
|
-
args = {tag: args}
|
|
5
|
-
}
|
|
6
|
-
args = {...openToCheckSettingsArgs, ...args}
|
|
7
|
-
if (typeof args.waitBeforeCapture !== 'number') args.waitBeforeCapture = appliConfFile.waitBeforeCapture
|
|
8
|
-
let accessibilitySettings = args.accessibilitySettings || appliConfFile.accessibilityValidation
|
|
9
|
-
|
|
10
|
-
const mappedValues = [
|
|
11
|
-
'tag',
|
|
12
|
-
'scriptHooks',
|
|
13
|
-
'ignore',
|
|
14
|
-
'floating',
|
|
15
|
-
'strict',
|
|
16
|
-
'layout',
|
|
17
|
-
'content',
|
|
18
|
-
'accessibility',
|
|
19
|
-
'region',
|
|
20
|
-
'selector',
|
|
21
|
-
'element',
|
|
22
|
-
'variationGroupId',
|
|
23
|
-
'accessibilitySettings',
|
|
24
|
-
'visualGridOptions',
|
|
25
|
-
]
|
|
26
|
-
|
|
27
|
-
let regionSettings = {}
|
|
28
|
-
let shadowDomSettings = {}
|
|
29
|
-
|
|
30
|
-
let renderers = args.renderers || args.browser || appliConfFile.browser
|
|
31
|
-
if (renderers) {
|
|
32
|
-
if (Array.isArray(renderers)) {
|
|
33
|
-
for (const [index, value] of renderers.entries()) {
|
|
34
|
-
renderers[index] = fillDefaultBrowserName(value)
|
|
35
|
-
}
|
|
36
|
-
} else {
|
|
37
|
-
renderers = [fillDefaultBrowserName(renderers)]
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const checkSettings = {
|
|
42
|
-
name: args.tag,
|
|
43
|
-
hooks: args.scriptHooks,
|
|
44
|
-
ignoreRegions: convertPaddedRegion(args.ignore),
|
|
45
|
-
floatingRegions: convertFloatingRegion(args.floating),
|
|
46
|
-
strictRegions: convertPaddedRegion(args.strict),
|
|
47
|
-
layoutRegions: convertPaddedRegion(args.layout),
|
|
48
|
-
contentRegions: convertPaddedRegion(args.content),
|
|
49
|
-
accessibilityRegions: convertAccessabilityRegions(args.accessibility),
|
|
50
|
-
renderers,
|
|
51
|
-
}
|
|
52
|
-
if (args.variationGroupId) {
|
|
53
|
-
checkSettings.userCommandId = args.variationGroupId
|
|
54
|
-
}
|
|
55
|
-
if (args.accessibilitySettings) {
|
|
56
|
-
checkSettings.accessibilitySettings = accessibilitySettings
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (args.visualGridOptions) {
|
|
60
|
-
checkSettings.ufgOptions = args.visualGridOptions
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (args.target === 'region') {
|
|
64
|
-
if (!Array.isArray(args.selector)) {
|
|
65
|
-
if (args.element) {
|
|
66
|
-
if (isHTMLElement(args.element)) {
|
|
67
|
-
regionSettings = {
|
|
68
|
-
region: Object.assign(refer.ref(args.element), {type: 'element'}),
|
|
69
|
-
}
|
|
70
|
-
} else {
|
|
71
|
-
// JQuery element
|
|
72
|
-
regionSettings = {
|
|
73
|
-
region: Object.assign(refer.ref(args.element[0]), {type: 'element'}),
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
} else if (
|
|
77
|
-
args.region &&
|
|
78
|
-
args.region.hasOwnProperty('top') &&
|
|
79
|
-
args.region.hasOwnProperty('left') &&
|
|
80
|
-
args.region.hasOwnProperty('width') &&
|
|
81
|
-
args.region.hasOwnProperty('height')
|
|
82
|
-
) {
|
|
83
|
-
regionSettings = {
|
|
84
|
-
region: {
|
|
85
|
-
y: args.region.top,
|
|
86
|
-
x: args.region.left,
|
|
87
|
-
width: args.region.width,
|
|
88
|
-
height: args.region.height,
|
|
89
|
-
},
|
|
90
|
-
}
|
|
91
|
-
} else if (!args.hasOwnProperty('selector')) {
|
|
92
|
-
regionSettings = {
|
|
93
|
-
region: args.region,
|
|
94
|
-
}
|
|
95
|
-
} else {
|
|
96
|
-
regionSettings = {
|
|
97
|
-
region: args.selector,
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
} else {
|
|
101
|
-
const selectors = args.selector
|
|
102
|
-
for (let i = selectors.length - 1; i > -1; i--) {
|
|
103
|
-
if (i === selectors.length - 1) {
|
|
104
|
-
shadowDomSettings['shadow'] = selectors[i].selector
|
|
105
|
-
} else {
|
|
106
|
-
const prevSettings = Object.assign({}, shadowDomSettings)
|
|
107
|
-
shadowDomSettings['selector'] = selectors[i].selector
|
|
108
|
-
if (!prevSettings.hasOwnProperty('selector')) {
|
|
109
|
-
shadowDomSettings['shadow'] = prevSettings.shadow
|
|
110
|
-
} else {
|
|
111
|
-
shadowDomSettings['shadow'] = prevSettings
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
regionSettings = {region: shadowDomSettings}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
for (const val of mappedValues) {
|
|
120
|
-
if (args.hasOwnProperty(val)) {
|
|
121
|
-
delete args[val]
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return Object.assign({}, checkSettings, regionSettings, args)
|
|
126
|
-
|
|
127
|
-
// #region helper functions
|
|
128
|
-
|
|
129
|
-
function convertPaddedRegion(regions) {
|
|
130
|
-
if (!regions) return
|
|
131
|
-
if (!Array.isArray(regions)) regions = [regions]
|
|
132
|
-
let resRegions = []
|
|
133
|
-
for (const region of regions) {
|
|
134
|
-
if (region.element || isHTMLElement(region) || region.jquery) {
|
|
135
|
-
if (region.padding || region.regionId) {
|
|
136
|
-
let currRefElements = refElements(region.element)
|
|
137
|
-
for (const refElement of currRefElements) {
|
|
138
|
-
let curr = {region: refElement}
|
|
139
|
-
if (region.padding) {
|
|
140
|
-
curr.padding = region.padding
|
|
141
|
-
}
|
|
142
|
-
if (region.regionId) {
|
|
143
|
-
curr.regionId = region.regionId
|
|
144
|
-
}
|
|
145
|
-
resRegions.push(curr)
|
|
146
|
-
}
|
|
147
|
-
} else {
|
|
148
|
-
resRegions = [...resRegions, ...refElements(region)]
|
|
149
|
-
}
|
|
150
|
-
} else {
|
|
151
|
-
if (region.selector && !region.type) {
|
|
152
|
-
region.region = region.selector
|
|
153
|
-
delete region.selector
|
|
154
|
-
}
|
|
155
|
-
resRegions.push(region)
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
return resRegions
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
function convertAccessabilityRegions(accessibilityRegions) {
|
|
162
|
-
if (!accessibilityRegions) return accessibilityRegions
|
|
163
|
-
if (!Array.isArray(accessibilityRegions)) {
|
|
164
|
-
accessibilityRegions = [accessibilityRegions]
|
|
165
|
-
}
|
|
166
|
-
const accessibility = []
|
|
167
|
-
|
|
168
|
-
accessibilityRegions.map(region => {
|
|
169
|
-
const accessabilityRegion = {
|
|
170
|
-
type: region.accessibilityType,
|
|
171
|
-
}
|
|
172
|
-
if (region.hasOwnProperty('selector')) {
|
|
173
|
-
accessabilityRegion.region = region.selector
|
|
174
|
-
accessibility.push(accessabilityRegion)
|
|
175
|
-
} else if (region.hasOwnProperty('element')) {
|
|
176
|
-
const elements = refElements(region.element)
|
|
177
|
-
delete region['element']
|
|
178
|
-
for (const element of elements) {
|
|
179
|
-
accessibility.push(Object.assign({}, region, accessabilityRegion, {region: element}))
|
|
180
|
-
}
|
|
181
|
-
} else if (region.hasOwnProperty('region')) {
|
|
182
|
-
region.type = region.region.accessibilityType
|
|
183
|
-
delete region.region.accessibilityType
|
|
184
|
-
accessibility.push(region)
|
|
185
|
-
} else {
|
|
186
|
-
accessabilityRegion.region = {
|
|
187
|
-
y: region.top,
|
|
188
|
-
x: region.left,
|
|
189
|
-
width: region.width,
|
|
190
|
-
height: region.height,
|
|
191
|
-
}
|
|
192
|
-
accessibility.push(accessabilityRegion)
|
|
193
|
-
}
|
|
194
|
-
})
|
|
195
|
-
|
|
196
|
-
return accessibility
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
function convertFloatingRegion(floatingRegions) {
|
|
200
|
-
if (!floatingRegions) return floatingRegions
|
|
201
|
-
if (!Array.isArray(floatingRegions)) {
|
|
202
|
-
floatingRegions = [floatingRegions]
|
|
203
|
-
}
|
|
204
|
-
const floating = []
|
|
205
|
-
|
|
206
|
-
for (const region of floatingRegions) {
|
|
207
|
-
const floatingRegion = {
|
|
208
|
-
offset: {
|
|
209
|
-
bottom: region.maxDownOffset || 0,
|
|
210
|
-
left: region.maxLeftOffset || 0,
|
|
211
|
-
top: region.maxUpOffset || 0,
|
|
212
|
-
right: region.maxRightOffset || 0,
|
|
213
|
-
},
|
|
214
|
-
}
|
|
215
|
-
if (region.hasOwnProperty('selector')) {
|
|
216
|
-
floatingRegion.region = region.selector
|
|
217
|
-
floating.push(floatingRegion)
|
|
218
|
-
} else if (region.hasOwnProperty('element')) {
|
|
219
|
-
const elements = refElements(region.element)
|
|
220
|
-
delete region['element']
|
|
221
|
-
for (const element of elements) {
|
|
222
|
-
floating.push(Object.assign({}, region, floatingRegion, {region: element}))
|
|
223
|
-
}
|
|
224
|
-
} else if (region.hasOwnProperty('region')) {
|
|
225
|
-
floating.push({offset: floatingRegion.offset, ...region})
|
|
226
|
-
} else {
|
|
227
|
-
floatingRegion.region = {
|
|
228
|
-
y: region.top,
|
|
229
|
-
x: region.left,
|
|
230
|
-
width: region.width,
|
|
231
|
-
height: region.height,
|
|
232
|
-
}
|
|
233
|
-
floating.push(floatingRegion)
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
return floating
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
function refElements(regions) {
|
|
240
|
-
if (!regions) return regions
|
|
241
|
-
if (!Array.isArray(regions)) regions = [regions]
|
|
242
|
-
const elements = []
|
|
243
|
-
for (const region of regions) {
|
|
244
|
-
if (isHTMLElement(region)) {
|
|
245
|
-
elements.push(Object.assign(refer.ref(region), {type: 'element'}))
|
|
246
|
-
} else if (region.jquery) {
|
|
247
|
-
region.each(function () {
|
|
248
|
-
// there's a small chance that `this` is not an HTML element. So we just verify it.
|
|
249
|
-
elements.push(isHTMLElement(this) ? Object.assign(refer.ref(this), {type: 'element'}) : this)
|
|
250
|
-
})
|
|
251
|
-
} else {
|
|
252
|
-
elements.push(region)
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
return elements
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
// #endregion
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
function isHTMLElement(element) {
|
|
262
|
-
// Avoiding instanceof here since the element might come from an iframe, and `instanceof HTMLElement` would fail.
|
|
263
|
-
// This check looks naive, but if anyone passes something like {nodeType: 1} as a region, then I'm fine with them crashing :)
|
|
264
|
-
return element.nodeType && element.nodeType === Node.ELEMENT_NODE
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
function fillDefaultBrowserName(browser) {
|
|
268
|
-
if (!browser.iosDeviceInfo && !browser.chromeEmulationInfo) {
|
|
269
|
-
if (!browser.name) {
|
|
270
|
-
browser.name = 'chrome'
|
|
271
|
-
}
|
|
272
|
-
if (browser.deviceName) {
|
|
273
|
-
browser = {chromeEmulationInfo: browser}
|
|
274
|
-
}
|
|
275
|
-
return browser
|
|
276
|
-
} else {
|
|
277
|
-
return browser
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
module.exports = {eyesCheckMapValues}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
const batchPropertiesRetriever = (args, appliConfFile) => {
|
|
2
|
-
return function (prop, nestedProp) {
|
|
3
|
-
nestedProp = nestedProp || prop
|
|
4
|
-
if (args.hasOwnProperty(prop)) {
|
|
5
|
-
return args[prop]
|
|
6
|
-
} else if (args.batch && args.batch.hasOwnProperty(nestedProp)) {
|
|
7
|
-
return args.batch[nestedProp]
|
|
8
|
-
} else if (appliConfFile.hasOwnProperty(prop)) {
|
|
9
|
-
return appliConfFile[prop]
|
|
10
|
-
} else if (appliConfFile.batch && appliConfFile.batch.hasOwnProperty(nestedProp)) {
|
|
11
|
-
return appliConfFile.batch[nestedProp]
|
|
12
|
-
}
|
|
13
|
-
return undefined
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
function eyesOpenMapValues({args, appliConfFile, testName, shouldUseBrowserHooks}) {
|
|
17
|
-
const batchProperties = batchPropertiesRetriever(args, appliConfFile)
|
|
18
|
-
const batch = {
|
|
19
|
-
id: batchProperties('batchId', 'id'),
|
|
20
|
-
name: batchProperties('batchName', 'name'),
|
|
21
|
-
sequenceName: batchProperties('batchSequenceName', 'sequenceName'),
|
|
22
|
-
notifyOnCompletion: batchProperties('notifyOnCompletion'),
|
|
23
|
-
properties:
|
|
24
|
-
(args.batch ? args.batch.properties : undefined) ||
|
|
25
|
-
(appliConfFile.batch ? appliConfFile.batch.properties : undefined),
|
|
26
|
-
}
|
|
27
|
-
for (let prop in batch) {
|
|
28
|
-
if (typeof batch[prop] === 'undefined') {
|
|
29
|
-
delete batch[prop]
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const mappedValues = [
|
|
34
|
-
'accessibilityValidation',
|
|
35
|
-
'browser',
|
|
36
|
-
'useDom',
|
|
37
|
-
'matchLevel',
|
|
38
|
-
'enablePatterns',
|
|
39
|
-
'ignoreDisplacements',
|
|
40
|
-
'ignoreCaret',
|
|
41
|
-
'batchName',
|
|
42
|
-
'batchId',
|
|
43
|
-
'batchSequenceName',
|
|
44
|
-
]
|
|
45
|
-
|
|
46
|
-
const defaultMatchSettings = {
|
|
47
|
-
matchLevel: args.matchLevel || appliConfFile.matchLevel,
|
|
48
|
-
ignoreCaret: args.ignoreCaret || appliConfFile.ignoreCaret,
|
|
49
|
-
useDom: args.useDom || appliConfFile.useDom,
|
|
50
|
-
enablePatterns: args.enablePatterns || appliConfFile.enablePatterns,
|
|
51
|
-
ignoreDisplacements: args.ignoreDisplacements || appliConfFile.ignoreDisplacements,
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const appliConfFileCopy = {...appliConfFile}
|
|
55
|
-
for (const val of mappedValues) {
|
|
56
|
-
if (args.hasOwnProperty(val)) {
|
|
57
|
-
delete args[val]
|
|
58
|
-
}
|
|
59
|
-
if (appliConfFileCopy.hasOwnProperty(val)) {
|
|
60
|
-
delete appliConfFileCopy[val]
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const mappedArgs = {
|
|
65
|
-
...defaultMatchSettings,
|
|
66
|
-
...args,
|
|
67
|
-
batch,
|
|
68
|
-
}
|
|
69
|
-
if (typeof args.viewportSize !== 'undefined' || typeof args.environment !== 'undefined') {
|
|
70
|
-
mappedArgs.environment = {viewportSize: args.viewportSize, ...args.environment}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return Object.assign({testName, keepBatchOpen: !shouldUseBrowserHooks}, appliConfFileCopy, mappedArgs)
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function eyesOpenToCheckMapValues(args) {
|
|
77
|
-
const {browser, waitBeforeCapture, layoutBreakpoints, accessibilityValidation} = args
|
|
78
|
-
|
|
79
|
-
const openToCheckSettingsArgs = {
|
|
80
|
-
browser,
|
|
81
|
-
waitBeforeCapture,
|
|
82
|
-
layoutBreakpoints,
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (accessibilityValidation) {
|
|
86
|
-
const {level, guidelinesVersion} = accessibilityValidation
|
|
87
|
-
openToCheckSettingsArgs.accessibilitySettings = {
|
|
88
|
-
level,
|
|
89
|
-
version: guidelinesVersion,
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return openToCheckSettingsArgs
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
module.exports = {eyesOpenMapValues, eyesOpenToCheckMapValues}
|