58 lines
8.0 KiB
JavaScript
58 lines
8.0 KiB
JavaScript
|
"use strict";
|
||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||
|
};
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
exports.TestRunCtorFactory = void 0;
|
||
|
const test_run_1 = __importDefault(require("../test-run"));
|
||
|
const test_run_state_1 = __importDefault(require("./test-run-state"));
|
||
|
const type_1 = __importDefault(require("../test-run/commands/type"));
|
||
|
const service_1 = require("../test-run/commands/service");
|
||
|
const TEST_RUN_ABORTED_MESSAGE = 'The test run has been aborted.';
|
||
|
const TestRunCtorFactory = function (callbacks) {
|
||
|
const { created, done, readyToNext } = callbacks;
|
||
|
return class LiveModeTestRun extends test_run_1.default {
|
||
|
constructor(test, browserConnection, screenshotCapturer, warningLog, opts) {
|
||
|
super(test, browserConnection, screenshotCapturer, warningLog, opts);
|
||
|
created(this, test);
|
||
|
this.state = test_run_state_1.default.created;
|
||
|
this.finish = null;
|
||
|
this.stopping = false;
|
||
|
this.isInRoleInitializing = false;
|
||
|
this.stopped = false;
|
||
|
}
|
||
|
stop() {
|
||
|
this.stopped = true;
|
||
|
}
|
||
|
_useRole(...args) {
|
||
|
this.isInRoleInitializing = true;
|
||
|
return super._useRole.apply(this, args)
|
||
|
.then(res => {
|
||
|
this.isInRoleInitializing = false;
|
||
|
return res;
|
||
|
})
|
||
|
.catch(err => {
|
||
|
this.isInRoleInitializing = false;
|
||
|
throw err;
|
||
|
});
|
||
|
}
|
||
|
_internalExecuteCommand(commandToExec, callsite, forced) {
|
||
|
// NOTE: don't close the page and the session when the last test in the queue is done
|
||
|
if (commandToExec.type === type_1.default.testDone && !forced) {
|
||
|
done(this, this.stopped)
|
||
|
.then(() => this._internalExecuteCommand(commandToExec, callsite, true))
|
||
|
.then(() => readyToNext(this));
|
||
|
this._internalExecuteCommand(new service_1.UnlockPageCommand(), null);
|
||
|
return Promise.resolve();
|
||
|
}
|
||
|
if (this.stopped && !this.stopping &&
|
||
|
!this.isInRoleInitializing) {
|
||
|
this.stopping = true;
|
||
|
return Promise.reject(new Error(TEST_RUN_ABORTED_MESSAGE));
|
||
|
}
|
||
|
return super._internalExecuteCommand(commandToExec, callsite);
|
||
|
}
|
||
|
};
|
||
|
};
|
||
|
exports.TestRunCtorFactory = TestRunCtorFactory;
|
||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC1ydW4uanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbGl2ZS90ZXN0LXJ1bi5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7QUFBQSwyREFBa0M7QUFDbEMsc0VBQThDO0FBQzlDLHFFQUFxRDtBQUNyRCwwREFBaUU7QUFFakUsTUFBTSx3QkFBd0IsR0FBRyxnQ0FBZ0MsQ0FBQztBQUUzRCxNQUFNLGtCQUFrQixHQUFHLFVBQVUsU0FBUztJQUNqRCxNQUFNLEVBQUUsT0FBTyxFQUFFLElBQUksRUFBRSxXQUFXLEVBQUUsR0FBRyxTQUFTLENBQUM7SUFFakQsT0FBTyxNQUFNLGVBQWdCLFNBQVEsa0JBQU87UUFDeEMsWUFBYSxJQUFJLEVBQUUsaUJBQWlCLEVBQUUsa0JBQWtCLEVBQUUsVUFBVSxFQUFFLElBQUk7WUFDdEUsS0FBSyxDQUFDLElBQUksRUFBRSxpQkFBaUIsRUFBRSxrQkFBa0IsRUFBRSxVQUFVLEVBQUUsSUFBSSxDQUFDLENBQUM7WUFFckUsT0FBTyxDQUFDLElBQUksRUFBRSxJQUFJLENBQUMsQ0FBQztZQUVwQixJQUFJLENBQUMsS0FBSyxHQUFrQix3QkFBYyxDQUFDLE9BQU8sQ0FBQztZQUNuRCxJQUFJLENBQUMsTUFBTSxHQUFpQixJQUFJLENBQUM7WUFDakMsSUFBSSxDQUFDLFFBQVEsR0FBZSxLQ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kgPSBmdW5jdGlvbiAoY2FsbGJhY2tzKSB7XG4gICAgY29uc3QgeyBjcmVhdGVkLCBkb25lLCByZWFkeVRvTmV4dCB9ID0gY2FsbGJhY2tzO1xuXG4gICAgcmV0dXJuIGNsYXNzIExpdmVNb2RlVGVzdFJ1biBleHRlbmRzIFRlc3RSdW4ge1xuICAgICAgICBjb25zdHJ1Y3RvciAodGVzdCwgYnJvd3NlckNvbm5lY3Rpb24sIHNjcmVlbnNob3RDYXB0dXJlciwgd2FybmluZ0xvZywgb3B0cykge1xuICAgICAgICAgICAgc3VwZXIodGVzdCwgYnJvd3NlckNvbm5lY3Rpb24sIHNjcmVlbnNob3RDYXB0dXJlciwgd2FybmluZ0xvZywgb3B0cyk7XG5cbiAgICAgICAgICAgIGNyZWF0ZWQodGhpcywgdGVzdCk7XG5cbiAgICAgICAgICAgIHRoaXMuc3RhdGUgICAgICAgICAgICAgICAgPSBURVNUX1JVTl9TVEFURS5jcmVhdGVkO1xuICAgICAgICAgICAgdGhpcy5maW5pc2ggICAgICAgICAgICAgICA9IG51bGw7XG4gICAgICAgICAgICB0aGlzLnN0b3BwaW5nICAgICAgICAgICAgID0gZmFsc2U7XG4gICAgICAgICAgICB0aGlzLmlzSW5Sb2xlSW5pdGlhbGl6aW5nID0gZmFsc2U7XG4gICAgICAgICAgICB0aGlzLnN0b3BwZWQgICAgICAgICAgICAgID0gZmFsc2U7XG4gICAgICAgIH1cblxuICAgICAgICBzdG9wICgpIHtcbiAgICAgICAgICAgIHRoaXMuc3RvcHBlZCA9IHRydWU7XG4gICAgICAgIH1cblxuICAgICAgICBfdXNlUm9sZSAoLi4uYXJncykge1xuICAgICAgICAgICAgdGhpcy5pc0luUm9sZUluaXRpYWxpemluZyA9IHRydWU7XG5cbiAgICAgICAgICAgIHJldHVybiBzdXBlci5fdXNlUm9sZS5hcHBseSh0aGlzLCBhcmdzKVxuICAgICAgICAgICAgICAgIC50aGVuKHJlcyA9P
|