/* * GNU AGPL-3.0 License * * Copyright (c) 2021 - present core.ai . All rights reserved. * Original work Copyright (c) 2012 - 2021 Adobe Systems Incorporated. All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License * for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see https://opensource.org/licenses/AGPL-3.0. * */ /*jslint regexp: true */ define(function (require, exports, module) { window.testResults = { // this is for playwright errors: {} }; var _ = require("thirdparty/lodash"); function formatMilliseconds(ms) { const hours = Math.floor(ms / (1000 * 60 * 60)); const minutes = Math.floor((ms % (1000 * 60 * 60)) / (1000 * 60)); const seconds = Math.floor((ms % (1000 * 60)) / 1000); let result = ''; if (hours) { result = result + `${hours}-Hour `; } if (minutes) { result = result + `${minutes}-Minutes `; } result = `${result}${seconds}-Seconds`; return result.trim(); } function formatElapsedTime(ms) { const totalSeconds = Math.floor(ms / 1000); const hours = Math.floor(totalSeconds / 3600); const minutes = Math.floor((totalSeconds % 3600) / 60); const seconds = totalSeconds % 60; return `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`; } function _addPrintableContainer() { var container = $(`
Test Failed Passed All
`); $("#printableReport").append(container); } function _copyElementToClipboardWithStyle( elementID ) { const doc = document; const text = doc.getElementById( elementID ); let range; let selection; if( doc.body.createTextRange ) { range = doc.body.createTextRange(); range.moveToElement( text ); range.select(); } else if ( window.getSelection ) { selection = window.getSelection(); range = doc.createRange(); range.selectNodeContents( text ); selection.removeAllRanges(); selection.addRange( range ); } document.execCommand( 'copy' ); window.getSelection().removeAllRanges(); } var BootstrapReporterView = function (doc, reporter) { doc = doc || window.document; $(reporter) .on("runnerStart", this._handleRunnerStart.bind(this)) .on("runnerEnd", this._handleRunnerEnd.bind(this)) .on("suiteEnd", this._handleSuiteEnd.bind(this)) .on("specStart", this._handleSpecStart.bind(this)) .on("specEnd", this._handleSpecEnd.bind(this)); // build DOM immediately var container = $( '
' + '
' + '
' + '' + '
' + '
' + '
' + '
' + '
' ); $(doc.body).append(container); _addPrintableContainer(); this._topLevelSuiteMap = {}; this._topLevelSuiteMapForPrint = {}; this.$suiteList = $("#suite-list"); this.$suiteListForPrint = $("#suiteResultsList"); this.$resultsContainer = $("#results-container"); this.$resultsContainerForPrint = $("#results-container-print"); $("#copyReportButton").click(function () { _copyElementToClipboardWithStyle("suiteResultsList"); }); $("#copyReportErrorsButton").click(function () { _copyElementToClipboardWithStyle("results-container-print"); }); $("#copyFullReportButton").click(function () { _copyElementToClipboardWithStyle("fullReport"); }); }; BootstrapReporterView.prototype._createSuiteListItem = function (suiteName, specCount, reporter) { let displayName = suiteName; if(suiteName.includes(":")){ let category = suiteName.split(":"); if(reporter.knownCategories.includes(category[0])){ displayName = suiteName.replace(`${category[0]}:`, ''); } } const platformQueryParam = window._getPlatformOverride() ? `&platform=${window._getPlatformOverride()}` : ''; let hyperlink = `?spec=${encodeURIComponent(suiteName)}${platformQueryParam}`; if(reporter.selectedCategories.length){ hyperlink = `${hyperlink}&category=${reporter.selectedCategories.join(',')}`; } var $badgeAll = $('' + specCount + ""), $badgePassed = $('