Innovenergy_trunk/frontend/node_modules/testcafe/lib/test-run/commands/options.js

386 lines
46 KiB
JavaScript
Raw Permalink Normal View History

"use strict";
// -------------------------------------------------------------
// WARNING: this file is used by both the client and the server.
// Do not use any browser or node-specific API!
// -------------------------------------------------------------
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SkipJsErrorsCallbackWithOptions = exports.SkipJsErrorsOptions = exports.GetProxyUrlOptions = exports.RequestOptions = exports.RequestProxyOptions = exports.RequestAuthOptions = exports.CookieOptions = exports.PressOptions = exports.AssertionOptions = exports.ResizeToFitDeviceOptions = exports.DragToElementOptions = exports.TypeOptions = exports.MoveOptions = exports.ClickOptions = exports.MouseOptions = exports.ModifiersOptions = exports.ElementScreenshotOptions = exports.CropOptions = exports.ScrollOptions = exports.OffsetOptions = exports.ActionOptions = exports.functionOption = exports.objectOption = exports.urlSearchParamsOption = exports.urlOption = exports.numberOption = exports.dateOption = exports.stringOrRegexOption = exports.stringOption = exports.speedOption = exports.booleanOption = exports.positiveIntegerOption = exports.integerOption = void 0;
const assignable_1 = __importDefault(require("../../utils/assignable"));
const factories_1 = require("./validations/factories");
const errors_1 = require("../../shared/errors");
exports.integerOption = (0, factories_1.createIntegerValidator)(errors_1.ActionIntegerOptionError);
exports.positiveIntegerOption = (0, factories_1.createPositiveIntegerValidator)(errors_1.ActionPositiveIntegerOptionError);
exports.booleanOption = (0, factories_1.createBooleanValidator)(errors_1.ActionBooleanOptionError);
exports.speedOption = (0, factories_1.createSpeedValidator)(errors_1.ActionSpeedOptionError);
exports.stringOption = (0, factories_1.createStringValidator)(errors_1.ActionStringOptionError);
exports.stringOrRegexOption = (0, factories_1.createStringOrRegexValidator)(errors_1.ActionStringOrRegexOptionError);
exports.dateOption = (0, factories_1.createDateValidator)(errors_1.ActionDateOptionError);
exports.numberOption = (0, factories_1.createNumberValidator)(errors_1.ActionNumberOptionError);
exports.urlOption = (0, factories_1.createUrlValidator)(errors_1.ActionUrlOptionError);
exports.urlSearchParamsOption = (0, factories_1.createUrlSearchParamsValidator)(errors_1.ActionUrlSearchParamsOptionError);
exports.objectOption = (0, factories_1.createObjectValidator)(errors_1.ActionObjectOptionError);
exports.functionOption = (0, factories_1.createFunctionValidator)(errors_1.ActionFunctionOptionError);
// Actions
class ActionOptions extends assignable_1.default {
constructor(obj, validate) {
super();
this.speed = null;
this._assignFrom(obj, validate);
}
getAssignableProperties() {
return [
{ name: 'speed', type: exports.speedOption },
];
}
}
exports.ActionOptions = ActionOptions;
// Offset
class OffsetOptions extends ActionOptions {
constructor(obj, validate) {
super();
this.offsetX = null;
this.offsetY = null;
this._assignFrom(obj, validate);
}
getAssignableProperties() {
return [
{ name: 'offsetX', type: exports.integerOption },
{ name: 'offsetY', type: exports.integerOption },
{ name: 'isDefaultOffset', type: exports.booleanOption },
];
}
}
exports.OffsetOptions = OffsetOptions;
class ScrollOptions extends OffsetOptions {
constructor(obj, validate) {
super();
this.scrollToCenter = false;
this.skipParentFrames = false;
this._assignFrom(obj, validate);
}
getAssignableProperties() {
return [
{ name: 'scrollToCenter', type: exports.booleanOption },
{ name: 'skipParentFrames', type: exports.booleanOption },
];
}
}
exports.ScrollOptions = ScrollOptions;
class CropOptions extends assignable_1.default {
constructor(obj, validate) {
super();
this._assignFrom(obj, validate);
}
getAssignableProperties() {
return [
{ name: 'left', type: exports.integerOption, defaultValue: null },
{ name: 'right', type: exports.integerOption, defaultValue: null },
{ name: 'top', type: exports.integerOption, defaultValue: null },
{ name: 'bottom', type: exports.integerOption, defaultValue: null },
];
}
}
exports.CropOptions = CropOptions;
// Element Screenshot
class ElementScreenshotOptions extends ActionOptions {
constructor(obj, validate) {
super();
this.scrollTargetX = null;
this.scrollTargetY = null;
this.includeMargins = false;
this.includeBorders = true;
this.includePaddings = true;
this.crop = {
left: null,
right: null,
top: null,
bottom: null,
};
this._assignFrom(obj, validate);
}
getAssignableProperties() {
return [
{ name: 'scrollTargetX', type: exports.integerOption },
{ name: 'scrollTargetY', type: exports.integerOption },
{ name: 'crop', type: exports.objectOption, init: initCropOptions },
{ name: 'includeMargins', type: exports.booleanOption },
{ name: 'includeBorders', type: exports.booleanOption },
{ name: 'includePaddings', type: exports.booleanOption },
];
}
}
exports.ElementScreenshotOptions = ElementScreenshotOptions;
class ModifiersOptions extends assignable_1.default {
constructor(obj, validate) {
super();
this._assignFrom(obj, validate);
}
getAssignableProperties() {
return [
{ name: 'ctrl', type: exports.booleanOption, defaultValue: false },
{ name: 'alt', type: exports.booleanOption, defaultValue: false },
{ name: 'shift', type: exports.booleanOption, defaultValue: false },
{ name: 'meta', type: exports.booleanOption, defaultValue: false },
];
}
}
exports.ModifiersOptions = ModifiersOptions;
// Mouse
class MouseOptions extends OffsetOptions {
constructor(obj, validate) {
super();
this.modifiers = {
ctrl: false,
alt: false,
shift: false,
meta: false,
};
this._assignFrom(obj, validate);
}
getAssignableProperties() {
return [
{ name: 'modifiers', type: exports.objectOption, init: initModifiersOptions },
];
}
}
exports.MouseOptions = MouseOptions;
// Click
class ClickOptions extends MouseOptions {
constructor(obj, validate) {
super();
this.caretPos = null;
this._assignFrom(obj, validate);
}
getAssignableProperties() {
return [
{ name: 'caretPos', type: exports.positiveIntegerOption },
];
}
}
exports.ClickOptions = ClickOptions;
// Move
class MoveOptions extends MouseOptions {
constructor(obj, validate) {
super();
this.speed = null;
this.minMovingTime = null;
this.holdLeftButton = false;
this.skipScrolling = false;
this.skipDefaultDragBehavior = false;
this._assignFrom(obj, validate);
}
getAssignableProperties() {
return [
{ name: 'speed' },
{ name: 'minMovingTime' },
{ name: 'holdLeftButton' },
{ name: 'skipScrolling', type: exports.booleanOption },
{ name: 'skipDefaultDragBehavior', type: exports.booleanOption },
];
}
}
exports.MoveOptions = MoveOptions;
// Type
class TypeOptions extends ClickOptions {
constructor(obj, validate) {
super();
this.replace = false;
this.paste = false;
this.confidential = void 0;
this._assignFrom(obj, validate);
}
getAssignableProperties() {
return [
{ name: 'replace', type: exports.booleanOption },
{ name: 'paste', type: exports.booleanOption },
{ name: 'confidential', type: exports.booleanOption },
];
}
}
exports.TypeOptions = TypeOptions;
// DragToElement
class DragToElementOptions extends MouseOptions {
constructor(obj, validate) {
super(obj, validate);
this.destinationOffsetX = null;
this.destinationOffsetY = null;
this._assignFrom(obj, validate);
}
getAssignableProperties() {
return [
{ name: 'destinationOffsetX', type: exports.integerOption },
{ name: 'destinationOffsetY', type: exports.integerOption },
];
}
}
exports.DragToElementOptions = DragToElementOptions;
//ResizeToFitDevice
class ResizeToFitDeviceOptions extends assignable_1.default {
constructor(obj, validate) {
super();
this.portraitOrientation = false;
this._assignFrom(obj, validate);
}
getAssignableProperties() {
return [
{ name: 'portraitOrientation', type: exports.booleanOption },
];
}
}
exports.ResizeToFitDeviceOptions = ResizeToFitDeviceOptions;
//Assertion
class AssertionOptions extends assignable_1.default {
constructor(obj, validate) {
super();
this.timeout = void 0;
this.allowUnawaitedPromise = false;
this._assignFrom(obj, validate);
}
getAssignableProperties() {
return [
{ name: 'timeout', type: exports.positiveIntegerOption },
{ name: 'allowUnawaitedPromise', type: exports.booleanOption },
];
}
}
exports.AssertionOptions = AssertionOptions;
// Press
class PressOptions extends ActionOptions {
constructor(obj, validate) {
super();
this.confidential = void 0;
this._assignFrom(obj, validate);
}
getAssignableProperties() {
return [
{ name: 'confidential', type: exports.booleanOption },
];
}
}
exports.PressOptions = PressOptions;
// Cookie
class CookieOptions extends assignable_1.default {
constructor(obj, validate) {
super();
this._assignFrom(obj, validate);
}
getAssignableProperties() {
return [
{ name: 'name', type: exports.stringOption },
{ name: 'value', type: exports.stringOption },
{ name: 'domain', type: exports.stringOption },
{ name: 'path', type: exports.stringOption },
{ name: 'expires', type: exports.dateOption },
{ name: 'maxAge', type: exports.numberOption },
{ name: 'secure', type: exports.booleanOption },
{ name: 'httpOnly', type: exports.booleanOption },
{ name: 'sameSite', type: exports.stringOption },
];
}
}
exports.CookieOptions = CookieOptions;
class RequestAuthOptions extends assignable_1.default {
constructor(obj, validate) {
super();
this._assignFrom(obj, validate);
}
getAssignableProperties() {
return [
{ name: 'username', type: exports.stringOption, required: true },
{ name: 'password', type: exports.stringOption },
];
}
}
exports.RequestAuthOptions = RequestAuthOptions;
class RequestProxyOptions extends assignable_1.default {
constructor(obj, validate) {
super();
this._assignFrom(obj, validate);
}
getAssignableProperties() {
return [
{ name: 'protocol', type: exports.stringOption },
{ name: 'host', type: exports.stringOption, required: true },
{ name: 'port', type: exports.numberOption, required: true },
{ name: 'auth', type: exports.objectOption, init: initRequestAuthOption },
];
}
}
exports.RequestProxyOptions = RequestProxyOptions;
class RequestOptions extends assignable_1.default {
constructor(obj, validate) {
super();
this._assignFrom(obj, validate);
}
getAssignableProperties() {
return [
{ name: 'url', type: exports.urlOption },
{ name: 'method', type: exports.stringOption },
{ name: 'headers', type: exports.objectOption },
{ name: 'params', type: exports.urlSearchParamsOption },
{ name: 'body' },
{ name: 'timeout', type: exports.numberOption },
{ name: 'withCredentials', type: exports.booleanOption },
{ name: 'auth', type: exports.objectOption, init: initRequestAuthOption },
{ name: 'proxy', type: exports.objectOption, init: initRequestProxyOptions },
{ name: 'rawResponse', type: exports.booleanOption },
];
}
}
exports.RequestOptions = RequestOptions;
class GetProxyUrlOptions extends assignable_1.default {
constructor(obj, validate) {
super();
this._assignFrom(obj, validate);
}
getAssignableProperties() {
return [
{ name: 'credentials', type: exports.numberOption },
];
}
}
exports.GetProxyUrlOptions = GetProxyUrlOptions;
class SkipJsErrorsOptions extends assignable_1.default {
constructor(obj, validate) {
super();
this._assignFrom(obj, validate);
}
getAssignableProperties() {
return [
{ name: 'stack', type: exports.stringOrRegexOption, required: false },
{ name: 'message', type: exports.stringOrRegexOption, required: false },
{ name: 'pageUrl', type: exports.stringOrRegexOption, required: false },
];
}
}
exports.SkipJsErrorsOptions = SkipJsErrorsOptions;
class SkipJsErrorsCallbackWithOptions extends assignable_1.default {
constructor(obj, validate) {
super();
this._assignFrom(obj, validate);
}
getAssignableProperties() {
return [
{ name: 'fn', type: exports.functionOption, required: true },
{ name: 'dependencies', type: exports.objectOption, required: false },
];
}
}
exports.SkipJsErrorsCallbackWithOptions = SkipJsErrorsCallbackWithOptions;
// Initializers
function initRequestAuthOption(name, val, initOptions, validate = true) {
return new RequestAuthOptions(val, validate);
}
function initRequestProxyOptions(name, val, initOptions, validate = true) {
return new RequestProxyOptions(val, validate);
}
function initCropOptions(name, val, initOptions, validate = true) {
return new CropOptions(val, validate);
}
function initModifiersOptions(name, val, initOptions, validate = true) {
return new ModifiersOptions(val, validate);
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3B0aW9ucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy90ZXN0LXJ1bi9jb21tYW5kcy9vcHRpb25zLmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxnRUFBZ0U7QUFDaEUsZ0VBQWdFO0FBQ2hFLCtDQUErQztBQUMvQyxnRUFBZ0U7Ozs7OztBQUVoRSx3RUFBZ0Q7QUFDaEQsdURBYWlDO0FBQ2pDLGdEQWE2QjtBQUVoQixRQUFBLGFBQWEsR0FBVyxJQUFBLGtDQUFzQixFQUFDLGlDQUF3QixDQUFDLENBQUM7QUFDekUsUUFBQSxxQkFBcUIsR0FBRyxJQUFBLDBDQUE4QixFQUFDLHlDQUFnQyxDQUFDLENBQUM7QUFDekYsUUFBQSxhQUFhLEdBQVcsSUFBQSxrQ0FBc0IsRUFBQyxpQ0FBd0IsQ0FBQyxDQUFDO0FBQ3pFLFFBQUEsV0FBVyxHQUFhLElBQUEsZ0NBQW9CLEVBQUMsK0JBQXNCLENBQUMsQ0FBQztBQUNyRSxRQUFBLFlBQVksR0FBWSxJQUFBLGlDQUFxQixFQUFDLGdDQUF1QixDQUFDLENBQUM7QUFDdkUsUUFBQSxtQkFBbUIsR0FBSyxJQUFB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