@telefonica/acceptance-testing 4.1.0 → 5.0.0-beta2
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/README.md +21 -2
- package/dist/config.d.ts +22 -0
- package/dist/config.js +57 -0
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +4 -0
- package/dist/coverage.d.ts +15 -15
- package/dist/coverage.js +119 -0
- package/dist/index.d.ts +86 -91
- package/dist/index.js +424 -8
- package/dist/jest-puppeteer.config.d.ts +1 -0
- package/{jest-puppeteer-config.js → dist/jest-puppeteer.config.js} +19 -60
- package/dist/utils.d.ts +12 -8
- package/dist/utils.js +43 -0
- package/dist/wsl.d.ts +6 -0
- package/dist/wsl.js +49 -0
- package/jest-puppeteer.config.js +1 -0
- package/package.json +15 -13
- package/dist/acceptance-testing.cjs.development.js +0 -1472
- package/dist/acceptance-testing.cjs.development.js.map +0 -1
- package/dist/acceptance-testing.cjs.production.min.js +0 -2
- package/dist/acceptance-testing.cjs.production.min.js.map +0 -1
- package/dist/acceptance-testing.esm.js +0 -1453
- package/dist/acceptance-testing.esm.js.map +0 -1
|
@@ -1,1472 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
|
-
|
|
7
|
-
var path = _interopDefault(require('path'));
|
|
8
|
-
var fs = _interopDefault(require('fs'));
|
|
9
|
-
var findRoot = _interopDefault(require('find-root'));
|
|
10
|
-
var pptrTestingLibrary = require('pptr-testing-library');
|
|
11
|
-
var jestImageSnapshot = require('jest-image-snapshot');
|
|
12
|
-
var globToRegExp = _interopDefault(require('glob-to-regexp'));
|
|
13
|
-
var child_process = require('child_process');
|
|
14
|
-
var istanbul = _interopDefault(require('istanbul-lib-coverage'));
|
|
15
|
-
|
|
16
|
-
function _regeneratorRuntime() {
|
|
17
|
-
_regeneratorRuntime = function () {
|
|
18
|
-
return exports;
|
|
19
|
-
};
|
|
20
|
-
var exports = {},
|
|
21
|
-
Op = Object.prototype,
|
|
22
|
-
hasOwn = Op.hasOwnProperty,
|
|
23
|
-
defineProperty = Object.defineProperty || function (obj, key, desc) {
|
|
24
|
-
obj[key] = desc.value;
|
|
25
|
-
},
|
|
26
|
-
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
27
|
-
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
28
|
-
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
29
|
-
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
30
|
-
function define(obj, key, value) {
|
|
31
|
-
return Object.defineProperty(obj, key, {
|
|
32
|
-
value: value,
|
|
33
|
-
enumerable: !0,
|
|
34
|
-
configurable: !0,
|
|
35
|
-
writable: !0
|
|
36
|
-
}), obj[key];
|
|
37
|
-
}
|
|
38
|
-
try {
|
|
39
|
-
define({}, "");
|
|
40
|
-
} catch (err) {
|
|
41
|
-
define = function (obj, key, value) {
|
|
42
|
-
return obj[key] = value;
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
46
|
-
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
47
|
-
generator = Object.create(protoGenerator.prototype),
|
|
48
|
-
context = new Context(tryLocsList || []);
|
|
49
|
-
return defineProperty(generator, "_invoke", {
|
|
50
|
-
value: makeInvokeMethod(innerFn, self, context)
|
|
51
|
-
}), generator;
|
|
52
|
-
}
|
|
53
|
-
function tryCatch(fn, obj, arg) {
|
|
54
|
-
try {
|
|
55
|
-
return {
|
|
56
|
-
type: "normal",
|
|
57
|
-
arg: fn.call(obj, arg)
|
|
58
|
-
};
|
|
59
|
-
} catch (err) {
|
|
60
|
-
return {
|
|
61
|
-
type: "throw",
|
|
62
|
-
arg: err
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
exports.wrap = wrap;
|
|
67
|
-
var ContinueSentinel = {};
|
|
68
|
-
function Generator() {}
|
|
69
|
-
function GeneratorFunction() {}
|
|
70
|
-
function GeneratorFunctionPrototype() {}
|
|
71
|
-
var IteratorPrototype = {};
|
|
72
|
-
define(IteratorPrototype, iteratorSymbol, function () {
|
|
73
|
-
return this;
|
|
74
|
-
});
|
|
75
|
-
var getProto = Object.getPrototypeOf,
|
|
76
|
-
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
77
|
-
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
|
78
|
-
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
79
|
-
function defineIteratorMethods(prototype) {
|
|
80
|
-
["next", "throw", "return"].forEach(function (method) {
|
|
81
|
-
define(prototype, method, function (arg) {
|
|
82
|
-
return this._invoke(method, arg);
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
function AsyncIterator(generator, PromiseImpl) {
|
|
87
|
-
function invoke(method, arg, resolve, reject) {
|
|
88
|
-
var record = tryCatch(generator[method], generator, arg);
|
|
89
|
-
if ("throw" !== record.type) {
|
|
90
|
-
var result = record.arg,
|
|
91
|
-
value = result.value;
|
|
92
|
-
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
93
|
-
invoke("next", value, resolve, reject);
|
|
94
|
-
}, function (err) {
|
|
95
|
-
invoke("throw", err, resolve, reject);
|
|
96
|
-
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
97
|
-
result.value = unwrapped, resolve(result);
|
|
98
|
-
}, function (error) {
|
|
99
|
-
return invoke("throw", error, resolve, reject);
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
reject(record.arg);
|
|
103
|
-
}
|
|
104
|
-
var previousPromise;
|
|
105
|
-
defineProperty(this, "_invoke", {
|
|
106
|
-
value: function (method, arg) {
|
|
107
|
-
function callInvokeWithMethodAndArg() {
|
|
108
|
-
return new PromiseImpl(function (resolve, reject) {
|
|
109
|
-
invoke(method, arg, resolve, reject);
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
function makeInvokeMethod(innerFn, self, context) {
|
|
117
|
-
var state = "suspendedStart";
|
|
118
|
-
return function (method, arg) {
|
|
119
|
-
if ("executing" === state) throw new Error("Generator is already running");
|
|
120
|
-
if ("completed" === state) {
|
|
121
|
-
if ("throw" === method) throw arg;
|
|
122
|
-
return doneResult();
|
|
123
|
-
}
|
|
124
|
-
for (context.method = method, context.arg = arg;;) {
|
|
125
|
-
var delegate = context.delegate;
|
|
126
|
-
if (delegate) {
|
|
127
|
-
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
128
|
-
if (delegateResult) {
|
|
129
|
-
if (delegateResult === ContinueSentinel) continue;
|
|
130
|
-
return delegateResult;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
134
|
-
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
135
|
-
context.dispatchException(context.arg);
|
|
136
|
-
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
137
|
-
state = "executing";
|
|
138
|
-
var record = tryCatch(innerFn, self, context);
|
|
139
|
-
if ("normal" === record.type) {
|
|
140
|
-
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
|
141
|
-
return {
|
|
142
|
-
value: record.arg,
|
|
143
|
-
done: context.done
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
function maybeInvokeDelegate(delegate, context) {
|
|
151
|
-
var methodName = context.method,
|
|
152
|
-
method = delegate.iterator[methodName];
|
|
153
|
-
if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
|
|
154
|
-
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
155
|
-
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
156
|
-
var info = record.arg;
|
|
157
|
-
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
|
|
158
|
-
}
|
|
159
|
-
function pushTryEntry(locs) {
|
|
160
|
-
var entry = {
|
|
161
|
-
tryLoc: locs[0]
|
|
162
|
-
};
|
|
163
|
-
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
|
164
|
-
}
|
|
165
|
-
function resetTryEntry(entry) {
|
|
166
|
-
var record = entry.completion || {};
|
|
167
|
-
record.type = "normal", delete record.arg, entry.completion = record;
|
|
168
|
-
}
|
|
169
|
-
function Context(tryLocsList) {
|
|
170
|
-
this.tryEntries = [{
|
|
171
|
-
tryLoc: "root"
|
|
172
|
-
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
|
173
|
-
}
|
|
174
|
-
function values(iterable) {
|
|
175
|
-
if (iterable) {
|
|
176
|
-
var iteratorMethod = iterable[iteratorSymbol];
|
|
177
|
-
if (iteratorMethod) return iteratorMethod.call(iterable);
|
|
178
|
-
if ("function" == typeof iterable.next) return iterable;
|
|
179
|
-
if (!isNaN(iterable.length)) {
|
|
180
|
-
var i = -1,
|
|
181
|
-
next = function next() {
|
|
182
|
-
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
|
183
|
-
return next.value = undefined, next.done = !0, next;
|
|
184
|
-
};
|
|
185
|
-
return next.next = next;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
return {
|
|
189
|
-
next: doneResult
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
function doneResult() {
|
|
193
|
-
return {
|
|
194
|
-
value: undefined,
|
|
195
|
-
done: !0
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
|
|
199
|
-
value: GeneratorFunctionPrototype,
|
|
200
|
-
configurable: !0
|
|
201
|
-
}), defineProperty(GeneratorFunctionPrototype, "constructor", {
|
|
202
|
-
value: GeneratorFunction,
|
|
203
|
-
configurable: !0
|
|
204
|
-
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
|
205
|
-
var ctor = "function" == typeof genFun && genFun.constructor;
|
|
206
|
-
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
|
207
|
-
}, exports.mark = function (genFun) {
|
|
208
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
|
|
209
|
-
}, exports.awrap = function (arg) {
|
|
210
|
-
return {
|
|
211
|
-
__await: arg
|
|
212
|
-
};
|
|
213
|
-
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
214
|
-
return this;
|
|
215
|
-
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
216
|
-
void 0 === PromiseImpl && (PromiseImpl = Promise);
|
|
217
|
-
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
218
|
-
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
|
219
|
-
return result.done ? result.value : iter.next();
|
|
220
|
-
});
|
|
221
|
-
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
|
|
222
|
-
return this;
|
|
223
|
-
}), define(Gp, "toString", function () {
|
|
224
|
-
return "[object Generator]";
|
|
225
|
-
}), exports.keys = function (val) {
|
|
226
|
-
var object = Object(val),
|
|
227
|
-
keys = [];
|
|
228
|
-
for (var key in object) keys.push(key);
|
|
229
|
-
return keys.reverse(), function next() {
|
|
230
|
-
for (; keys.length;) {
|
|
231
|
-
var key = keys.pop();
|
|
232
|
-
if (key in object) return next.value = key, next.done = !1, next;
|
|
233
|
-
}
|
|
234
|
-
return next.done = !0, next;
|
|
235
|
-
};
|
|
236
|
-
}, exports.values = values, Context.prototype = {
|
|
237
|
-
constructor: Context,
|
|
238
|
-
reset: function (skipTempReset) {
|
|
239
|
-
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
|
|
240
|
-
},
|
|
241
|
-
stop: function () {
|
|
242
|
-
this.done = !0;
|
|
243
|
-
var rootRecord = this.tryEntries[0].completion;
|
|
244
|
-
if ("throw" === rootRecord.type) throw rootRecord.arg;
|
|
245
|
-
return this.rval;
|
|
246
|
-
},
|
|
247
|
-
dispatchException: function (exception) {
|
|
248
|
-
if (this.done) throw exception;
|
|
249
|
-
var context = this;
|
|
250
|
-
function handle(loc, caught) {
|
|
251
|
-
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
|
252
|
-
}
|
|
253
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
254
|
-
var entry = this.tryEntries[i],
|
|
255
|
-
record = entry.completion;
|
|
256
|
-
if ("root" === entry.tryLoc) return handle("end");
|
|
257
|
-
if (entry.tryLoc <= this.prev) {
|
|
258
|
-
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
|
259
|
-
hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
260
|
-
if (hasCatch && hasFinally) {
|
|
261
|
-
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
262
|
-
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
263
|
-
} else if (hasCatch) {
|
|
264
|
-
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
265
|
-
} else {
|
|
266
|
-
if (!hasFinally) throw new Error("try statement without catch or finally");
|
|
267
|
-
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
},
|
|
272
|
-
abrupt: function (type, arg) {
|
|
273
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
274
|
-
var entry = this.tryEntries[i];
|
|
275
|
-
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
276
|
-
var finallyEntry = entry;
|
|
277
|
-
break;
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
|
|
281
|
-
var record = finallyEntry ? finallyEntry.completion : {};
|
|
282
|
-
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
|
283
|
-
},
|
|
284
|
-
complete: function (record, afterLoc) {
|
|
285
|
-
if ("throw" === record.type) throw record.arg;
|
|
286
|
-
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
|
|
287
|
-
},
|
|
288
|
-
finish: function (finallyLoc) {
|
|
289
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
290
|
-
var entry = this.tryEntries[i];
|
|
291
|
-
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
|
|
292
|
-
}
|
|
293
|
-
},
|
|
294
|
-
catch: function (tryLoc) {
|
|
295
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
296
|
-
var entry = this.tryEntries[i];
|
|
297
|
-
if (entry.tryLoc === tryLoc) {
|
|
298
|
-
var record = entry.completion;
|
|
299
|
-
if ("throw" === record.type) {
|
|
300
|
-
var thrown = record.arg;
|
|
301
|
-
resetTryEntry(entry);
|
|
302
|
-
}
|
|
303
|
-
return thrown;
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
throw new Error("illegal catch attempt");
|
|
307
|
-
},
|
|
308
|
-
delegateYield: function (iterable, resultName, nextLoc) {
|
|
309
|
-
return this.delegate = {
|
|
310
|
-
iterator: values(iterable),
|
|
311
|
-
resultName: resultName,
|
|
312
|
-
nextLoc: nextLoc
|
|
313
|
-
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
|
|
314
|
-
}
|
|
315
|
-
}, exports;
|
|
316
|
-
}
|
|
317
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
318
|
-
try {
|
|
319
|
-
var info = gen[key](arg);
|
|
320
|
-
var value = info.value;
|
|
321
|
-
} catch (error) {
|
|
322
|
-
reject(error);
|
|
323
|
-
return;
|
|
324
|
-
}
|
|
325
|
-
if (info.done) {
|
|
326
|
-
resolve(value);
|
|
327
|
-
} else {
|
|
328
|
-
Promise.resolve(value).then(_next, _throw);
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
function _asyncToGenerator(fn) {
|
|
332
|
-
return function () {
|
|
333
|
-
var self = this,
|
|
334
|
-
args = arguments;
|
|
335
|
-
return new Promise(function (resolve, reject) {
|
|
336
|
-
var gen = fn.apply(self, args);
|
|
337
|
-
function _next(value) {
|
|
338
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
339
|
-
}
|
|
340
|
-
function _throw(err) {
|
|
341
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
342
|
-
}
|
|
343
|
-
_next(undefined);
|
|
344
|
-
});
|
|
345
|
-
};
|
|
346
|
-
}
|
|
347
|
-
function _extends() {
|
|
348
|
-
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
349
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
350
|
-
var source = arguments[i];
|
|
351
|
-
for (var key in source) {
|
|
352
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
353
|
-
target[key] = source[key];
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
return target;
|
|
358
|
-
};
|
|
359
|
-
return _extends.apply(this, arguments);
|
|
360
|
-
}
|
|
361
|
-
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
362
|
-
if (source == null) return {};
|
|
363
|
-
var target = {};
|
|
364
|
-
var sourceKeys = Object.keys(source);
|
|
365
|
-
var key, i;
|
|
366
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
367
|
-
key = sourceKeys[i];
|
|
368
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
369
|
-
target[key] = source[key];
|
|
370
|
-
}
|
|
371
|
-
return target;
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
/**
|
|
375
|
-
* Debug function that logs to the console if the DEBUG_ACCEPTANCE_TESTING environment variable is set
|
|
376
|
-
*/
|
|
377
|
-
var debug = function debug() {
|
|
378
|
-
if (process.env.DEBUG_ACCEPTANCE_TESTING) {
|
|
379
|
-
var _console;
|
|
380
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
381
|
-
args[_key] = arguments[_key];
|
|
382
|
-
}
|
|
383
|
-
(_console = console).debug.apply(_console, ['[acceptance-testing]'].concat(args));
|
|
384
|
-
}
|
|
385
|
-
};
|
|
386
|
-
/**
|
|
387
|
-
* Returns true if the current path matches the spied path, including parameters
|
|
388
|
-
*/
|
|
389
|
-
var matchPath = function matchPath(spiedPath, currentPath) {
|
|
390
|
-
var normalizedCurrentPath = path.normalize(currentPath);
|
|
391
|
-
var pattern = globToRegExp(spiedPath);
|
|
392
|
-
return pattern.test(normalizedCurrentPath);
|
|
393
|
-
};
|
|
394
|
-
|
|
395
|
-
var getGlobalPage = function getGlobalPage() {
|
|
396
|
-
return global.page;
|
|
397
|
-
};
|
|
398
|
-
var getRootPath = function getRootPath() {
|
|
399
|
-
var rootPath = expect.getState().snapshotState._rootDir;
|
|
400
|
-
if (!rootPath) {
|
|
401
|
-
throw new Error('Root path not found');
|
|
402
|
-
}
|
|
403
|
-
return rootPath;
|
|
404
|
-
};
|
|
405
|
-
/**
|
|
406
|
-
* We want to clear coverage files from previous runs, but at this point it is not easy because each
|
|
407
|
-
* worker runs a different instance of this script, so we can't just clear the coverage folder at
|
|
408
|
-
* the beginning of the test run.
|
|
409
|
-
*
|
|
410
|
-
* The solution is to remove the coverage folder when the stored ppid (parent process id) is
|
|
411
|
-
* different from the current one
|
|
412
|
-
*/
|
|
413
|
-
var prepareCoverageReportPath = function prepareCoverageReportPath(_ref) {
|
|
414
|
-
var coveragePath = _ref.coveragePath;
|
|
415
|
-
var ppidFile = path.join(coveragePath, '.ppid');
|
|
416
|
-
var nycOutputPath = path.join(coveragePath, '.nyc_output');
|
|
417
|
-
var ppid = process.ppid.toString();
|
|
418
|
-
if (!fs.existsSync(ppidFile) || fs.readFileSync(ppidFile, 'utf-8') !== ppid) {
|
|
419
|
-
// the condition is just to make sure we don't remove files outside the repo
|
|
420
|
-
if (getRootPath() === process.cwd() && path.normalize(coveragePath).startsWith(process.cwd())) {
|
|
421
|
-
fs.rmSync(nycOutputPath, {
|
|
422
|
-
recursive: true,
|
|
423
|
-
force: true
|
|
424
|
-
});
|
|
425
|
-
}
|
|
426
|
-
fs.mkdirSync(nycOutputPath, {
|
|
427
|
-
recursive: true
|
|
428
|
-
});
|
|
429
|
-
fs.writeFileSync(ppidFile, ppid);
|
|
430
|
-
}
|
|
431
|
-
};
|
|
432
|
-
var workerId = process.env.JEST_WORKER_ID || '0';
|
|
433
|
-
/**
|
|
434
|
-
* Writes the coverage reports into single files, one per each coverage object (path). This makes it easier to merge them.
|
|
435
|
-
* The `workerId` from jest is used to avoid race conditions when multiple workers are running in parallel.
|
|
436
|
-
*/
|
|
437
|
-
var writeCombinedCoverage = function writeCombinedCoverage(nycOutputPath, coverage) {
|
|
438
|
-
Object.values(coverage).forEach(function (value) {
|
|
439
|
-
if (value && value.path && value.hash) {
|
|
440
|
-
var _currentCoverage;
|
|
441
|
-
var filename = path.join(nycOutputPath, value.hash + "-" + workerId + ".json");
|
|
442
|
-
var currentCoverage = (_currentCoverage = {}, _currentCoverage[value.path] = value, _currentCoverage);
|
|
443
|
-
var previousCoverage = fs.existsSync(filename) ? JSON.parse(fs.readFileSync(filename, 'utf8')) : {};
|
|
444
|
-
var mergedCoverage = istanbul.createCoverageMap(previousCoverage);
|
|
445
|
-
mergedCoverage.merge(currentCoverage);
|
|
446
|
-
debug('Writing merged coverage:', value.path, value.hash);
|
|
447
|
-
fs.writeFileSync(filename, JSON.stringify(mergedCoverage.toJSON(), null, 2));
|
|
448
|
-
} else {
|
|
449
|
-
debug('Skip write coverage. Missing path or hash:', value);
|
|
450
|
-
}
|
|
451
|
-
});
|
|
452
|
-
};
|
|
453
|
-
/**
|
|
454
|
-
* Assumes the code was instrumented with istanbul/nyc and the coverage report stored in `window.__coverage__`.
|
|
455
|
-
* If not, this function does nothing.
|
|
456
|
-
*/
|
|
457
|
-
var collectFrontendCoverage = /*#__PURE__*/function () {
|
|
458
|
-
var _ref3 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref2) {
|
|
459
|
-
var coveragePath, nycOutputPath, coverage;
|
|
460
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
461
|
-
while (1) switch (_context.prev = _context.next) {
|
|
462
|
-
case 0:
|
|
463
|
-
coveragePath = _ref2.coveragePath;
|
|
464
|
-
nycOutputPath = path.join(coveragePath, '.nyc_output');
|
|
465
|
-
_context.next = 4;
|
|
466
|
-
return getGlobalPage().evaluate(function () {
|
|
467
|
-
return window.__coverage__;
|
|
468
|
-
});
|
|
469
|
-
case 4:
|
|
470
|
-
coverage = _context.sent;
|
|
471
|
-
if (coverage) {
|
|
472
|
-
_context.next = 8;
|
|
473
|
-
break;
|
|
474
|
-
}
|
|
475
|
-
debug('Skipping coverage collection. No coverage found.');
|
|
476
|
-
return _context.abrupt("return");
|
|
477
|
-
case 8:
|
|
478
|
-
debug('Frontend coverage found');
|
|
479
|
-
prepareCoverageReportPath({
|
|
480
|
-
coveragePath: coveragePath
|
|
481
|
-
});
|
|
482
|
-
fs.mkdirSync(nycOutputPath, {
|
|
483
|
-
recursive: true
|
|
484
|
-
});
|
|
485
|
-
writeCombinedCoverage(nycOutputPath, coverage);
|
|
486
|
-
case 12:
|
|
487
|
-
case "end":
|
|
488
|
-
return _context.stop();
|
|
489
|
-
}
|
|
490
|
-
}, _callee);
|
|
491
|
-
}));
|
|
492
|
-
return function collectFrontendCoverage(_x) {
|
|
493
|
-
return _ref3.apply(this, arguments);
|
|
494
|
-
};
|
|
495
|
-
}();
|
|
496
|
-
var writeCoverage = function writeCoverage(nycOutputPath, nameSuffix, coverage) {
|
|
497
|
-
Object.values(coverage).forEach(function (value) {
|
|
498
|
-
if (value && value.path && value.hash) {
|
|
499
|
-
var _JSON$stringify;
|
|
500
|
-
var filename = path.join(nycOutputPath, "" + value.hash + nameSuffix + ".json");
|
|
501
|
-
debug('Writing coverage:', value.path, value.hash);
|
|
502
|
-
fs.writeFileSync(filename, JSON.stringify((_JSON$stringify = {}, _JSON$stringify[value.path] = value, _JSON$stringify), null, 2));
|
|
503
|
-
} else {
|
|
504
|
-
debug('Skip write coverage. Missing path or hash:', value);
|
|
505
|
-
}
|
|
506
|
-
});
|
|
507
|
-
};
|
|
508
|
-
/**
|
|
509
|
-
* Collects backend coverage reports from the provided URLs and stores them in the coverage folder
|
|
510
|
-
*/
|
|
511
|
-
var collectBackendCoverage = /*#__PURE__*/function () {
|
|
512
|
-
var _ref5 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref4) {
|
|
513
|
-
var coveragePath, coverageUrls, nycOutputPath, serverReports;
|
|
514
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
515
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
516
|
-
case 0:
|
|
517
|
-
coveragePath = _ref4.coveragePath, coverageUrls = _ref4.coverageUrls;
|
|
518
|
-
nycOutputPath = path.join(coveragePath, '.nyc_output');
|
|
519
|
-
debug('Collecting backend coverage reports', coverageUrls);
|
|
520
|
-
_context2.next = 5;
|
|
521
|
-
return Promise.all(coverageUrls.map(function (url) {
|
|
522
|
-
return fetch(url).then(function (res) {
|
|
523
|
-
var _res$headers$get;
|
|
524
|
-
if (res.ok && res.status === 200 && (_res$headers$get = res.headers.get('content-type')) != null && _res$headers$get.includes('application/json')) {
|
|
525
|
-
return res.json();
|
|
526
|
-
}
|
|
527
|
-
debug('Error fetching coverage report:', {
|
|
528
|
-
url: url,
|
|
529
|
-
status: res.status
|
|
530
|
-
});
|
|
531
|
-
return null;
|
|
532
|
-
})["catch"](function () {
|
|
533
|
-
debug('Error fetching coverage report:', {
|
|
534
|
-
url: url
|
|
535
|
-
});
|
|
536
|
-
return null;
|
|
537
|
-
});
|
|
538
|
-
}));
|
|
539
|
-
case 5:
|
|
540
|
-
serverReports = _context2.sent;
|
|
541
|
-
serverReports.forEach(function (report, index) {
|
|
542
|
-
writeCoverage(nycOutputPath, "-backend" + index, report.coverage);
|
|
543
|
-
});
|
|
544
|
-
case 7:
|
|
545
|
-
case "end":
|
|
546
|
-
return _context2.stop();
|
|
547
|
-
}
|
|
548
|
-
}, _callee2);
|
|
549
|
-
}));
|
|
550
|
-
return function collectBackendCoverage(_x2) {
|
|
551
|
-
return _ref5.apply(this, arguments);
|
|
552
|
-
};
|
|
553
|
-
}();
|
|
554
|
-
|
|
555
|
-
var _excluded = ["captureBeyondViewport"],
|
|
556
|
-
_excluded2 = ["userAgent", "isDarkMode", "viewport", "cookies"];
|
|
557
|
-
var _pkg$acceptanceTests, _ref, _projectConfig$covera, _projectConfig$covera2;
|
|
558
|
-
var LINUX_DOCKER_HOST_IP = '172.17.0.1';
|
|
559
|
-
var getGlobalBrowser = function getGlobalBrowser() {
|
|
560
|
-
return global.browser;
|
|
561
|
-
};
|
|
562
|
-
var getGlobalPage$1 = function getGlobalPage() {
|
|
563
|
-
return global.page;
|
|
564
|
-
};
|
|
565
|
-
var isCi = /*#__PURE__*/process.argv.includes('--ci') || process.env.CI;
|
|
566
|
-
var isUsingDockerizedChromium = isCi || /*#__PURE__*/new URL( /*#__PURE__*/getGlobalBrowser().wsEndpoint()).port === '9223';
|
|
567
|
-
/** Check if running inside WSL */
|
|
568
|
-
var isWsl = function isWsl() {
|
|
569
|
-
if (process.platform !== 'linux') {
|
|
570
|
-
return false;
|
|
571
|
-
}
|
|
572
|
-
try {
|
|
573
|
-
return child_process.execSync('which wsl.exe').toString().startsWith('/mnt/');
|
|
574
|
-
} catch (e) {
|
|
575
|
-
// catched because it throws an error if wsl.exe is not found
|
|
576
|
-
return false;
|
|
577
|
-
}
|
|
578
|
-
};
|
|
579
|
-
/** Assumes running inside WSL */
|
|
580
|
-
var isWsl2 = function isWsl2() {
|
|
581
|
-
// `wsl.exe -l -v` returns something like:
|
|
582
|
-
//
|
|
583
|
-
// NAME STATE VERSION
|
|
584
|
-
// * Ubuntu-22.04 Running 2
|
|
585
|
-
// docker-desktop-data Running 2
|
|
586
|
-
// docker-desktop Running 2
|
|
587
|
-
// Ubuntu-20.04 Stopped 2
|
|
588
|
-
return child_process.execSync('wsl.exe -l -v').toString()
|
|
589
|
-
// null-bytes are inserted between chars in this command output (UTF-16 output?)
|
|
590
|
-
.replace(/\0/g, '').split('\n').map(function (line) {
|
|
591
|
-
return line.trim();
|
|
592
|
-
})
|
|
593
|
-
// matches a line like: "* Ubuntu-22.04 Running 2"
|
|
594
|
-
.some(function (line) {
|
|
595
|
-
return !!line.match(/\*\s+\S+\s+Running\s+2/);
|
|
596
|
-
});
|
|
597
|
-
};
|
|
598
|
-
/** Assumes running inside WSL */
|
|
599
|
-
var getWslHostIp = function getWslHostIp() {
|
|
600
|
-
var ips = child_process.execSync('wsl.exe hostname -I').toString().trim().split(/\s+/);
|
|
601
|
-
if (ips.includes(LINUX_DOCKER_HOST_IP)) {
|
|
602
|
-
// looks like a docker engine installed inside linux
|
|
603
|
-
return LINUX_DOCKER_HOST_IP;
|
|
604
|
-
}
|
|
605
|
-
// assuming docker-desktop installed in windows
|
|
606
|
-
return ips[0];
|
|
607
|
-
};
|
|
608
|
-
var serverHostName = /*#__PURE__*/function () {
|
|
609
|
-
if (isCi) {
|
|
610
|
-
return 'localhost';
|
|
611
|
-
}
|
|
612
|
-
if (isUsingDockerizedChromium) {
|
|
613
|
-
if (isWsl()) {
|
|
614
|
-
if (isWsl2()) {
|
|
615
|
-
return getWslHostIp();
|
|
616
|
-
}
|
|
617
|
-
throw new Error('WSL 1 is not supported. Please, use WSL 2.');
|
|
618
|
-
}
|
|
619
|
-
if (process.platform === 'win32') {
|
|
620
|
-
throw new Error('Windows is not supported. Please, use WSL 2.');
|
|
621
|
-
}
|
|
622
|
-
return process.platform === 'linux' ? LINUX_DOCKER_HOST_IP : 'host.docker.internal';
|
|
623
|
-
}
|
|
624
|
-
return 'localhost';
|
|
625
|
-
}();
|
|
626
|
-
var rootDir = /*#__PURE__*/findRoot( /*#__PURE__*/process.cwd());
|
|
627
|
-
var pkg = /*#__PURE__*/JSON.parse( /*#__PURE__*/fs.readFileSync( /*#__PURE__*/path.join(rootDir, 'package.json'), 'utf-8'));
|
|
628
|
-
var projectConfig = (_pkg$acceptanceTests = pkg.acceptanceTests) != null ? _pkg$acceptanceTests : {};
|
|
629
|
-
debug('Project config:', projectConfig);
|
|
630
|
-
var server = (_ref = isCi ? projectConfig.ciServer : projectConfig.devServer) != null ? _ref : projectConfig.server;
|
|
631
|
-
var coveragePath = /*#__PURE__*/path.join(rootDir, (_projectConfig$covera = projectConfig.coveragePath) != null ? _projectConfig$covera : 'reports/coverage-acceptance');
|
|
632
|
-
var coverageUrls = (_projectConfig$covera2 = projectConfig.coverageUrls) != null ? _projectConfig$covera2 : [];
|
|
633
|
-
var serverPort = server == null ? void 0 : server.port;
|
|
634
|
-
var toMatchImageSnapshot = /*#__PURE__*/jestImageSnapshot.configureToMatchImageSnapshot({
|
|
635
|
-
failureThreshold: 0,
|
|
636
|
-
failureThresholdType: 'percent',
|
|
637
|
-
customSnapshotIdentifier: function customSnapshotIdentifier(_ref2) {
|
|
638
|
-
var defaultIdentifier = _ref2.defaultIdentifier;
|
|
639
|
-
return defaultIdentifier;
|
|
640
|
-
}
|
|
641
|
-
});
|
|
642
|
-
var calledToMatchImageSnapshotOutsideDocker = false;
|
|
643
|
-
var localToMatchImageSnapshot = function localToMatchImageSnapshot() {
|
|
644
|
-
calledToMatchImageSnapshotOutsideDocker = true;
|
|
645
|
-
// let the expectation pass, then fail in afterEach. This way we allow developers to debug screenshot tests in local
|
|
646
|
-
// but don't allow them to save screenshots taken outside the dockerized chromium
|
|
647
|
-
return {
|
|
648
|
-
message: function message() {
|
|
649
|
-
return '';
|
|
650
|
-
},
|
|
651
|
-
pass: true
|
|
652
|
-
};
|
|
653
|
-
};
|
|
654
|
-
expect.extend({
|
|
655
|
-
toMatchImageSnapshot: isUsingDockerizedChromium ? toMatchImageSnapshot : localToMatchImageSnapshot
|
|
656
|
-
});
|
|
657
|
-
afterEach(function () {
|
|
658
|
-
if (calledToMatchImageSnapshotOutsideDocker) {
|
|
659
|
-
var error = new Error("Calling .toMatchImageSnapshot() is not allowed outside dockerized browser. Please, run your screenshot test in headless mode.");
|
|
660
|
-
error.stack = (error.stack || '').split('\n')[0];
|
|
661
|
-
throw error;
|
|
662
|
-
}
|
|
663
|
-
});
|
|
664
|
-
var waitForPaintEnd = /*#__PURE__*/function () {
|
|
665
|
-
var _ref3 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(element, _temp) {
|
|
666
|
-
var _ref4, _ref4$fullPage, fullPage, captureBeyondViewport, MAX_WAIT, STEP_TIME, t0, buf1, buf2;
|
|
667
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
668
|
-
while (1) switch (_context.prev = _context.next) {
|
|
669
|
-
case 0:
|
|
670
|
-
_ref4 = _temp === void 0 ? {} : _temp, _ref4$fullPage = _ref4.fullPage, fullPage = _ref4$fullPage === void 0 ? true : _ref4$fullPage, captureBeyondViewport = _ref4.captureBeyondViewport;
|
|
671
|
-
MAX_WAIT = 15000;
|
|
672
|
-
STEP_TIME = 250;
|
|
673
|
-
t0 = Date.now();
|
|
674
|
-
_context.next = 6;
|
|
675
|
-
return element.screenshot(normalizeSreenshotOptions({
|
|
676
|
-
fullPage: fullPage,
|
|
677
|
-
captureBeyondViewport: captureBeyondViewport
|
|
678
|
-
}));
|
|
679
|
-
case 6:
|
|
680
|
-
buf1 = _context.sent;
|
|
681
|
-
_context.next = 9;
|
|
682
|
-
return new Promise(function (r) {
|
|
683
|
-
return setTimeout(r, STEP_TIME);
|
|
684
|
-
});
|
|
685
|
-
case 9:
|
|
686
|
-
_context.next = 11;
|
|
687
|
-
return element.screenshot(normalizeSreenshotOptions({
|
|
688
|
-
fullPage: fullPage,
|
|
689
|
-
captureBeyondViewport: captureBeyondViewport
|
|
690
|
-
}));
|
|
691
|
-
case 11:
|
|
692
|
-
buf2 = _context.sent;
|
|
693
|
-
case 12:
|
|
694
|
-
if (!buf1.compare(buf2)) {
|
|
695
|
-
_context.next = 23;
|
|
696
|
-
break;
|
|
697
|
-
}
|
|
698
|
-
if (!(Date.now() - t0 > MAX_WAIT)) {
|
|
699
|
-
_context.next = 15;
|
|
700
|
-
break;
|
|
701
|
-
}
|
|
702
|
-
throw Error('Paint end timeout');
|
|
703
|
-
case 15:
|
|
704
|
-
buf1 = buf2;
|
|
705
|
-
_context.next = 18;
|
|
706
|
-
return new Promise(function (r) {
|
|
707
|
-
return setTimeout(r, STEP_TIME);
|
|
708
|
-
});
|
|
709
|
-
case 18:
|
|
710
|
-
_context.next = 20;
|
|
711
|
-
return element.screenshot(normalizeSreenshotOptions({
|
|
712
|
-
fullPage: fullPage,
|
|
713
|
-
captureBeyondViewport: captureBeyondViewport
|
|
714
|
-
}));
|
|
715
|
-
case 20:
|
|
716
|
-
buf2 = _context.sent;
|
|
717
|
-
_context.next = 12;
|
|
718
|
-
break;
|
|
719
|
-
case 23:
|
|
720
|
-
case "end":
|
|
721
|
-
return _context.stop();
|
|
722
|
-
}
|
|
723
|
-
}, _callee);
|
|
724
|
-
}));
|
|
725
|
-
return function waitForPaintEnd(_x, _x2) {
|
|
726
|
-
return _ref3.apply(this, arguments);
|
|
727
|
-
};
|
|
728
|
-
}();
|
|
729
|
-
var normalizeSreenshotOptions = function normalizeSreenshotOptions(_temp2) {
|
|
730
|
-
var _ref5 = _temp2 === void 0 ? {} : _temp2,
|
|
731
|
-
_ref5$captureBeyondVi = _ref5.captureBeyondViewport,
|
|
732
|
-
captureBeyondViewport = _ref5$captureBeyondVi === void 0 ? false : _ref5$captureBeyondVi,
|
|
733
|
-
options = _objectWithoutPropertiesLoose(_ref5, _excluded);
|
|
734
|
-
// Puppeter default for captureBeyondViewport is true, but we think false is a better default.
|
|
735
|
-
// When this is true, the fixed elements (like fixed footers) are relative to the original page
|
|
736
|
-
// viewport, not to the full page, so those elements look weird in fullPage screenshots.
|
|
737
|
-
return _extends({}, options, {
|
|
738
|
-
captureBeyondViewport: captureBeyondViewport
|
|
739
|
-
});
|
|
740
|
-
};
|
|
741
|
-
// Puppeteer already calls scrollIntoViewIfNeeded before clicking an element. But it doesn't work in all situations
|
|
742
|
-
// For example, when there is a fixed footer in the page and the element to click is under it, the browser won't scroll
|
|
743
|
-
// because the element is already in the viewport (the ifNeeded part is important here). By forcing the scroll to the
|
|
744
|
-
// center, we manage to fix these edge cases.
|
|
745
|
-
var scrollIntoView = function scrollIntoView(el) {
|
|
746
|
-
return el.evaluate(function (e) {
|
|
747
|
-
return e.scrollIntoView({
|
|
748
|
-
block: 'center'
|
|
749
|
-
});
|
|
750
|
-
});
|
|
751
|
-
};
|
|
752
|
-
var getPageApi = function getPageApi(page) {
|
|
753
|
-
var api = Object.create(page);
|
|
754
|
-
api.type = /*#__PURE__*/function () {
|
|
755
|
-
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(elementHandle, text, options) {
|
|
756
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
757
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
758
|
-
case 0:
|
|
759
|
-
_context2.next = 2;
|
|
760
|
-
return scrollIntoView(elementHandle);
|
|
761
|
-
case 2:
|
|
762
|
-
return _context2.abrupt("return", elementHandle.type(text, options));
|
|
763
|
-
case 3:
|
|
764
|
-
case "end":
|
|
765
|
-
return _context2.stop();
|
|
766
|
-
}
|
|
767
|
-
}, _callee2);
|
|
768
|
-
}));
|
|
769
|
-
return function (_x3, _x4, _x5) {
|
|
770
|
-
return _ref6.apply(this, arguments);
|
|
771
|
-
};
|
|
772
|
-
}();
|
|
773
|
-
api.click = /*#__PURE__*/function () {
|
|
774
|
-
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(elementHandle, options) {
|
|
775
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
776
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
777
|
-
case 0:
|
|
778
|
-
_context3.next = 2;
|
|
779
|
-
return scrollIntoView(elementHandle);
|
|
780
|
-
case 2:
|
|
781
|
-
return _context3.abrupt("return", elementHandle.click(options));
|
|
782
|
-
case 3:
|
|
783
|
-
case "end":
|
|
784
|
-
return _context3.stop();
|
|
785
|
-
}
|
|
786
|
-
}, _callee3);
|
|
787
|
-
}));
|
|
788
|
-
return function (_x6, _x7) {
|
|
789
|
-
return _ref7.apply(this, arguments);
|
|
790
|
-
};
|
|
791
|
-
}();
|
|
792
|
-
api.select = /*#__PURE__*/function () {
|
|
793
|
-
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(elementHandle) {
|
|
794
|
-
var _len,
|
|
795
|
-
values,
|
|
796
|
-
_key,
|
|
797
|
-
_args4 = arguments;
|
|
798
|
-
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
799
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
800
|
-
case 0:
|
|
801
|
-
_context4.next = 2;
|
|
802
|
-
return scrollIntoView(elementHandle);
|
|
803
|
-
case 2:
|
|
804
|
-
for (_len = _args4.length, values = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
805
|
-
values[_key - 1] = _args4[_key];
|
|
806
|
-
}
|
|
807
|
-
return _context4.abrupt("return", elementHandle.select.apply(elementHandle, values));
|
|
808
|
-
case 4:
|
|
809
|
-
case "end":
|
|
810
|
-
return _context4.stop();
|
|
811
|
-
}
|
|
812
|
-
}, _callee4);
|
|
813
|
-
}));
|
|
814
|
-
return function (_x8) {
|
|
815
|
-
return _ref8.apply(this, arguments);
|
|
816
|
-
};
|
|
817
|
-
}();
|
|
818
|
-
api.screenshot = /*#__PURE__*/function () {
|
|
819
|
-
var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(options) {
|
|
820
|
-
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
821
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
822
|
-
case 0:
|
|
823
|
-
if (options != null && options.skipNetworkWait) {
|
|
824
|
-
_context5.next = 3;
|
|
825
|
-
break;
|
|
826
|
-
}
|
|
827
|
-
_context5.next = 3;
|
|
828
|
-
return page.waitForNetworkIdle();
|
|
829
|
-
case 3:
|
|
830
|
-
_context5.next = 5;
|
|
831
|
-
return waitForPaintEnd(page, options);
|
|
832
|
-
case 5:
|
|
833
|
-
return _context5.abrupt("return", page.screenshot(normalizeSreenshotOptions(options)));
|
|
834
|
-
case 6:
|
|
835
|
-
case "end":
|
|
836
|
-
return _context5.stop();
|
|
837
|
-
}
|
|
838
|
-
}, _callee5);
|
|
839
|
-
}));
|
|
840
|
-
return function (_x9) {
|
|
841
|
-
return _ref9.apply(this, arguments);
|
|
842
|
-
};
|
|
843
|
-
}();
|
|
844
|
-
api.clear = /*#__PURE__*/function () {
|
|
845
|
-
var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(elementHandle) {
|
|
846
|
-
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
847
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
848
|
-
case 0:
|
|
849
|
-
_context6.next = 2;
|
|
850
|
-
return elementHandle.click({
|
|
851
|
-
clickCount: 3
|
|
852
|
-
});
|
|
853
|
-
case 2:
|
|
854
|
-
_context6.next = 4;
|
|
855
|
-
return elementHandle.press('Delete');
|
|
856
|
-
case 4:
|
|
857
|
-
case "end":
|
|
858
|
-
return _context6.stop();
|
|
859
|
-
}
|
|
860
|
-
}, _callee6);
|
|
861
|
-
}));
|
|
862
|
-
return function (_x10) {
|
|
863
|
-
return _ref10.apply(this, arguments);
|
|
864
|
-
};
|
|
865
|
-
}();
|
|
866
|
-
// For some reason, puppeteer browserContext.overridePermissions doesn't work with newer chrome versions.
|
|
867
|
-
// This workaround polyfills the browser geolocation api to return the mocked position
|
|
868
|
-
api.setGeolocation = function (position) {
|
|
869
|
-
return page.evaluate(function (position) {
|
|
870
|
-
window.navigator.geolocation.getCurrentPosition = function (callback) {
|
|
871
|
-
// @ts-expect-error - puppeteer's setGeoLocation does not expect a timestamp to be passed
|
|
872
|
-
callback({
|
|
873
|
-
coords: position
|
|
874
|
-
});
|
|
875
|
-
};
|
|
876
|
-
}, position);
|
|
877
|
-
};
|
|
878
|
-
return api;
|
|
879
|
-
};
|
|
880
|
-
var needsRequestInterception = false;
|
|
881
|
-
var requestHandlers = [];
|
|
882
|
-
var requestInterceptor = /*#__PURE__*/function () {
|
|
883
|
-
var _ref11 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(req) {
|
|
884
|
-
var _requestHandlers$find;
|
|
885
|
-
var _ref12, handler, response;
|
|
886
|
-
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
887
|
-
while (1) switch (_context7.prev = _context7.next) {
|
|
888
|
-
case 0:
|
|
889
|
-
_ref12 = (_requestHandlers$find = requestHandlers.find(function (_ref13) {
|
|
890
|
-
var matcher = _ref13.matcher;
|
|
891
|
-
return matcher(req);
|
|
892
|
-
})) != null ? _requestHandlers$find : {
|
|
893
|
-
handler: null
|
|
894
|
-
}, handler = _ref12.handler;
|
|
895
|
-
if (handler) {
|
|
896
|
-
_context7.next = 4;
|
|
897
|
-
break;
|
|
898
|
-
}
|
|
899
|
-
req["continue"]();
|
|
900
|
-
return _context7.abrupt("return");
|
|
901
|
-
case 4:
|
|
902
|
-
_context7.next = 6;
|
|
903
|
-
return handler(req);
|
|
904
|
-
case 6:
|
|
905
|
-
response = _context7.sent;
|
|
906
|
-
req.respond(response);
|
|
907
|
-
case 8:
|
|
908
|
-
case "end":
|
|
909
|
-
return _context7.stop();
|
|
910
|
-
}
|
|
911
|
-
}, _callee7);
|
|
912
|
-
}));
|
|
913
|
-
return function requestInterceptor(_x11) {
|
|
914
|
-
return _ref11.apply(this, arguments);
|
|
915
|
-
};
|
|
916
|
-
}();
|
|
917
|
-
var interceptRequest = function interceptRequest(matcher) {
|
|
918
|
-
needsRequestInterception = true;
|
|
919
|
-
var spy = jest.fn();
|
|
920
|
-
requestHandlers.push({
|
|
921
|
-
matcher: matcher,
|
|
922
|
-
handler: spy
|
|
923
|
-
});
|
|
924
|
-
return spy;
|
|
925
|
-
};
|
|
926
|
-
var createApiEndpointMock = function createApiEndpointMock(_temp3) {
|
|
927
|
-
var _ref15;
|
|
928
|
-
var _ref14 = _temp3 === void 0 ? {} : _temp3,
|
|
929
|
-
origin = _ref14.origin,
|
|
930
|
-
baseUrl = _ref14.baseUrl;
|
|
931
|
-
var originRegExp = globToRegExp((_ref15 = origin != null ? origin : baseUrl) != null ? _ref15 : '*');
|
|
932
|
-
interceptRequest(function (req) {
|
|
933
|
-
var _URL = new URL(req.url()),
|
|
934
|
-
origin = _URL.origin;
|
|
935
|
-
return req.method() === 'OPTIONS' && !!origin.match(originRegExp);
|
|
936
|
-
}).mockImplementation(function () {
|
|
937
|
-
return {
|
|
938
|
-
status: 204,
|
|
939
|
-
headers: {
|
|
940
|
-
'Access-Control-Allow-Origin': '*',
|
|
941
|
-
'Access-Control-Allow-Methods': 'POST,PATCH,PUT,GET,OPTIONS,DELETE',
|
|
942
|
-
'Access-Control-Allow-Headers': '*'
|
|
943
|
-
}
|
|
944
|
-
};
|
|
945
|
-
});
|
|
946
|
-
return {
|
|
947
|
-
spyOn: function spyOn(spiedPath, method) {
|
|
948
|
-
if (method === void 0) {
|
|
949
|
-
method = 'GET';
|
|
950
|
-
}
|
|
951
|
-
var matcher = function matcher(req) {
|
|
952
|
-
var _URL2 = new URL(req.url()),
|
|
953
|
-
origin = _URL2.origin,
|
|
954
|
-
pathname = _URL2.pathname,
|
|
955
|
-
search = _URL2.search;
|
|
956
|
-
var pathWithParams = pathname + search;
|
|
957
|
-
return req.method() === method && !!origin.match(originRegExp) && matchPath(spiedPath, pathWithParams);
|
|
958
|
-
};
|
|
959
|
-
var spy = jest.fn();
|
|
960
|
-
interceptRequest(matcher).mockImplementation( /*#__PURE__*/function () {
|
|
961
|
-
var _ref16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(req) {
|
|
962
|
-
var _spyResult$status;
|
|
963
|
-
var spyResult, status, resBody;
|
|
964
|
-
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
965
|
-
while (1) switch (_context8.prev = _context8.next) {
|
|
966
|
-
case 0:
|
|
967
|
-
_context8.next = 2;
|
|
968
|
-
return spy(req);
|
|
969
|
-
case 2:
|
|
970
|
-
spyResult = _context8.sent;
|
|
971
|
-
status = (_spyResult$status = spyResult.status) != null ? _spyResult$status : 200;
|
|
972
|
-
resBody = spyResult.body || spyResult;
|
|
973
|
-
return _context8.abrupt("return", {
|
|
974
|
-
status: status,
|
|
975
|
-
headers: {
|
|
976
|
-
'Access-Control-Allow-Origin': '*'
|
|
977
|
-
},
|
|
978
|
-
contentType: 'application/json',
|
|
979
|
-
body: JSON.stringify(resBody)
|
|
980
|
-
});
|
|
981
|
-
case 6:
|
|
982
|
-
case "end":
|
|
983
|
-
return _context8.stop();
|
|
984
|
-
}
|
|
985
|
-
}, _callee8);
|
|
986
|
-
}));
|
|
987
|
-
return function (_x12) {
|
|
988
|
-
return _ref16.apply(this, arguments);
|
|
989
|
-
};
|
|
990
|
-
}());
|
|
991
|
-
return spy;
|
|
992
|
-
}
|
|
993
|
-
};
|
|
994
|
-
};
|
|
995
|
-
var openPage = /*#__PURE__*/function () {
|
|
996
|
-
var _ref18 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(_ref17) {
|
|
997
|
-
var userAgent, isDarkMode, viewport, cookies, urlConfig, url, currentUserAgent, page, connectionError;
|
|
998
|
-
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
999
|
-
while (1) switch (_context9.prev = _context9.next) {
|
|
1000
|
-
case 0:
|
|
1001
|
-
userAgent = _ref17.userAgent, isDarkMode = _ref17.isDarkMode, viewport = _ref17.viewport, cookies = _ref17.cookies, urlConfig = /*#__PURE__*/_objectWithoutPropertiesLoose(_ref17, _excluded2);
|
|
1002
|
-
url = function () {
|
|
1003
|
-
if (urlConfig.url !== undefined) {
|
|
1004
|
-
return urlConfig.url;
|
|
1005
|
-
}
|
|
1006
|
-
var _urlConfig$path = urlConfig.path,
|
|
1007
|
-
path = _urlConfig$path === void 0 ? '/' : _urlConfig$path,
|
|
1008
|
-
_urlConfig$port = urlConfig.port,
|
|
1009
|
-
port = _urlConfig$port === void 0 ? serverPort : _urlConfig$port,
|
|
1010
|
-
_urlConfig$protocol = urlConfig.protocol,
|
|
1011
|
-
protocol = _urlConfig$protocol === void 0 ? 'http' : _urlConfig$protocol,
|
|
1012
|
-
_urlConfig$hostname = urlConfig.hostname,
|
|
1013
|
-
hostname = _urlConfig$hostname === void 0 ? serverHostName : _urlConfig$hostname;
|
|
1014
|
-
if (!port) {
|
|
1015
|
-
// Error.captureStackTrace(error, openPage);
|
|
1016
|
-
throw new Error('You must specify a port. You can specify it when calling openPage() or by configuring a dev and ci server in the acceptanceTests config in your package.json');
|
|
1017
|
-
}
|
|
1018
|
-
return protocol + "://" + hostname + ":" + port + path;
|
|
1019
|
-
}();
|
|
1020
|
-
debug('Opening page:', url);
|
|
1021
|
-
_context9.t0 = userAgent;
|
|
1022
|
-
if (_context9.t0) {
|
|
1023
|
-
_context9.next = 8;
|
|
1024
|
-
break;
|
|
1025
|
-
}
|
|
1026
|
-
_context9.next = 7;
|
|
1027
|
-
return getGlobalBrowser().userAgent();
|
|
1028
|
-
case 7:
|
|
1029
|
-
_context9.t0 = _context9.sent;
|
|
1030
|
-
case 8:
|
|
1031
|
-
currentUserAgent = _context9.t0;
|
|
1032
|
-
page = getGlobalPage$1();
|
|
1033
|
-
_context9.next = 12;
|
|
1034
|
-
return page.bringToFront();
|
|
1035
|
-
case 12:
|
|
1036
|
-
if (!viewport) {
|
|
1037
|
-
_context9.next = 15;
|
|
1038
|
-
break;
|
|
1039
|
-
}
|
|
1040
|
-
_context9.next = 15;
|
|
1041
|
-
return page.setViewport(viewport);
|
|
1042
|
-
case 15:
|
|
1043
|
-
if (!cookies) {
|
|
1044
|
-
_context9.next = 18;
|
|
1045
|
-
break;
|
|
1046
|
-
}
|
|
1047
|
-
_context9.next = 18;
|
|
1048
|
-
return page.setCookie.apply(page, cookies);
|
|
1049
|
-
case 18:
|
|
1050
|
-
_context9.next = 20;
|
|
1051
|
-
return page.setUserAgent(currentUserAgent + " acceptance-test");
|
|
1052
|
-
case 20:
|
|
1053
|
-
_context9.next = 22;
|
|
1054
|
-
return page.emulateMediaFeatures([{
|
|
1055
|
-
name: 'prefers-color-scheme',
|
|
1056
|
-
value: isDarkMode ? 'dark' : 'light'
|
|
1057
|
-
}]);
|
|
1058
|
-
case 22:
|
|
1059
|
-
_context9.next = 24;
|
|
1060
|
-
return page.evaluateOnNewDocument(function (viewport) {
|
|
1061
|
-
var _viewport$safeAreaIns;
|
|
1062
|
-
var overriddenSafeAreaInsets = !viewport ? [] : Object.keys((_viewport$safeAreaIns = viewport == null ? void 0 : viewport.safeAreaInset) != null ? _viewport$safeAreaIns : {}).map(function (key) {
|
|
1063
|
-
var _viewport$safeAreaIns2;
|
|
1064
|
-
var position = key;
|
|
1065
|
-
return "--acceptance-test-override-safe-area-inset-" + key + ": " + (viewport == null ? void 0 : (_viewport$safeAreaIns2 = viewport.safeAreaInset) == null ? void 0 : _viewport$safeAreaIns2[position]) + ";";
|
|
1066
|
-
});
|
|
1067
|
-
var style = document.createElement('style');
|
|
1068
|
-
style.innerHTML = "\n *, *:after, *:before {\n transition-delay: 0s !important;\n transition-duration: 0s !important;\n animation-delay: -0.0001s !important;\n animation-duration: 0s !important;\n animation-play-state: paused !important;\n caret-color: transparent !important;\n font-variant-ligatures: none !important;\n }\n *::-webkit-scrollbar {\n display: none !important;\n width: 0 !important;\n height: 0 !important;\n }\n :root {\n " + overriddenSafeAreaInsets.join('\n') + "\n }\n ";
|
|
1069
|
-
window.addEventListener('DOMContentLoaded', function () {
|
|
1070
|
-
document.head.appendChild(style);
|
|
1071
|
-
});
|
|
1072
|
-
}, viewport);
|
|
1073
|
-
case 24:
|
|
1074
|
-
if (!needsRequestInterception) {
|
|
1075
|
-
_context9.next = 28;
|
|
1076
|
-
break;
|
|
1077
|
-
}
|
|
1078
|
-
_context9.next = 27;
|
|
1079
|
-
return page.setRequestInterception(true);
|
|
1080
|
-
case 27:
|
|
1081
|
-
page.on('request', requestInterceptor);
|
|
1082
|
-
case 28:
|
|
1083
|
-
_context9.prev = 28;
|
|
1084
|
-
_context9.next = 31;
|
|
1085
|
-
return page["goto"](url);
|
|
1086
|
-
case 31:
|
|
1087
|
-
_context9.next = 42;
|
|
1088
|
-
break;
|
|
1089
|
-
case 33:
|
|
1090
|
-
_context9.prev = 33;
|
|
1091
|
-
_context9.t1 = _context9["catch"](28);
|
|
1092
|
-
if (!_context9.t1.message.includes('net::ERR_CONNECTION_REFUSED')) {
|
|
1093
|
-
_context9.next = 41;
|
|
1094
|
-
break;
|
|
1095
|
-
}
|
|
1096
|
-
connectionError = new Error("Could not connect to " + url + ". Is the server running?");
|
|
1097
|
-
Error.captureStackTrace(connectionError, openPage);
|
|
1098
|
-
throw connectionError;
|
|
1099
|
-
case 41:
|
|
1100
|
-
throw _context9.t1;
|
|
1101
|
-
case 42:
|
|
1102
|
-
_context9.next = 44;
|
|
1103
|
-
return page.waitForFunction('document.fonts.status === "loaded"');
|
|
1104
|
-
case 44:
|
|
1105
|
-
return _context9.abrupt("return", getPageApi(page));
|
|
1106
|
-
case 45:
|
|
1107
|
-
case "end":
|
|
1108
|
-
return _context9.stop();
|
|
1109
|
-
}
|
|
1110
|
-
}, _callee9, null, [[28, 33]]);
|
|
1111
|
-
}));
|
|
1112
|
-
return function openPage(_x13) {
|
|
1113
|
-
return _ref18.apply(this, arguments);
|
|
1114
|
-
};
|
|
1115
|
-
}();
|
|
1116
|
-
var buildQueryMethods = function buildQueryMethods(_temp4) {
|
|
1117
|
-
var _ref19 = _temp4 === void 0 ? {} : _temp4,
|
|
1118
|
-
page = _ref19.page,
|
|
1119
|
-
element = _ref19.element;
|
|
1120
|
-
var boundQueries = {};
|
|
1121
|
-
var _loop = function _loop() {
|
|
1122
|
-
var _Object$entries$_i = _Object$entries[_i],
|
|
1123
|
-
queryName = _Object$entries$_i[0],
|
|
1124
|
-
queryFn = _Object$entries$_i[1];
|
|
1125
|
-
boundQueries[queryName] = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
1126
|
-
var doc,
|
|
1127
|
-
body,
|
|
1128
|
-
_len2,
|
|
1129
|
-
args,
|
|
1130
|
-
_key2,
|
|
1131
|
-
queryArgs,
|
|
1132
|
-
elementHandle,
|
|
1133
|
-
newElementHandle,
|
|
1134
|
-
_args14 = arguments;
|
|
1135
|
-
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
1136
|
-
while (1) switch (_context14.prev = _context14.next) {
|
|
1137
|
-
case 0:
|
|
1138
|
-
_context14.next = 2;
|
|
1139
|
-
return pptrTestingLibrary.getDocument(page != null ? page : getGlobalPage$1());
|
|
1140
|
-
case 2:
|
|
1141
|
-
doc = _context14.sent;
|
|
1142
|
-
_context14.next = 5;
|
|
1143
|
-
return doc.$('body');
|
|
1144
|
-
case 5:
|
|
1145
|
-
body = _context14.sent;
|
|
1146
|
-
for (_len2 = _args14.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
1147
|
-
args[_key2] = _args14[_key2];
|
|
1148
|
-
}
|
|
1149
|
-
queryArgs = [].concat(args);
|
|
1150
|
-
if (queryName.startsWith('findBy')) {
|
|
1151
|
-
if (queryArgs.length === 1) {
|
|
1152
|
-
queryArgs.push(undefined);
|
|
1153
|
-
}
|
|
1154
|
-
queryArgs.push({
|
|
1155
|
-
timeout: 10000
|
|
1156
|
-
});
|
|
1157
|
-
}
|
|
1158
|
-
_context14.next = 11;
|
|
1159
|
-
return queryFn.apply(void 0, [element != null ? element : body].concat(queryArgs));
|
|
1160
|
-
case 11:
|
|
1161
|
-
elementHandle = _context14.sent;
|
|
1162
|
-
newElementHandle = Object.create(elementHandle);
|
|
1163
|
-
newElementHandle.screenshot = /*#__PURE__*/function () {
|
|
1164
|
-
var _ref21 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(options) {
|
|
1165
|
-
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
1166
|
-
while (1) switch (_context10.prev = _context10.next) {
|
|
1167
|
-
case 0:
|
|
1168
|
-
if (options != null && options.skipNetworkWait) {
|
|
1169
|
-
_context10.next = 3;
|
|
1170
|
-
break;
|
|
1171
|
-
}
|
|
1172
|
-
_context10.next = 3;
|
|
1173
|
-
return (page != null ? page : getGlobalPage$1()).waitForNetworkIdle();
|
|
1174
|
-
case 3:
|
|
1175
|
-
_context10.next = 5;
|
|
1176
|
-
return waitForPaintEnd(elementHandle, _extends({}, options, {
|
|
1177
|
-
fullPage: false
|
|
1178
|
-
}));
|
|
1179
|
-
case 5:
|
|
1180
|
-
return _context10.abrupt("return", elementHandle.screenshot(normalizeSreenshotOptions(options)));
|
|
1181
|
-
case 6:
|
|
1182
|
-
case "end":
|
|
1183
|
-
return _context10.stop();
|
|
1184
|
-
}
|
|
1185
|
-
}, _callee10);
|
|
1186
|
-
}));
|
|
1187
|
-
return function (_x14) {
|
|
1188
|
-
return _ref21.apply(this, arguments);
|
|
1189
|
-
};
|
|
1190
|
-
}();
|
|
1191
|
-
newElementHandle.click = /*#__PURE__*/function () {
|
|
1192
|
-
var _ref22 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(options) {
|
|
1193
|
-
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
1194
|
-
while (1) switch (_context11.prev = _context11.next) {
|
|
1195
|
-
case 0:
|
|
1196
|
-
_context11.next = 2;
|
|
1197
|
-
return scrollIntoView(elementHandle);
|
|
1198
|
-
case 2:
|
|
1199
|
-
return _context11.abrupt("return", elementHandle.click(options));
|
|
1200
|
-
case 3:
|
|
1201
|
-
case "end":
|
|
1202
|
-
return _context11.stop();
|
|
1203
|
-
}
|
|
1204
|
-
}, _callee11);
|
|
1205
|
-
}));
|
|
1206
|
-
return function (_x15) {
|
|
1207
|
-
return _ref22.apply(this, arguments);
|
|
1208
|
-
};
|
|
1209
|
-
}();
|
|
1210
|
-
newElementHandle.type = /*#__PURE__*/function () {
|
|
1211
|
-
var _ref23 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(text, options) {
|
|
1212
|
-
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
1213
|
-
while (1) switch (_context12.prev = _context12.next) {
|
|
1214
|
-
case 0:
|
|
1215
|
-
_context12.next = 2;
|
|
1216
|
-
return scrollIntoView(elementHandle);
|
|
1217
|
-
case 2:
|
|
1218
|
-
return _context12.abrupt("return", elementHandle.type(text, options));
|
|
1219
|
-
case 3:
|
|
1220
|
-
case "end":
|
|
1221
|
-
return _context12.stop();
|
|
1222
|
-
}
|
|
1223
|
-
}, _callee12);
|
|
1224
|
-
}));
|
|
1225
|
-
return function (_x16, _x17) {
|
|
1226
|
-
return _ref23.apply(this, arguments);
|
|
1227
|
-
};
|
|
1228
|
-
}();
|
|
1229
|
-
newElementHandle.select = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
1230
|
-
var _args13 = arguments;
|
|
1231
|
-
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
1232
|
-
while (1) switch (_context13.prev = _context13.next) {
|
|
1233
|
-
case 0:
|
|
1234
|
-
_context13.next = 2;
|
|
1235
|
-
return scrollIntoView(elementHandle);
|
|
1236
|
-
case 2:
|
|
1237
|
-
return _context13.abrupt("return", elementHandle.select.apply(elementHandle, _args13));
|
|
1238
|
-
case 3:
|
|
1239
|
-
case "end":
|
|
1240
|
-
return _context13.stop();
|
|
1241
|
-
}
|
|
1242
|
-
}, _callee13);
|
|
1243
|
-
}));
|
|
1244
|
-
return _context14.abrupt("return", newElementHandle);
|
|
1245
|
-
case 18:
|
|
1246
|
-
case "end":
|
|
1247
|
-
return _context14.stop();
|
|
1248
|
-
}
|
|
1249
|
-
}, _callee14);
|
|
1250
|
-
}));
|
|
1251
|
-
};
|
|
1252
|
-
for (var _i = 0, _Object$entries = Object.entries(pptrTestingLibrary.queries); _i < _Object$entries.length; _i++) {
|
|
1253
|
-
_loop();
|
|
1254
|
-
}
|
|
1255
|
-
return boundQueries;
|
|
1256
|
-
};
|
|
1257
|
-
var getScreen = function getScreen(page) {
|
|
1258
|
-
return buildQueryMethods({
|
|
1259
|
-
page: page
|
|
1260
|
-
});
|
|
1261
|
-
};
|
|
1262
|
-
var screen = /*#__PURE__*/buildQueryMethods();
|
|
1263
|
-
var within = function within(element) {
|
|
1264
|
-
return buildQueryMethods({
|
|
1265
|
-
element: element
|
|
1266
|
-
});
|
|
1267
|
-
};
|
|
1268
|
-
beforeEach( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
|
|
1269
|
-
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1270
|
-
while (1) switch (_context15.prev = _context15.next) {
|
|
1271
|
-
case 0:
|
|
1272
|
-
_context15.next = 2;
|
|
1273
|
-
return getGlobalPage$1().setRequestInterception(false);
|
|
1274
|
-
case 2:
|
|
1275
|
-
_context15.next = 4;
|
|
1276
|
-
return global.jestPuppeteer.resetPage();
|
|
1277
|
-
case 4:
|
|
1278
|
-
case "end":
|
|
1279
|
-
return _context15.stop();
|
|
1280
|
-
}
|
|
1281
|
-
}, _callee15);
|
|
1282
|
-
})));
|
|
1283
|
-
afterEach( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
|
|
1284
|
-
var page;
|
|
1285
|
-
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
1286
|
-
while (1) switch (_context16.prev = _context16.next) {
|
|
1287
|
-
case 0:
|
|
1288
|
-
if (!process.env.COLLECT_ACCEPTANCE_COVERAGE) {
|
|
1289
|
-
_context16.next = 3;
|
|
1290
|
-
break;
|
|
1291
|
-
}
|
|
1292
|
-
_context16.next = 3;
|
|
1293
|
-
return collectFrontendCoverage({
|
|
1294
|
-
coveragePath: coveragePath
|
|
1295
|
-
});
|
|
1296
|
-
case 3:
|
|
1297
|
-
_context16.prev = 3;
|
|
1298
|
-
page = getGlobalPage$1();
|
|
1299
|
-
requestHandlers = [];
|
|
1300
|
-
needsRequestInterception = false;
|
|
1301
|
-
page.off('request', requestInterceptor);
|
|
1302
|
-
// clear tab, this way we clear the DOM and stop js execution or pending requests
|
|
1303
|
-
_context16.next = 10;
|
|
1304
|
-
return page["goto"]('about:blank');
|
|
1305
|
-
case 10:
|
|
1306
|
-
_context16.next = 14;
|
|
1307
|
-
break;
|
|
1308
|
-
case 12:
|
|
1309
|
-
_context16.prev = 12;
|
|
1310
|
-
_context16.t0 = _context16["catch"](3);
|
|
1311
|
-
case 14:
|
|
1312
|
-
case "end":
|
|
1313
|
-
return _context16.stop();
|
|
1314
|
-
}
|
|
1315
|
-
}, _callee16, null, [[3, 12]]);
|
|
1316
|
-
})));
|
|
1317
|
-
afterAll( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
1318
|
-
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1319
|
-
while (1) switch (_context17.prev = _context17.next) {
|
|
1320
|
-
case 0:
|
|
1321
|
-
if (!process.env.COLLECT_ACCEPTANCE_COVERAGE) {
|
|
1322
|
-
_context17.next = 3;
|
|
1323
|
-
break;
|
|
1324
|
-
}
|
|
1325
|
-
_context17.next = 3;
|
|
1326
|
-
return collectBackendCoverage({
|
|
1327
|
-
coveragePath: coveragePath,
|
|
1328
|
-
coverageUrls: coverageUrls
|
|
1329
|
-
});
|
|
1330
|
-
case 3:
|
|
1331
|
-
case "end":
|
|
1332
|
-
return _context17.stop();
|
|
1333
|
-
}
|
|
1334
|
-
}, _callee17);
|
|
1335
|
-
})));
|
|
1336
|
-
/**
|
|
1337
|
-
* Returns a new path to the file that can be used by chromium in acceptance tests
|
|
1338
|
-
*
|
|
1339
|
-
* To be able to use `element.uploadFile()` in a dockerized chromium, the file must exist in the
|
|
1340
|
-
* host and the docker, and both sides must use the same path.
|
|
1341
|
-
*
|
|
1342
|
-
* To workaround this bug or limitation, this function prepares the file by copying it to /tmp in
|
|
1343
|
-
* the host and the container.
|
|
1344
|
-
*/
|
|
1345
|
-
var prepareFile = function prepareFile(filepath) {
|
|
1346
|
-
var isLocal = !isCi;
|
|
1347
|
-
var isHeadless = !!process.env.HEADLESS;
|
|
1348
|
-
var usesDocker = isLocal && isHeadless;
|
|
1349
|
-
var dockerComposeFile = path.join(__dirname, '..', 'docker-compose.yaml');
|
|
1350
|
-
if (usesDocker) {
|
|
1351
|
-
var containerId = child_process.execSync("docker compose -f " + dockerComposeFile + " ps -q").toString().trim();
|
|
1352
|
-
if (!containerId) {
|
|
1353
|
-
throw Error('acceptance-testing container not found');
|
|
1354
|
-
}
|
|
1355
|
-
child_process.execSync("docker cp " + filepath + " " + containerId + ":/tmp");
|
|
1356
|
-
var newPath = path.join('/tmp', path.basename(filepath));
|
|
1357
|
-
fs.copyFileSync(filepath, newPath);
|
|
1358
|
-
return newPath;
|
|
1359
|
-
} else {
|
|
1360
|
-
return filepath;
|
|
1361
|
-
}
|
|
1362
|
-
};
|
|
1363
|
-
/**
|
|
1364
|
-
* A convenience method to defer an expectation
|
|
1365
|
-
*/
|
|
1366
|
-
var wait = function wait(expectation, timeout, interval) {
|
|
1367
|
-
if (timeout === void 0) {
|
|
1368
|
-
timeout = 10000;
|
|
1369
|
-
}
|
|
1370
|
-
if (interval === void 0) {
|
|
1371
|
-
interval = 50;
|
|
1372
|
-
}
|
|
1373
|
-
var startTime = Date.now();
|
|
1374
|
-
var startStack = new Error().stack;
|
|
1375
|
-
return new Promise(function (resolve, reject) {
|
|
1376
|
-
var rejectOrRerun = function rejectOrRerun(error) {
|
|
1377
|
-
if (Date.now() - startTime >= timeout) {
|
|
1378
|
-
if (error instanceof Error) {
|
|
1379
|
-
if (error.message === 'Element not removed') {
|
|
1380
|
-
error.stack = startStack;
|
|
1381
|
-
}
|
|
1382
|
-
}
|
|
1383
|
-
reject(error);
|
|
1384
|
-
return;
|
|
1385
|
-
}
|
|
1386
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
1387
|
-
setTimeout(runExpectation, interval);
|
|
1388
|
-
};
|
|
1389
|
-
var runExpectation = function runExpectation() {
|
|
1390
|
-
try {
|
|
1391
|
-
Promise.resolve(expectation()).then(function (r) {
|
|
1392
|
-
return resolve(r);
|
|
1393
|
-
})["catch"](rejectOrRerun);
|
|
1394
|
-
} catch (error) {
|
|
1395
|
-
rejectOrRerun(error);
|
|
1396
|
-
}
|
|
1397
|
-
};
|
|
1398
|
-
setTimeout(runExpectation, 0);
|
|
1399
|
-
});
|
|
1400
|
-
};
|
|
1401
|
-
var waitForElementToBeRemoved = function waitForElementToBeRemoved(element, timeout, interval) {
|
|
1402
|
-
if (timeout === void 0) {
|
|
1403
|
-
timeout = 10000;
|
|
1404
|
-
}
|
|
1405
|
-
if (interval === void 0) {
|
|
1406
|
-
interval = 100;
|
|
1407
|
-
}
|
|
1408
|
-
var startStack = new Error().stack;
|
|
1409
|
-
var wait = /*#__PURE__*/function () {
|
|
1410
|
-
var _ref28 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
1411
|
-
var t0, box;
|
|
1412
|
-
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1413
|
-
while (1) switch (_context18.prev = _context18.next) {
|
|
1414
|
-
case 0:
|
|
1415
|
-
t0 = Date.now();
|
|
1416
|
-
case 1:
|
|
1417
|
-
if (!(Date.now() - t0 < timeout)) {
|
|
1418
|
-
_context18.next = 11;
|
|
1419
|
-
break;
|
|
1420
|
-
}
|
|
1421
|
-
_context18.next = 4;
|
|
1422
|
-
return element.boundingBox();
|
|
1423
|
-
case 4:
|
|
1424
|
-
box = _context18.sent;
|
|
1425
|
-
if (box) {
|
|
1426
|
-
_context18.next = 7;
|
|
1427
|
-
break;
|
|
1428
|
-
}
|
|
1429
|
-
return _context18.abrupt("return");
|
|
1430
|
-
case 7:
|
|
1431
|
-
_context18.next = 9;
|
|
1432
|
-
return new Promise(function (resolve) {
|
|
1433
|
-
return setTimeout(resolve, interval);
|
|
1434
|
-
});
|
|
1435
|
-
case 9:
|
|
1436
|
-
_context18.next = 1;
|
|
1437
|
-
break;
|
|
1438
|
-
case 11:
|
|
1439
|
-
throw new Error('Element not removed');
|
|
1440
|
-
case 12:
|
|
1441
|
-
case "end":
|
|
1442
|
-
return _context18.stop();
|
|
1443
|
-
}
|
|
1444
|
-
}, _callee18);
|
|
1445
|
-
}));
|
|
1446
|
-
return function wait() {
|
|
1447
|
-
return _ref28.apply(this, arguments);
|
|
1448
|
-
};
|
|
1449
|
-
}();
|
|
1450
|
-
return wait()["catch"](function (error) {
|
|
1451
|
-
if (error.message === 'Element not removed') {
|
|
1452
|
-
error.stack = startStack;
|
|
1453
|
-
}
|
|
1454
|
-
throw error;
|
|
1455
|
-
});
|
|
1456
|
-
};
|
|
1457
|
-
|
|
1458
|
-
exports.createApiEndpointMock = createApiEndpointMock;
|
|
1459
|
-
exports.getGlobalBrowser = getGlobalBrowser;
|
|
1460
|
-
exports.getGlobalPage = getGlobalPage$1;
|
|
1461
|
-
exports.getPageApi = getPageApi;
|
|
1462
|
-
exports.getScreen = getScreen;
|
|
1463
|
-
exports.interceptRequest = interceptRequest;
|
|
1464
|
-
exports.openPage = openPage;
|
|
1465
|
-
exports.prepareFile = prepareFile;
|
|
1466
|
-
exports.screen = screen;
|
|
1467
|
-
exports.serverHostName = serverHostName;
|
|
1468
|
-
exports.serverPort = serverPort;
|
|
1469
|
-
exports.wait = wait;
|
|
1470
|
-
exports.waitForElementToBeRemoved = waitForElementToBeRemoved;
|
|
1471
|
-
exports.within = within;
|
|
1472
|
-
//# sourceMappingURL=acceptance-testing.cjs.development.js.map
|