Innovenergy_trunk/frontend/node_modules/testcafe/lib/runner/task/index.js

148 lines
21 KiB
JavaScript

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
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 moment_1 = __importDefault(require("moment"));
const async_event_emitter_1 = __importDefault(require("../../utils/async-event-emitter"));
const browser_job_1 = __importDefault(require("../browser-job"));
const screenshots_1 = __importDefault(require("../../screenshots"));
const warning_log_1 = __importDefault(require("../../notifications/warning-log"));
const fixture_hook_controller_1 = __importDefault(require("../fixture-hook-controller"));
const clientScriptsRouting = __importStar(require("../../custom-client-scripts/routing"));
const videos_1 = __importDefault(require("../../video-recorder/videos"));
const phase_1 = __importDefault(require("./phase"));
class Task extends async_event_emitter_1.default {
constructor({ tests, browserConnectionGroups, proxy, opts, runnerWarningLog, compilerService, messageBus, }) {
super({ captureRejections: true });
this._timeStamp = (0, moment_1.default)();
this._phase = phase_1.default.initialized;
this.browserConnectionGroups = browserConnectionGroups;
this.tests = tests;
this.opts = opts;
this._proxy = proxy;
this.warningLog = new warning_log_1.default(null, warning_log_1.default.createAddWarningCallback(messageBus));
this._compilerService = compilerService;
this._messageBus = messageBus;
this.warningLog.copyFrom(runnerWarningLog);
const { path, pathPattern, fullPage, thumbnails, autoTakeOnFails } = this.opts.screenshots;
this.screenshots = new screenshots_1.default({
enabled: !this.opts.disableScreenshots,
path,
pathPattern,
fullPage,
thumbnails,
messageBus,
autoTakeOnFails,
});
this.fixtureHookController = new fixture_hook_controller_1.default(tests, browserConnectionGroups.length);
this._pendingBrowserJobs = this._createBrowserJobs(proxy, this.opts);
this._clientScriptRoutes = clientScriptsRouting.register(proxy, tests, !!this.opts.experimentalProxyless);
this.testStructure = this._prepareTestStructure(tests);
if (this.opts.videoPath) {
const { videoPath, videoOptions, videoEncodingOptions } = this.opts;
this.videos = new videos_1.default(this._pendingBrowserJobs, { videoPath, videoOptions, videoEncodingOptions }, this.warningLog, this._timeStamp);
}
}
_assignBrowserJobEventHandlers(job) {
job.on('test-run-done', async (testRun) => {
await this._messageBus.emit('test-run-done', testRun);
if (this.opts.stopOnFirstFail && testRun.errs.length) {
this.abort();
await this._messageBus.emit('done');
}
});
job.once('start', async (startTime) => {
if (this._phase !== phase_1.default.started) {
this._phase = phase_1.default.started;
this.startTime = startTime;
await this._messageBus.emit('start', this);
}
});
job.once('done', async () => {
await this.emit('browser-job-done', job);
(0, lodash_1.pull)(this._pendingBrowserJobs, job);
if (!this._pendingBrowserJobs.length) {
this._phase = phase_1.default.done;
await this._messageBus.emit('done');
}
});
job.on('test-action-done', async (args) => {
if (this._phase === phase_1.default.done)
return;
await this._messageBus.emit('test-action-done', args);
});
}
_prepareTestStructure(tests) {
const groups = (0, lodash_1.groupBy)(tests, 'fixture.id');
return Object.keys(groups).map(fixtureId => {
const testsByGroup = groups[fixtureId];
const fixture = testsByGroup[0].fixture;
return {
fixture: {
id: fixture.id,
name: fixture.name,
tests: testsByGroup.map(test => {
return {
id: test.id,
name: test.name,
skip: test.skip,
};
}),
},
};
});
}
_createBrowserJobs(proxy, opts) {
return this.browserConnectionGroups.map(browserConnectionGroup => {
const job = new browser_job_1.default({
tests: this.tests,
browserConnections: browserConnectionGroup,
screenshots: this.screenshots,
warningLog: this.warningLog,
fixtureHookController: this.fixtureHookController,
compilerService: this._compilerService,
messageBus: this._messageBus,
proxy,
opts,
});
this._assignBrowserJobEventHandlers(job);
browserConnectionGroup.map(bc => bc.addJob(job));
return job;
});
}
unRegisterClientScriptRouting() {
clientScriptsRouting.unRegister(this._proxy, this._clientScriptRoutes);
}
// API
abort() {
this._pendingBrowserJobs.forEach(job => job.abort());
}
}
exports.default = Task;
module.exports = exports.default;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvcnVubmVyL3Rhc2svaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztBQUFBLG1DQUFpRDtBQUNqRCxvREFBNEI7QUFDNUIsMEZBQWdFO0FBQ2hFLGlFQUF3QztBQUN4QyxvRUFBNEM7QUFDNUMsa0ZBQXlEO0FBQ3pELHlGQUErRDtBQUMvRCwwRkFBNEU7QUFDNUUseUVBQWlEO0FBYWpELG9EQUFnQztBQUtoQyxNQUFxQixJQUFLLFNBQVEsNkJBQWlCO0lBa0IvQyxZQUFvQixFQUNoQixLQUFLLEVBQ0wsdUJBQXVCLEVBQ3ZCLEtBQUssRUFDTCxJQUFJLEVBQ0osZ0JBQWdCLEVBQ2hCLGVBQWUsRUFDZixVQUFVLEdBQ0g7UUFDUCxLQUFLLENBQUMsRUFBRSxpQkFBaUIsRUFBRSxJQUFJLEVBQUUsQ0FBQyxDQUFDO1FBRW5DLElBQUksQ0FBQyxVQUFVLEdBQWdCLElBQUEsZ0JBQU0sR0FBRSxDQUFDO1FBQ3hDLElBQUksQ0FBQyxNQUFNLEdBQ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x5IF9jbGllbnRTY3JpcHRSb3V0ZXM6IHN0cmluZ1tdO1xuICAgIHB1YmxpYyByZWFkb25seSB0ZXN0U3RydWN0dXJlOiBSZXBvcnRlZFRlc3RTdHJ1Y3R1cmVJdGVtW107XG4gICAgcHVibGljIHJlYWRvbmx5IHZpZGVvcz86IFZpZGVvcztcbiAgICBwcml2YXRlIHJlYWRvbmx5IF9jb21waWxlclNlcnZpY2U/OiBDb21waWxlclNlcnZpY2U7XG4gICAgcHJpdmF0ZSByZWFkb25seSBfbWVzc2FnZUJ1czogTWVzc2FnZUJ1cztcbiAgICBwdWJsaWMgc3RhcnRUaW1lPzogRGF0ZTtcblxuICAgIHB1YmxpYyBjb25zdHJ1Y3RvciAoe1xuICAgICAgICB0ZXN0cyxcbiAgICAgICAgYnJvd3NlckNvbm5lY3Rpb25Hcm91cHMsXG4gICAgICAgIHByb3h5LFxuICAgICAgICBvcHRzLFxuICAgICAgICBydW5uZXJXYXJuaW5nTG9nLFxuICAgICAgICBjb21waWxlclNlcnZpY2UsXG4gICAgICAgIG1lc3NhZ2VCdXMsXG4gICAgfTogVGFza0luaXQpIHtcbiAgICAgICAgc3VwZXIoeyBjYXB0dXJlUmVqZWN0aW9uczogdHJ1ZSB9KTtcblxuICAgICAgICB0aGlzLl90aW1lU3RhbXAgICAgICAgICAgICAgID0gbW9tZW50KCk7XG4gICAgICAgIHRoaXMuX3BoYXNlICAgICAgICAgICAgICAgICAgPSBUYXNrUGhhc2UuaW5pdGlhbGl6ZWQ7XG4gICAgICAgIHRoaXMuYnJvd3NlckNvbm5lY3Rpb25Hcm91cHMgPSBicm93c2VyQ29ubmVjdGlvbkdyb3VwcztcbiAgICAgICAgdGhpcy50ZXN0cyAgICAgICAgICAgICAgICAgICA9IHRlc3RzO1xuICAgICAgICB0aGlzLm9wdHMgICAgICAgICAgICAgICAgICAgID0gb3B0cztcbiAgICAgICAgdGhpcy5fcHJveHkgICAgICAgICAgICAgICAgICA9IHByb3h5O1xuICAgICAg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zZS5kb25lKVxuICAgICAgICAgICAgICAgIHJldHVybjtcblxuICAgICAgICAgICAgYXdhaXQgdGhpcy5fbWVzc2FnZUJ1cy5lbWl0KCd0ZXN0LWFjdGlvbi1kb25lJywgYXJncyk7XG4gICAgICAgIH0pO1xuXG4gICAgfVxuXG4gICAgcHJpdmF0ZSBfcHJlcGFyZVRlc3RTdHJ1Y3R1cmUgKHRlc3RzOiBUZXN0W10pOiBSZXBvcnRlZFRlc3RTdHJ1Y3R1cmVJdGVtW10ge1xuICAgICAgICBjb25zdCBncm91cHMgPSBncm91cEJ5KHRlc3RzLCAnZml4dHVyZS5pZCcpO1xuXG4gICAgICAgIHJldHVybiBPYmplY3Qua2V5cyhncm91cHMpLm1hcChmaXh0dXJlSWQgPT4ge1xuICAgICAgICAgICAgY29uc3QgdGVzdHNCeUdyb3VwID0gZ3JvdXBzW2ZpeHR1cmVJZF07XG4gICAgICAgICAgICBjb25zdCBmaXh0dXJlICAgICAgPSB0ZXN0c0J5R3JvdXBbMF0uZml4dHVyZSBhcyBGaXh0dXJlO1xuXG4gICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgIGZpeHR1cmU6IHtcbiAgICAgICAgICAgICAgICAgICAgaWQ6ICAgIGZpeHR1cmUuaWQsXG4gICAgICAgICAgICAgICAgICAgIG5hbWU6ICBmaXh0dXJlLm5hbWUgYXMgc3RyaW5nLFxuICAgICAgICAgICAgICAgICAgICB0ZXN0czogdGVzdHNCeUdyb3VwLm1hcCh0ZXN0ID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWQ6ICAgdGVzdC5pZCxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYW1lOiB0ZXN0Lm5hbWUgYXMgc3RyaW5nLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNraXA6IHRlc3Quc2tpcCxcbiAgICAgICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgICAgIH0pLFxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICB9O1xuICAgICAgICB9KTtcbiAgICB9XG5cbiAgICBwcml2YXRlIF9jcmVhdGVCcm93c2VySm9icyAocHJveHk6IFByb3h5LCBvcHRzOiBEaWN0aW9uYXJ5PE9wdGlvblZhbHVlPik6IEJyb3dzZXJKb2JbXSB7XG4gICAgICAgIHJldHVybiB0aGlzLmJyb3dzZXJDb25uZWN0aW9uR3JvdXBzLm1hcChicm93c2VyQ29ubmVjdGlvbkdyb3VwID0+IHtcbiAgICAgICAgICAgIGNvbnN0IGpvYiA9IG5ldyBCcm93c2VySm9iKHtcbiAgICAgICAgICAgICAgICB0ZXN0czogICAgICAgICAgICAgICAgIHRoaXMudGVzdHMsXG4gICAgICAgICAgICAgICAgYnJvd3NlckNvbm5lY3Rpb25zOiAgICBicm93c2VyQ29ubmVjdGlvbkdyb3VwLFxuICAgICAgICAgICAgICAgIHNjcmVlbnNob3RzOiAgICAgICAgICAgdGhpcy5zY3JlZW5zaG90cyxcbiAgICAgICAgICAgICAgICB3YXJuaW5nTG9nOiAgICAgICAgICAgIHRoaXMud2FybmluZ0xvZyxcbiAgICAgICAgICAgICAgICBmaXh0dXJlSG9va0NvbnRyb2xsZXI6IHRoaXMuZml4dHVyZUhvb2tDb250cm9sbGVyLFxuICAgICAgICAgICAgICAgIGNvbXBpbGVyU2VydmljZTogICAgICAgdGhpcy5fY29tcGlsZXJTZXJ2aWNlLFxuICAgICAgICAgICAgICAgIG1lc3NhZ2VCdXM6ICAgICAgICAgICAgdGhpcy5fbWVzc2FnZUJ1cyxcbiAgICAgICAgICAgICAgICBwcm94eSxcbiAgICAgICAgICAgICAgICBvcHRzLFxuICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgICAgIHRoaXMuX2Fzc2lnbkJyb3dzZXJKb2JFdmVudEhhbmRsZXJzKGpvYik7XG4gICAgICAgICAgICBicm93c2VyQ29ubmVjdGlvbkdyb3VwLm1hcChiYyA9PiBiYy5hZGRKb2Ioam9iKSk7XG5cbiAgICAgICAgICAgIHJldHVybiBqb2I7XG4gICAgICAgIH0pO1xuICAgIH1cblxuICAgIHB1YmxpYyB1blJlZ2lzdGVyQ2xpZW50U2NyaXB0Um91dGluZyAoKTogdm9pZCB7XG4gICAgICAgIGNsaWVudFNjcmlwdHNSb3V0aW5nLnVuUmVnaXN0ZXIodGhpcy5fcHJveHksIHRoaXMuX2NsaWVudFNjcmlwdFJvdXRlcyk7XG4gICAgfVxuXG4gICAgLy8gQVBJXG4gICAgcHVibGljIGFib3J0ICgpOiB2b2lkIHtcbiAgICAgICAgdGhpcy5fcGVuZGluZ0Jyb3dzZXJKb2JzLmZvckVhY2goam9iID0+IGpvYi5hYm9ydCgpKTtcbiAgICB9XG59XG4iXX0=