e2ed
Version:
E2E testing framework over Playwright
27 lines (26 loc) • 1.43 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.addPages = void 0;
const asserts_1 = require("../asserts");
const object_1 = require("../object");
/**
* Adds additional pages to total API statistics pages.
* @internal
*/
const addPages = (targetByPageName, sourceByPageName) => {
for (const pageName of (0, object_1.getKeys)(sourceByPageName)) {
const sourceByUrl = sourceByPageName[pageName];
(0, asserts_1.assertValueIsDefined)(sourceByUrl, 'sourceByUrl is defined', { pageName, sourceByPageName });
let targetByUrl = targetByPageName[pageName];
targetByUrl ??= (0, object_1.setReadonlyProperty)(targetByPageName, pageName, Object.create(null));
for (const url of (0, object_1.getKeys)(sourceByUrl)) {
const sourceStatistics = sourceByUrl[url];
(0, asserts_1.assertValueIsDefined)(sourceStatistics, 'sourceStatistics is defined', { pageName, url });
let targetStatistics = targetByUrl[url];
targetStatistics ??= (0, object_1.setReadonlyProperty)(targetByUrl, url, { count: 0, duration: 0 });
(0, object_1.setReadonlyProperty)(targetStatistics, 'count', targetStatistics.count + sourceStatistics.count);
(0, object_1.setReadonlyProperty)(targetStatistics, 'duration', targetStatistics.duration + sourceStatistics.duration);
}
}
};
exports.addPages = addPages;