e2ed
Version:
E2E testing framework over Playwright
51 lines (50 loc) • 2.02 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.JsonData = void 0;
const internal_1 = require("../../../constants/internal");
const client_1 = require("../client");
const filterErrors = (fullTestRuns) => {
const errors = [];
const rest = [];
for (const fullTestRun of fullTestRuns) {
if (internal_1.FAILED_TEST_RUN_STATUSES.includes(fullTestRun.status)) {
errors.push(fullTestRun);
}
else {
rest.push(fullTestRun);
}
}
return [errors, rest];
};
/**
* Renders `<script>` tags with JSON presentation of report data.
* In first tag renders the errors of the last retry, then the entire last retry,
* then all the remaining errors, tnen general client data, and then all the remaining data.
* @internal
*/
const JsonData = ({ reportData }) => {
const { apiStatistics, retries } = reportData;
const reportClientData = { apiStatistics };
const fullTestRunsNotFromLastRetry = [];
const lastRetry = retries.at(-1);
for (let index = 0; index < retries.length - 1; index += 1) {
fullTestRunsNotFromLastRetry.push(...(retries[index]?.fullTestRuns ?? []));
}
const [lastRetryErrors, lastRetryRest] = filterErrors(lastRetry?.fullTestRuns ?? []);
const [restErrors, rest] = filterErrors(fullTestRunsNotFromLastRetry);
const parts = [
lastRetryErrors,
lastRetryRest,
restErrors,
reportClientData,
rest,
].filter((part) => !('length' in part) || part.length > 0);
const scripts = parts.map((fullTestRuns) => {
const json = JSON.stringify(fullTestRuns);
const sanitizedJson = (0, client_1.sanitizeJson)(json);
return (jsx.createElement("script", { class: "e2edJsonReportData", type: "application/json" },
jsx.createElement(client_1.SafeHtml, { withoutSanitize: sanitizedJson })));
});
return jsx.createElement(client_1.List, { elements: scripts });
};
exports.JsonData = JsonData;