UNPKG

e2ed

Version:

E2E testing framework over Playwright

47 lines (46 loc) 1.65 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.groupLogEvents = void 0; /** * Group log events to log events with children (for groupping of `TestRun` steps). * This base client function should not use scope variables (except other base functions). * @internal */ const groupLogEvents = (logEvents) => { const topLevelTypes = [ 1 /* LogEventType.Action */, 2 /* LogEventType.Assert */, 3 /* LogEventType.Entity */, 5 /* LogEventType.InternalAction */, 6 /* LogEventType.InternalAssert */, ]; const isTopLevelEvent = (logEvent) => topLevelTypes.includes(logEvent.type) || logEvent.payload?.logEventStatus === "failed" /* LogEventStatus.Failed */; const result = []; for (const logEvent of logEvents) { const last = result.at(-1); const newEvent = { children: [], ...logEvent }; if (isTopLevelEvent(logEvent)) { if (last && !isTopLevelEvent(last)) { const firstTopLevel = { children: [...result], message: 'Initialization', payload: undefined, time: last.time, type: 7 /* LogEventType.InternalCore */, }; result.length = 0; result.push(firstTopLevel); } result.push(newEvent); } else if (last && isTopLevelEvent(last)) { last.children.push(newEvent); } else { result.push(newEvent); } } return result; }; exports.groupLogEvents = groupLogEvents;