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

116 lines
15 KiB
JavaScript
Raw Normal View History

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const type_1 = __importDefault(require("./type"));
const actions_1 = require("./actions");
const assertion_1 = require("./assertion");
const browser_manipulation_1 = require("./browser-manipulation");
const observation_1 = require("./observation");
const lodash_1 = require("lodash");
function getCmdCtor(type) {
switch (type) {
case type_1.default.click:
return actions_1.ClickCommand;
case type_1.default.rightClick:
return actions_1.RightClickCommand;
case type_1.default.doubleClick:
return actions_1.DoubleClickCommand;
case type_1.default.hover:
return actions_1.HoverCommand;
case type_1.default.drag:
return actions_1.DragCommand;
case type_1.default.dragToElement:
return actions_1.DragToElementCommand;
case type_1.default.typeText:
return actions_1.TypeTextCommand;
case type_1.default.selectText:
return actions_1.SelectTextCommand;
case type_1.default.selectTextAreaContent:
return actions_1.SelectTextAreaContentCommand;
case type_1.default.selectEditableContent:
return actions_1.SelectEditableContentCommand;
case type_1.default.pressKey:
return actions_1.PressKeyCommand;
case type_1.default.wait:
return observation_1.WaitCommand;
case type_1.default.navigateTo:
return actions_1.NavigateToCommand;
case type_1.default.setFilesToUpload:
return actions_1.SetFilesToUploadCommand;
case type_1.default.clearUpload:
return actions_1.ClearUploadCommand;
case type_1.default.takeScreenshot:
return browser_manipulation_1.TakeScreenshotCommand;
case type_1.default.takeElementScreenshot:
return browser_manipulation_1.TakeElementScreenshotCommand;
case type_1.default.resizeWindow:
return browser_manipulation_1.ResizeWindowCommand;
case type_1.default.resizeWindowToFitDevice:
return browser_manipulation_1.ResizeWindowToFitDeviceCommand;
case type_1.default.maximizeWindow:
return browser_manipulation_1.MaximizeWindowCommand;
case type_1.default.switchToIframe:
return actions_1.SwitchToIframeCommand;
case type_1.default.switchToMainWindow:
return actions_1.SwitchToMainWindowCommand;
case type_1.default.setNativeDialogHandler:
return actions_1.SetNativeDialogHandlerCommand;
case type_1.default.setTestSpeed:
return actions_1.SetTestSpeedCommand;
case type_1.default.setPageLoadTimeout:
return actions_1.SetPageLoadTimeoutCommand;
case type_1.default.assertion:
return assertion_1.AssertionCommand;
case type_1.default.debug:
return observation_1.DebugCommand;
case type_1.default.executeExpression:
return actions_1.ExecuteExpressionCommand;
case type_1.default.executeAsyncExpression:
return actions_1.ExecuteAsyncExpressionCommand;
case type_1.default.recorder:
return actions_1.RecorderCommand;
case type_1.default.getCookies:
return actions_1.GetCookiesCommand;
case type_1.default.setCookies:
return actions_1.SetCookiesCommand;
case type_1.default.deleteCookies:
return actions_1.DeleteCookiesCommand;
case type_1.default.scroll:
return actions_1.ScrollCommand;
case type_1.default.request:
return actions_1.RequestCommand;
case type_1.default.getProxyUrl:
return actions_1.GetProxyUrlCommand;
default:
return null;
}
}
const STUDIO_PROPERTY_NAMES = {
studio: 'studio',
selector: 'selector',
note: 'note',
callsite: 'callsite',
};
function removeStudioRelatedProperties(commandObj) {
delete commandObj[STUDIO_PROPERTY_NAMES.studio];
delete commandObj[STUDIO_PROPERTY_NAMES.note];
delete commandObj[STUDIO_PROPERTY_NAMES.callsite];
const selectorValue = commandObj[STUDIO_PROPERTY_NAMES.selector];
if (!(0, lodash_1.isNil)(selectorValue))
return;
delete commandObj['selector'];
}
// Create command from object
function createCommandFromObject(obj, testRun) {
const CmdCtor = getCmdCtor(obj.type);
// NOTE: TestCafe Studio adds additional fields to the command object in RAW tests.
// They do not affect the execution of the command. Therefore, we should remove them before validation.
// We should change this mechanism in TestCafe Studio in the future to not add these properties to RAW tests.
removeStudioRelatedProperties(obj);
return CmdCtor && new CmdCtor(obj, testRun);
}
exports.default = createCommandFromObject;
module.exports = exports.default;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZnJvbS1vYmplY3QuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvdGVzdC1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