156 lines
26 KiB
JavaScript
156 lines
26 KiB
JavaScript
"use strict";
|
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const lodash_1 = require("lodash");
|
|
const test_run_tracker_1 = __importDefault(require("../../api/test-run-tracker"));
|
|
const test_controller_1 = __importDefault(require("../../api/test-controller"));
|
|
const observed_callsites_storage_1 = __importDefault(require("../../test-run/observed-callsites-storage"));
|
|
const warning_log_1 = __importDefault(require("../../notifications/warning-log"));
|
|
const type_1 = __importDefault(require("../../test-run/commands/type"));
|
|
const base_1 = require("../../test-run/commands/base");
|
|
const testcafe_hammerhead_1 = require("testcafe-hammerhead");
|
|
const re_executable_promise_1 = __importDefault(require("../../utils/re-executable-promise"));
|
|
const async_event_emitter_1 = __importDefault(require("../../utils/async-event-emitter"));
|
|
const marker_symbol_1 = __importDefault(require("../../test-run/marker-symbol"));
|
|
const constants_1 = require("../../test-run/execute-js-expression/constants");
|
|
const marker_1 = require("../serialization/replicator/transforms/function-marker-transform/marker");
|
|
const get_fn_1 = __importDefault(require("../../assertions/get-fn"));
|
|
const thennable_1 = require("../../utils/thennable");
|
|
const marker_2 = require("../serialization/replicator/transforms/promise-marker-transform/marker");
|
|
const observation_1 = require("../../test-run/commands/observation");
|
|
class TestRunProxy extends async_event_emitter_1.default {
|
|
constructor({ dispatcher, id, test, options, browser, activeWindowId, messageBus }) {
|
|
super();
|
|
this.debugging = false;
|
|
this[marker_symbol_1.default] = true;
|
|
this.dispatcher = dispatcher;
|
|
this.id = id;
|
|
this.test = test;
|
|
this.ctx = Object.create(null);
|
|
this.fixtureCtx = Object.create(null);
|
|
this._options = options;
|
|
this.browser = browser;
|
|
this.assertionCommands = new Map();
|
|
this.switchToWindowByPredicateCommands = new Map();
|
|
this.asyncJsExpressionCallsites = new Map();
|
|
this.controller = new test_controller_1.default(this);
|
|
this.observedCallsites = new observed_callsites_storage_1.default();
|
|
this.warningLog = new warning_log_1.default(null, warning_log_1.default.createAddWarningCallback(messageBus));
|
|
this.disableMultipleWindows = options.disableMultipleWindows;
|
|
this.activeWindowId = activeWindowId;
|
|
test_run_tracker_1.default.addActiveTestRun(this);
|
|
this._initializeRequestHooks();
|
|
}
|
|
_initializeRequestHooks() {
|
|
this.test.requestHooks.forEach(this._attachWarningLog, this);
|
|
}
|
|
_attachWarningLog(hook) {
|
|
hook._warningLog = this.warningLog;
|
|
}
|
|
_detachWarningLog(hook) {
|
|
hook._warningLog = null;
|
|
}
|
|
_storeAssertionCommand(command) {
|
|
command.id = (0, testcafe_hammerhead_1.generateUniqueId)();
|
|
this.assertionCommands.set(command.id, command);
|
|
}
|
|
_storeSwitchToWindowByPredicateCommand(command) {
|
|
command.id = (0, testcafe_hammerhead_1.generateUniqueId)();
|
|
this.switchToWindowByPredicateCommands.set(command.id, command);
|
|
}
|
|
_handleAssertionCommand(command) {
|
|
if ((0, lodash_1.isFunction)(command.actual)) {
|
|
command.originActual = command.actual;
|
|
command.actual = new marker_1.FunctionMarker();
|
|
this._storeAssertionCommand(command);
|
|
}
|
|
else if (command.actual instanceof re_executable_promise_1.default)
|
|
this._storeAssertionCommand(command);
|
|
else if ((0, thennable_1.isThennable)(command.actual)) {
|
|
command.originActual = command.actual;
|
|
command.actual = new marker_2.PromiseMarker();
|
|
this._storeAssertionCommand(command);
|
|
}
|
|
}
|
|
_handleExecuteClientFunctionCommandBase(command) {
|
|
command.esmRuntime = this.test.esmRuntime;
|
|
}
|
|
_storeActionCallsitesForExecutedAsyncJsExpression(callsite) {
|
|
// @ts-ignore
|
|
if ((callsite === null || callsite === void 0 ? void 0 : callsite.filename) !== constants_1.ERROR_FILENAME)
|
|
return;
|
|
const id = (0, testcafe_hammerhead_1.generateUniqueId)();
|
|
// @ts-ignore
|
|
callsite.id = id;
|
|
this.asyncJsExpressionCallsites.set(id, callsite);
|
|
}
|
|
async executeCommand(command, callsite) {
|
|
if (command instanceof base_1.ActionCommandBase && callsite)
|
|
this._storeActionCallsitesForExecutedAsyncJsExpression(callsite);
|
|
if (command.type === type_1.default.assertion)
|
|
this._handleAssertionCommand(command);
|
|
else if (command.type === type_1.default.useRole)
|
|
this.dispatcher.onRoleAppeared(command.role);
|
|
else if (command.type === type_1.default.switchToWindowByPredicate)
|
|
this._storeSwitchToWindowByPredicateCommand(command);
|
|
else if (command instanceof observation_1.ExecuteClientFunctionCommandBase)
|
|
this._handleExecuteClientFunctionCommandBase(command);
|
|
return this.dispatcher.executeCommand({
|
|
command,
|
|
callsite,
|
|
id: this.id,
|
|
});
|
|
}
|
|
executeCommandSync(command, callsite) {
|
|
if (command.type === type_1.default.assertion)
|
|
this._handleAssertionCommand(command);
|
|
else if (command.type === type_1.default.useRole)
|
|
this.dispatcher.onRoleAppeared(command.role);
|
|
return this.dispatcher.executeCommandSync({
|
|
command,
|
|
callsite,
|
|
id: this.id,
|
|
});
|
|
}
|
|
async addRequestHook(hook) {
|
|
if (this.test.requestHooks.includes(hook))
|
|
return;
|
|
this.test.requestHooks.push(hook);
|
|
this._attachWarningLog(hook);
|
|
await this.dispatcher.addRequestEventListeners({
|
|
hookId: hook.id,
|
|
hookClassName: hook._className,
|
|
rules: hook._requestFilterRules,
|
|
});
|
|
}
|
|
async removeRequestHook(hook) {
|
|
if (!this.test.requestHooks.includes(hook))
|
|
return;
|
|
(0, lodash_1.pull)(this.test.requestHooks, hook);
|
|
this._detachWarningLog(hook);
|
|
await this.dispatcher.removeRequestEventListeners({ rules: hook._requestFilterRules });
|
|
}
|
|
async getAssertionActualValue(commandId) {
|
|
const command = this.assertionCommands.get(commandId);
|
|
return command.actual._reExecute();
|
|
}
|
|
async executeAssertionFn(commandId) {
|
|
const command = this.assertionCommands.get(commandId);
|
|
command.actual = command.originActual;
|
|
const fn = (0, get_fn_1.default)(command);
|
|
return await fn();
|
|
}
|
|
restoreOriginCallsiteForError(err) {
|
|
err.errCallsite = this.asyncJsExpressionCallsites.get(err.errCallsite.id);
|
|
this.asyncJsExpressionCallsites.clear();
|
|
}
|
|
checkWindow(commandId, { title, url }) {
|
|
const command = this.switchToWindowByPredicateCommands.get(commandId);
|
|
return command.checkWindow({ title, url });
|
|
}
|
|
}
|
|
exports.default = TestRunProxy;
|
|
module.exports = exports.default;
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC1ydW4tcHJveHkuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvc2VydmljZXMvY29tcGlsZXIvdGVzdC1ydW4tcHJveHkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFBQSxtQ0FBMEM7QUFDMUMsa0ZBQXdEO0FBRXhELGdGQUF1RDtBQUN2RCwyR0FBaUY7QUFDakYsa0ZBQXlEO0FBR3pELHdFQUF3RDtBQUN4RCx1REFBOEU7QUFJOUUsNkRBQXVEO0FBU3ZELDhGQUFvRTtBQUNwRSwwRkFBZ0U7QUFDaEUsaUZBQXlEO0FBQ3pELDhFQUFnRjtBQUVoRixvR0FBeUc7QUFDekcscUVBQTRDO0FBQzVDLHFEQUFvRDtBQUNwRCxtR0FBdUc7QUFDdkcscUVBQXVGO0FBRXZGLE1BQU0sWUFBYSxTQUFRLDZCQUFpQjtJQW1CeEMsWUFBb0IsRUFBRSxVQUFVLEVBQUUsRUFBRSxFQUFFLElBQUksRUFBRSxPQUFPLEVBQUUsT0FBTyxFQUFFLGNBQWMsRUFBRSxVQUFVLEVBQW9CO1FBQ3hHLEtBQUssRUFBRSxDQUFDO1FBWkwsY0FBUyxHQUFHLEtBQUssQ0FBQztRQWNyQixJQUFJLENBQUMsdUJBQWEsQ0FBQyxHQUFzQixJQUFJLENBQUM7UUFDOUMsSUFBSSxDQUFDLFVBQVUsR0FBMEIsVUFBVSxDQUFDO1FBQ3BELElBQUksQ0FBQyxFQUFFLEdBQWtDLEVBQUUsQ0FBQztRQUM1Qyx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LCBTd2l0Y2hUb1dpbmRvd0J5UHJlZGljYXRlQ29tbWFuZD47XG4gICAgcHJpdmF0ZSByZWFkb25seSBhc3luY0pzRXhwcmVzc2lvbkNhbGxzaXRlczogTWFwPHN0cmluZywgQ2FsbHNpdGVSZWNvcmQ+O1xuICAgIHB1YmxpYyByZWFkb25seSBicm93c2VyOiBCcm93c2VyO1xuICAgIHB1YmxpYyByZWFkb25seSBkaXNhYmxlTXVsdGlwbGVXaW5kb3dzOiBib29sZWFuO1xuICAgIHB1YmxpYyBhY3RpdmVXaW5kb3dJZDogbnVsbCB8IHN0cmluZztcblxuICAgIHB1YmxpYyBjb25zdHJ1Y3RvciAoeyBkaXNwYXRjaGVyLCBpZCwgdGVzdCwgb3B0aW9ucywgYnJvd3NlciwgYWN0aXZlV2luZG93SWQsIG1lc3NhZ2VCdXMgfTogVGVzdFJ1blByb3h5SW5pdCkge1xuICAgICAgICBzdXBlcigpO1xuXG4gICAgICAgIHRoaXNbdGVzdFJ1bk1hcmtlcl0gICAgICAgICAgICAgICAgICAgID0gdHJ1ZTtcbiAgICAgICAgdGhpcy5kaXNwYXRjaGVyICAgICAgICAgICAgICAgICAgICAgICAgPSBkaXNwYXRjaGVyO1xuICAgICAgICB0aGlzLmlkICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA9IGlkO1xuICAgICAgICB0aGlzLnRlc3QgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA9IHRlc3Q7XG4gICAgICAgIHRoaXMuY3R4ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgID0gT2JqZWN0LmNyZWF0ZShudWxsKTtcbiAgICAgICAgdGhpcy5maXh0dXJlQ3R4ICAgICAgICAgICAgICAgICAgICAgICAgPSBPYmplY3QuY3JlYXRlKG51bGwpO1xuICAgICAgICB0aGlzLl9vcHRpb25zICAgICAgICAgICAgICAgICAgICAgICAgICA9IG9wdGlvbnM7XG4gICAgICAgIHRoaXMuYnJvd3NlciAgICAgICAgICAgICAgICAgICAg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