@allurereport/core 3.16.1 → 3.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.d.ts +3 -1
- package/dist/config.d.ts +2 -1
- package/dist/config.js +18 -13
- package/dist/history.d.ts +5 -2
- package/dist/history.js +53 -9
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/qualityGate/qualityGate.d.ts +7 -4
- package/dist/qualityGate/qualityGate.js +21 -15
- package/dist/qualityGate/rules.d.ts +13 -8
- package/dist/qualityGate/rules.js +149 -12
- package/dist/report.js +156 -40
- package/dist/resolutions.d.ts +8 -0
- package/dist/resolutions.js +23 -2
- package/dist/store/convert.js +1 -0
- package/dist/store/store.d.ts +4 -1
- package/dist/store/store.js +118 -41
- package/dist/utils/artifacts.d.ts +14 -0
- package/dist/utils/artifacts.js +35 -0
- package/dist/utils/event.d.ts +20 -0
- package/dist/utils/event.js +21 -0
- package/dist/utils/perf.d.ts +6 -10
- package/dist/utils/perf.js +41 -28
- package/package.json +22 -22
package/dist/store/store.js
CHANGED
|
@@ -9,9 +9,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _DefaultAllureStore_instances, _DefaultAllureStore_testResults, _DefaultAllureStore_environmentDisplayNames, _DefaultAllureStore_environmentNameToId, _DefaultAllureStore_attachments, _DefaultAllureStore_attachmentContents, _DefaultAllureStore_testCases, _DefaultAllureStore_metadata, _DefaultAllureStore_history, _DefaultAllureStore_resolutionsConfig, _DefaultAllureStore_resolutionIssues, _DefaultAllureStore_testResultIdsByResolutionIssueId, _DefaultAllureStore_resolutionIssueIdByTestResultId, _DefaultAllureStore_fixtures, _DefaultAllureStore_defaultLabels, _DefaultAllureStore_environment, _DefaultAllureStore_environmentsConfig, _DefaultAllureStore_reportVariables, _DefaultAllureStore_realtimeDispatcher, _DefaultAllureStore_realtimeSubscriber, _DefaultAllureStore_allowedEnvironmentIds, _DefaultAllureStore_retrySubstore, _DefaultAllureStore_testResultIdsByEnvironmentId, _DefaultAllureStore_cachedEnvironmentEntries, _DefaultAllureStore_globalAttachmentIds, _DefaultAllureStore_globalAttachmentIdsByEnv, _DefaultAllureStore_globalErrors, _DefaultAllureStore_globalErrorsByEnv, _DefaultAllureStore_globalExitCode, _DefaultAllureStore_checkResultsById, _DefaultAllureStore_qualityGateResults, _DefaultAllureStore_historyPoints, _DefaultAllureStore_environments, _DefaultAllureStore_mergeEnvironmentIdentity, _DefaultAllureStore_environmentIdForLookup, _DefaultAllureStore_addEnvironments, _DefaultAllureStore_environmentIdByName, _DefaultAllureStore_setTestResultEnvironmentId, _DefaultAllureStore_assertAllowedEnvironmentId, _DefaultAllureStore_assertAllowedStoredEnvironment, _DefaultAllureStore_environmentIdByTestResult, _DefaultAllureStore_assignRetryHash, _DefaultAllureStore_classifyResolution, _DefaultAllureStore_associateResolutionIssue, _DefaultAllureStore_removeResolutionIssueAssociation, _DefaultAllureStore_rebuildRetrySubstore, _DefaultAllureStore_resolveGlobalEnvironmentIdentity, _DefaultAllureStore_globalAttachmentId, _DefaultAllureStore_indexGlobalError, _DefaultAllureStore_addGlobalError, _DefaultAllureStore_indexGlobalAttachment, _DefaultAllureStore_addGlobalAttachment, _DefaultAllureStore_restoreAttachmentContent, _DefaultAllureStore_relinkRestoredAttachmentSteps, _DefaultAllureStore_retriesByTr, _DefaultAllureStore_historyByTr;
|
|
12
|
+
var _DefaultAllureStore_instances, _DefaultAllureStore_testResults, _DefaultAllureStore_environmentDisplayNames, _DefaultAllureStore_environmentNameToId, _DefaultAllureStore_attachments, _DefaultAllureStore_attachmentContents, _DefaultAllureStore_testCases, _DefaultAllureStore_metadata, _DefaultAllureStore_history, _DefaultAllureStore_resolutionsConfig, _DefaultAllureStore_resolutionIssues, _DefaultAllureStore_testResultIdsByResolutionIssueId, _DefaultAllureStore_resolutionIssueIdByTestResultId, _DefaultAllureStore_fixtures, _DefaultAllureStore_defaultLabels, _DefaultAllureStore_environment, _DefaultAllureStore_environmentsConfig, _DefaultAllureStore_reportVariables, _DefaultAllureStore_realtimeDispatcher, _DefaultAllureStore_realtimeSubscriber, _DefaultAllureStore_allowedEnvironmentIds, _DefaultAllureStore_retrySubstore, _DefaultAllureStore_testResultIdsByEnvironmentId, _DefaultAllureStore_cachedEnvironmentEntries, _DefaultAllureStore_globalAttachmentIds, _DefaultAllureStore_globalAttachmentIdsByEnv, _DefaultAllureStore_globalErrors, _DefaultAllureStore_globalErrorsByEnv, _DefaultAllureStore_processGlobalAttachmentIds, _DefaultAllureStore_processGlobalAttachmentIdsByEnv, _DefaultAllureStore_processGlobalErrors, _DefaultAllureStore_processGlobalErrorsByEnv, _DefaultAllureStore_globalExitCode, _DefaultAllureStore_checkResultsById, _DefaultAllureStore_qualityGateResults, _DefaultAllureStore_metrics, _DefaultAllureStore_performance, _DefaultAllureStore_historyPoints, _DefaultAllureStore_environments, _DefaultAllureStore_mergeEnvironmentIdentity, _DefaultAllureStore_environmentIdForLookup, _DefaultAllureStore_addEnvironments, _DefaultAllureStore_environmentIdByName, _DefaultAllureStore_setTestResultEnvironmentId, _DefaultAllureStore_assertAllowedEnvironmentId, _DefaultAllureStore_assertAllowedStoredEnvironment, _DefaultAllureStore_environmentIdByTestResult, _DefaultAllureStore_assignRetryHash, _DefaultAllureStore_classifyResolution, _DefaultAllureStore_associateResolutionIssue, _DefaultAllureStore_removeResolutionIssueAssociation, _DefaultAllureStore_rebuildRetrySubstore, _DefaultAllureStore_resolveGlobalEnvironmentIdentity, _DefaultAllureStore_globalAttachmentId, _DefaultAllureStore_processGlobalAttachmentId, _DefaultAllureStore_indexGlobalError, _DefaultAllureStore_addGlobalError, _DefaultAllureStore_indexGlobalAttachment, _DefaultAllureStore_addGlobalAttachment, _DefaultAllureStore_resetProcessGlobals, _DefaultAllureStore_restoreAttachmentContent, _DefaultAllureStore_relinkRestoredAttachmentSteps, _DefaultAllureStore_retriesByTr, _DefaultAllureStore_historyByTr;
|
|
13
13
|
import { extname } from "node:path";
|
|
14
|
-
import { DEFAULT_ENVIRONMENT, DEFAULT_ENVIRONMENT_IDENTITY, compareBy, createDictionary, getHistoryIdCandidates, getWorstStatus, normalizeHistoryDataPoint, ordinal, reverse, selectHistoryTestResults, validateEnvironmentId, validateEnvironmentName, } from "@allurereport/core-api";
|
|
14
|
+
import { DEFAULT_ENVIRONMENT, DEFAULT_ENVIRONMENT_IDENTITY, compareBy, createDictionary, getHistoryIdCandidates, getWorstStatus, normalizeHistoryDataPoint, ordinal, reverse, resolveMetricSamples, selectHistoryTestResults, validateEnvironmentId, validateEnvironmentName, } from "@allurereport/core-api";
|
|
15
15
|
import { md5, } from "@allurereport/plugin-api";
|
|
16
16
|
import { getResolutionByRules, isIgnoredFailure } from "../resolutions.js";
|
|
17
17
|
import { environmentIdentityById, normalizeEnvironmentDescriptorMap, resolveEnvironmentIdentity, resolveStoredEnvironmentIdentity, validateAllowedEnvironmentId, } from "../utils/environment.js";
|
|
@@ -89,12 +89,18 @@ export class DefaultAllureStore {
|
|
|
89
89
|
_DefaultAllureStore_globalAttachmentIdsByEnv.set(this, new Map());
|
|
90
90
|
_DefaultAllureStore_globalErrors.set(this, []);
|
|
91
91
|
_DefaultAllureStore_globalErrorsByEnv.set(this, new Map());
|
|
92
|
+
_DefaultAllureStore_processGlobalAttachmentIds.set(this, []);
|
|
93
|
+
_DefaultAllureStore_processGlobalAttachmentIdsByEnv.set(this, new Map());
|
|
94
|
+
_DefaultAllureStore_processGlobalErrors.set(this, []);
|
|
95
|
+
_DefaultAllureStore_processGlobalErrorsByEnv.set(this, new Map());
|
|
92
96
|
_DefaultAllureStore_globalExitCode.set(this, void 0);
|
|
93
97
|
_DefaultAllureStore_checkResultsById.set(this, new Map());
|
|
94
98
|
_DefaultAllureStore_qualityGateResults.set(this, []);
|
|
99
|
+
_DefaultAllureStore_metrics.set(this, []);
|
|
100
|
+
_DefaultAllureStore_performance.set(this, {});
|
|
95
101
|
_DefaultAllureStore_historyPoints.set(this, []);
|
|
96
102
|
_DefaultAllureStore_environments.set(this, []);
|
|
97
|
-
const { history, resolutionsConfig, realtimeDispatcher, realtimeSubscriber, defaultLabels = {}, environment, allowedEnvironments, environmentsConfig = {}, reportVariables = {}, } = params ?? {};
|
|
103
|
+
const { history, resolutionsConfig, realtimeDispatcher, realtimeSubscriber, defaultLabels = {}, environment, allowedEnvironments, environmentsConfig = {}, reportVariables = {}, performance = {}, } = params ?? {};
|
|
98
104
|
const errors = [];
|
|
99
105
|
const { normalized: normalizedEnvironmentsConfig, identities, errors: configErrors, } = normalizeEnvironmentDescriptorMap(environmentsConfig, "environmentsConfig");
|
|
100
106
|
errors.push(...configErrors);
|
|
@@ -120,6 +126,7 @@ export class DefaultAllureStore {
|
|
|
120
126
|
__classPrivateFieldSet(this, _DefaultAllureStore_fixtures, new Map(), "f");
|
|
121
127
|
__classPrivateFieldSet(this, _DefaultAllureStore_history, history, "f");
|
|
122
128
|
__classPrivateFieldSet(this, _DefaultAllureStore_resolutionsConfig, resolutionsConfig, "f");
|
|
129
|
+
__classPrivateFieldSet(this, _DefaultAllureStore_performance, performance, "f");
|
|
123
130
|
__classPrivateFieldSet(this, _DefaultAllureStore_realtimeDispatcher, realtimeDispatcher, "f");
|
|
124
131
|
__classPrivateFieldSet(this, _DefaultAllureStore_realtimeSubscriber, realtimeSubscriber, "f");
|
|
125
132
|
__classPrivateFieldSet(this, _DefaultAllureStore_defaultLabels, defaultLabels, "f");
|
|
@@ -177,6 +184,32 @@ export class DefaultAllureStore {
|
|
|
177
184
|
};
|
|
178
185
|
__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_addGlobalAttachment).call(this, attachmentLink, attachment);
|
|
179
186
|
});
|
|
187
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_realtimeSubscriber, "f")?.onProcessGlobalError?.((error) => {
|
|
188
|
+
const resolvedEnvironment = __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_resolveGlobalEnvironmentIdentity).call(this, error.environment);
|
|
189
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_addGlobalError).call(this, {
|
|
190
|
+
...error,
|
|
191
|
+
environment: resolvedEnvironment.id,
|
|
192
|
+
}, __classPrivateFieldGet(this, _DefaultAllureStore_processGlobalErrors, "f"), __classPrivateFieldGet(this, _DefaultAllureStore_processGlobalErrorsByEnv, "f"));
|
|
193
|
+
});
|
|
194
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_realtimeSubscriber, "f")?.onProcessGlobalAttachment?.(({ attachment, fileName, environment }) => {
|
|
195
|
+
const originalFileName = attachment.getOriginalFileName();
|
|
196
|
+
const resolvedEnvironment = __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_resolveGlobalEnvironmentIdentity).call(this, environment);
|
|
197
|
+
const attachmentLink = {
|
|
198
|
+
id: __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_processGlobalAttachmentId).call(this, originalFileName, resolvedEnvironment.id),
|
|
199
|
+
name: fileName || originalFileName,
|
|
200
|
+
missed: false,
|
|
201
|
+
used: true,
|
|
202
|
+
ext: attachment.getExtension(),
|
|
203
|
+
contentType: attachment.getContentType(),
|
|
204
|
+
contentLength: attachment.getContentLength(),
|
|
205
|
+
originalFileName,
|
|
206
|
+
environment: resolvedEnvironment.id,
|
|
207
|
+
};
|
|
208
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_addGlobalAttachment).call(this, attachmentLink, attachment, __classPrivateFieldGet(this, _DefaultAllureStore_processGlobalAttachmentIds, "f"), __classPrivateFieldGet(this, _DefaultAllureStore_processGlobalAttachmentIdsByEnv, "f"));
|
|
209
|
+
});
|
|
210
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_realtimeSubscriber, "f")?.onProcessGlobalsReset?.(() => {
|
|
211
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_resetProcessGlobals).call(this);
|
|
212
|
+
});
|
|
180
213
|
}
|
|
181
214
|
async readHistory() {
|
|
182
215
|
if (!__classPrivateFieldGet(this, _DefaultAllureStore_history, "f")) {
|
|
@@ -258,13 +291,19 @@ export class DefaultAllureStore {
|
|
|
258
291
|
return __classPrivateFieldGet(this, _DefaultAllureStore_globalExitCode, "f");
|
|
259
292
|
}
|
|
260
293
|
async allGlobalErrors() {
|
|
261
|
-
return __classPrivateFieldGet(this, _DefaultAllureStore_globalErrors, "f");
|
|
294
|
+
return [...__classPrivateFieldGet(this, _DefaultAllureStore_globalErrors, "f"), ...__classPrivateFieldGet(this, _DefaultAllureStore_processGlobalErrors, "f")];
|
|
262
295
|
}
|
|
263
296
|
async allGlobalErrorsByEnv() {
|
|
264
|
-
|
|
297
|
+
const result = {};
|
|
298
|
+
for (const errorsByEnv of [__classPrivateFieldGet(this, _DefaultAllureStore_globalErrorsByEnv, "f"), __classPrivateFieldGet(this, _DefaultAllureStore_processGlobalErrorsByEnv, "f")]) {
|
|
299
|
+
errorsByEnv.forEach((errors, environmentId) => {
|
|
300
|
+
result[environmentId] = [...(result[environmentId] ?? []), ...errors];
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
return result;
|
|
265
304
|
}
|
|
266
305
|
async allGlobalAttachments() {
|
|
267
|
-
return __classPrivateFieldGet(this, _DefaultAllureStore_globalAttachmentIds, "f").reduce((acc, id) => {
|
|
306
|
+
return [...__classPrivateFieldGet(this, _DefaultAllureStore_globalAttachmentIds, "f"), ...__classPrivateFieldGet(this, _DefaultAllureStore_processGlobalAttachmentIds, "f")].reduce((acc, id) => {
|
|
268
307
|
const attachment = __classPrivateFieldGet(this, _DefaultAllureStore_attachments, "f").get(id);
|
|
269
308
|
if (!attachment) {
|
|
270
309
|
return acc;
|
|
@@ -275,21 +314,31 @@ export class DefaultAllureStore {
|
|
|
275
314
|
}
|
|
276
315
|
async allGlobalAttachmentsByEnv() {
|
|
277
316
|
const result = {};
|
|
278
|
-
__classPrivateFieldGet(this, _DefaultAllureStore_globalAttachmentIdsByEnv, "f")
|
|
279
|
-
|
|
280
|
-
const
|
|
281
|
-
|
|
317
|
+
for (const attachmentIdsByEnv of [__classPrivateFieldGet(this, _DefaultAllureStore_globalAttachmentIdsByEnv, "f"), __classPrivateFieldGet(this, _DefaultAllureStore_processGlobalAttachmentIdsByEnv, "f")]) {
|
|
318
|
+
attachmentIdsByEnv.forEach((attachmentIds, environmentId) => {
|
|
319
|
+
const attachments = attachmentIds.reduce((acc, id) => {
|
|
320
|
+
const attachment = __classPrivateFieldGet(this, _DefaultAllureStore_attachments, "f").get(id);
|
|
321
|
+
if (!attachment) {
|
|
322
|
+
return acc;
|
|
323
|
+
}
|
|
324
|
+
acc.push(attachment);
|
|
282
325
|
return acc;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
});
|
|
326
|
+
}, []);
|
|
327
|
+
result[environmentId] = [...(result[environmentId] ?? []), ...attachments];
|
|
328
|
+
});
|
|
329
|
+
}
|
|
288
330
|
return result;
|
|
289
331
|
}
|
|
290
332
|
async visitCheckResult(result) {
|
|
291
333
|
await this.addCheckResult(result);
|
|
292
334
|
}
|
|
335
|
+
async visitMetrics(metrics, context = { readerId: "api" }) {
|
|
336
|
+
const source = context.metadata?.originalFileName;
|
|
337
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_metrics, "f").push(...resolveMetricSamples(metrics.map((metric) => ({
|
|
338
|
+
...metric,
|
|
339
|
+
...(source ? { source } : {}),
|
|
340
|
+
})), __classPrivateFieldGet(this, _DefaultAllureStore_performance, "f")));
|
|
341
|
+
}
|
|
293
342
|
async visitTestResult(raw, context) {
|
|
294
343
|
const attachmentLinks = [];
|
|
295
344
|
const testResult = testResultRawToState({
|
|
@@ -377,7 +426,7 @@ export class DefaultAllureStore {
|
|
|
377
426
|
contentLength: resultFile.getContentLength(),
|
|
378
427
|
});
|
|
379
428
|
}
|
|
380
|
-
for (const globalAttachmentId of __classPrivateFieldGet(this, _DefaultAllureStore_globalAttachmentIds, "f")) {
|
|
429
|
+
for (const globalAttachmentId of [...__classPrivateFieldGet(this, _DefaultAllureStore_globalAttachmentIds, "f"), ...__classPrivateFieldGet(this, _DefaultAllureStore_processGlobalAttachmentIds, "f")]) {
|
|
381
430
|
const globalAttachment = __classPrivateFieldGet(this, _DefaultAllureStore_attachments, "f").get(globalAttachmentId);
|
|
382
431
|
if (!globalAttachment || globalAttachment.originalFileName !== originalFileName) {
|
|
383
432
|
continue;
|
|
@@ -529,6 +578,9 @@ export class DefaultAllureStore {
|
|
|
529
578
|
.map((testResultId) => __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f").get(testResultId))
|
|
530
579
|
.filter(Boolean);
|
|
531
580
|
}
|
|
581
|
+
async allMetrics() {
|
|
582
|
+
return [...__classPrivateFieldGet(this, _DefaultAllureStore_metrics, "f")];
|
|
583
|
+
}
|
|
532
584
|
async allNewTestResults(filter, history) {
|
|
533
585
|
if (!__classPrivateFieldGet(this, _DefaultAllureStore_history, "f") && !history) {
|
|
534
586
|
return [];
|
|
@@ -673,6 +725,20 @@ export class DefaultAllureStore {
|
|
|
673
725
|
}
|
|
674
726
|
async testsStatistic(filter) {
|
|
675
727
|
const statistic = { total: 0 };
|
|
728
|
+
const incrementResolution = (tr) => {
|
|
729
|
+
if (tr.resolution === "issue") {
|
|
730
|
+
statistic.resolutions ?? (statistic.resolutions = {});
|
|
731
|
+
statistic.resolutions.issues = (statistic.resolutions.issues ?? 0) + 1;
|
|
732
|
+
}
|
|
733
|
+
if (tr.resolution === "muted") {
|
|
734
|
+
statistic.resolutions ?? (statistic.resolutions = {});
|
|
735
|
+
statistic.resolutions.muted = (statistic.resolutions.muted ?? 0) + 1;
|
|
736
|
+
}
|
|
737
|
+
if (tr.resolution === "accepted") {
|
|
738
|
+
statistic.resolutions ?? (statistic.resolutions = {});
|
|
739
|
+
statistic.resolutions.accepted = (statistic.resolutions.accepted ?? 0) + 1;
|
|
740
|
+
}
|
|
741
|
+
};
|
|
676
742
|
for (const [, tr] of __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f")) {
|
|
677
743
|
if (tr.isRetry) {
|
|
678
744
|
continue;
|
|
@@ -691,6 +757,7 @@ export class DefaultAllureStore {
|
|
|
691
757
|
if (tr.transition === "new") {
|
|
692
758
|
statistic.new = (statistic.new ?? 0) + 1;
|
|
693
759
|
}
|
|
760
|
+
incrementResolution(tr);
|
|
694
761
|
if (!statistic[tr.status]) {
|
|
695
762
|
statistic[tr.status] = 0;
|
|
696
763
|
}
|
|
@@ -800,8 +867,8 @@ export class DefaultAllureStore {
|
|
|
800
867
|
fixtures: mapToObject(__classPrivateFieldGet(this, _DefaultAllureStore_fixtures, "f")),
|
|
801
868
|
environments: __classPrivateFieldGet(this, _DefaultAllureStore_environments, "f"),
|
|
802
869
|
reportVariables: __classPrivateFieldGet(this, _DefaultAllureStore_reportVariables, "f"),
|
|
803
|
-
globalAttachmentIds: __classPrivateFieldGet(this, _DefaultAllureStore_globalAttachmentIds, "f"),
|
|
804
|
-
globalErrors: __classPrivateFieldGet(this, _DefaultAllureStore_globalErrors, "f"),
|
|
870
|
+
globalAttachmentIds: [...__classPrivateFieldGet(this, _DefaultAllureStore_globalAttachmentIds, "f"), ...__classPrivateFieldGet(this, _DefaultAllureStore_processGlobalAttachmentIds, "f")],
|
|
871
|
+
globalErrors: [...__classPrivateFieldGet(this, _DefaultAllureStore_globalErrors, "f"), ...__classPrivateFieldGet(this, _DefaultAllureStore_processGlobalErrors, "f")],
|
|
805
872
|
checkResults: mapToObject(__classPrivateFieldGet(this, _DefaultAllureStore_checkResultsById, "f")),
|
|
806
873
|
indexAttachmentByTestResult: {},
|
|
807
874
|
indexTestResultByHistoryId: {},
|
|
@@ -811,6 +878,7 @@ export class DefaultAllureStore {
|
|
|
811
878
|
indexFixturesByTestResult: {},
|
|
812
879
|
resolutionIssues: mapToObject(__classPrivateFieldGet(this, _DefaultAllureStore_resolutionIssues, "f")),
|
|
813
880
|
qualityGateResults: __classPrivateFieldGet(this, _DefaultAllureStore_qualityGateResults, "f"),
|
|
881
|
+
metrics: __classPrivateFieldGet(this, _DefaultAllureStore_metrics, "f"),
|
|
814
882
|
testResultIdsIngestOrder: __classPrivateFieldGet(this, _DefaultAllureStore_retrySubstore, "f").ingestOrderIdsForDump(),
|
|
815
883
|
};
|
|
816
884
|
this.indexAttachmentByFixture.forEach((link, fxId) => {
|
|
@@ -834,7 +902,7 @@ export class DefaultAllureStore {
|
|
|
834
902
|
return storeDump;
|
|
835
903
|
}
|
|
836
904
|
async restoreState(stateDump, attachmentsContents = {}) {
|
|
837
|
-
const { testResults, attachments, testCases, fixtures, reportVariables, environments, globalAttachmentIds = [], globalErrors = [], checkResults, indexAttachmentByTestResult = {}, indexTestResultByHistoryId = {}, indexTestResultByTestCase = {}, indexTestResultByResolutionIssue = {}, indexAttachmentByFixture = {}, indexFixturesByTestResult = {}, resolutionIssues = {}, qualityGateResults = [], testResultIdsIngestOrder = [], } = stateDump;
|
|
905
|
+
const { testResults, attachments, testCases, fixtures, reportVariables, environments, globalAttachmentIds = [], globalErrors = [], checkResults, indexAttachmentByTestResult = {}, indexTestResultByHistoryId = {}, indexTestResultByTestCase = {}, indexTestResultByResolutionIssue = {}, indexAttachmentByFixture = {}, indexFixturesByTestResult = {}, resolutionIssues = {}, qualityGateResults = [], metrics = [], testResultIdsIngestOrder = [], } = stateDump;
|
|
838
906
|
const storedEnvironmentAliases = environments.flatMap((environmentValue) => {
|
|
839
907
|
if (typeof environmentValue === "string") {
|
|
840
908
|
return [{ id: environmentValue, name: environmentValue }];
|
|
@@ -1001,13 +1069,8 @@ export class DefaultAllureStore {
|
|
|
1001
1069
|
existingFixtures.push(...fxs);
|
|
1002
1070
|
});
|
|
1003
1071
|
__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_rebuildRetrySubstore).call(this);
|
|
1004
|
-
|
|
1005
|
-
__classPrivateFieldGet(this,
|
|
1006
|
-
__classPrivateFieldGet(this, _DefaultAllureStore_testResultIdsByResolutionIssueId, "f").clear();
|
|
1007
|
-
__classPrivateFieldGet(this, _DefaultAllureStore_resolutionIssueIdByTestResultId, "f").clear();
|
|
1008
|
-
for (const testResult of __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f").values()) {
|
|
1009
|
-
__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_classifyResolution).call(this, testResult);
|
|
1010
|
-
}
|
|
1072
|
+
for (const testResult of __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f").values()) {
|
|
1073
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_classifyResolution).call(this, testResult);
|
|
1011
1074
|
}
|
|
1012
1075
|
qualityGateResults.forEach((result, index) => {
|
|
1013
1076
|
__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_assertAllowedStoredEnvironment).call(this, {
|
|
@@ -1018,9 +1081,10 @@ export class DefaultAllureStore {
|
|
|
1018
1081
|
});
|
|
1019
1082
|
__classPrivateFieldGet(this, _DefaultAllureStore_qualityGateResults, "f").push(result);
|
|
1020
1083
|
});
|
|
1084
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_metrics, "f").push(...metrics);
|
|
1021
1085
|
}
|
|
1022
1086
|
}
|
|
1023
|
-
_DefaultAllureStore_testResults = new WeakMap(), _DefaultAllureStore_environmentDisplayNames = new WeakMap(), _DefaultAllureStore_environmentNameToId = new WeakMap(), _DefaultAllureStore_attachments = new WeakMap(), _DefaultAllureStore_attachmentContents = new WeakMap(), _DefaultAllureStore_testCases = new WeakMap(), _DefaultAllureStore_metadata = new WeakMap(), _DefaultAllureStore_history = new WeakMap(), _DefaultAllureStore_resolutionsConfig = new WeakMap(), _DefaultAllureStore_resolutionIssues = new WeakMap(), _DefaultAllureStore_testResultIdsByResolutionIssueId = new WeakMap(), _DefaultAllureStore_resolutionIssueIdByTestResultId = new WeakMap(), _DefaultAllureStore_fixtures = new WeakMap(), _DefaultAllureStore_defaultLabels = new WeakMap(), _DefaultAllureStore_environment = new WeakMap(), _DefaultAllureStore_environmentsConfig = new WeakMap(), _DefaultAllureStore_reportVariables = new WeakMap(), _DefaultAllureStore_realtimeDispatcher = new WeakMap(), _DefaultAllureStore_realtimeSubscriber = new WeakMap(), _DefaultAllureStore_allowedEnvironmentIds = new WeakMap(), _DefaultAllureStore_retrySubstore = new WeakMap(), _DefaultAllureStore_testResultIdsByEnvironmentId = new WeakMap(), _DefaultAllureStore_cachedEnvironmentEntries = new WeakMap(), _DefaultAllureStore_globalAttachmentIds = new WeakMap(), _DefaultAllureStore_globalAttachmentIdsByEnv = new WeakMap(), _DefaultAllureStore_globalErrors = new WeakMap(), _DefaultAllureStore_globalErrorsByEnv = new WeakMap(), _DefaultAllureStore_globalExitCode = new WeakMap(), _DefaultAllureStore_checkResultsById = new WeakMap(), _DefaultAllureStore_qualityGateResults = new WeakMap(), _DefaultAllureStore_historyPoints = new WeakMap(), _DefaultAllureStore_environments = new WeakMap(), _DefaultAllureStore_instances = new WeakSet(), _DefaultAllureStore_mergeEnvironmentIdentity = function _DefaultAllureStore_mergeEnvironmentIdentity(existingEnvironment, incomingEnvironment) {
|
|
1087
|
+
_DefaultAllureStore_testResults = new WeakMap(), _DefaultAllureStore_environmentDisplayNames = new WeakMap(), _DefaultAllureStore_environmentNameToId = new WeakMap(), _DefaultAllureStore_attachments = new WeakMap(), _DefaultAllureStore_attachmentContents = new WeakMap(), _DefaultAllureStore_testCases = new WeakMap(), _DefaultAllureStore_metadata = new WeakMap(), _DefaultAllureStore_history = new WeakMap(), _DefaultAllureStore_resolutionsConfig = new WeakMap(), _DefaultAllureStore_resolutionIssues = new WeakMap(), _DefaultAllureStore_testResultIdsByResolutionIssueId = new WeakMap(), _DefaultAllureStore_resolutionIssueIdByTestResultId = new WeakMap(), _DefaultAllureStore_fixtures = new WeakMap(), _DefaultAllureStore_defaultLabels = new WeakMap(), _DefaultAllureStore_environment = new WeakMap(), _DefaultAllureStore_environmentsConfig = new WeakMap(), _DefaultAllureStore_reportVariables = new WeakMap(), _DefaultAllureStore_realtimeDispatcher = new WeakMap(), _DefaultAllureStore_realtimeSubscriber = new WeakMap(), _DefaultAllureStore_allowedEnvironmentIds = new WeakMap(), _DefaultAllureStore_retrySubstore = new WeakMap(), _DefaultAllureStore_testResultIdsByEnvironmentId = new WeakMap(), _DefaultAllureStore_cachedEnvironmentEntries = new WeakMap(), _DefaultAllureStore_globalAttachmentIds = new WeakMap(), _DefaultAllureStore_globalAttachmentIdsByEnv = new WeakMap(), _DefaultAllureStore_globalErrors = new WeakMap(), _DefaultAllureStore_globalErrorsByEnv = new WeakMap(), _DefaultAllureStore_processGlobalAttachmentIds = new WeakMap(), _DefaultAllureStore_processGlobalAttachmentIdsByEnv = new WeakMap(), _DefaultAllureStore_processGlobalErrors = new WeakMap(), _DefaultAllureStore_processGlobalErrorsByEnv = new WeakMap(), _DefaultAllureStore_globalExitCode = new WeakMap(), _DefaultAllureStore_checkResultsById = new WeakMap(), _DefaultAllureStore_qualityGateResults = new WeakMap(), _DefaultAllureStore_metrics = new WeakMap(), _DefaultAllureStore_performance = new WeakMap(), _DefaultAllureStore_historyPoints = new WeakMap(), _DefaultAllureStore_environments = new WeakMap(), _DefaultAllureStore_instances = new WeakSet(), _DefaultAllureStore_mergeEnvironmentIdentity = function _DefaultAllureStore_mergeEnvironmentIdentity(existingEnvironment, incomingEnvironment) {
|
|
1024
1088
|
const configuredEnvironment = environmentIdentityById(__classPrivateFieldGet(this, _DefaultAllureStore_environmentsConfig, "f"), incomingEnvironment.id);
|
|
1025
1089
|
if (configuredEnvironment) {
|
|
1026
1090
|
return configuredEnvironment;
|
|
@@ -1124,13 +1188,15 @@ _DefaultAllureStore_testResults = new WeakMap(), _DefaultAllureStore_environment
|
|
|
1124
1188
|
testResult.retryHash = calculateRetryHash(testResult.testCase?.id, parametersHash, environmentId);
|
|
1125
1189
|
}, _DefaultAllureStore_classifyResolution = function _DefaultAllureStore_classifyResolution(testResult) {
|
|
1126
1190
|
const rule = getResolutionByRules(testResult, __classPrivateFieldGet(this, _DefaultAllureStore_resolutionsConfig, "f"));
|
|
1127
|
-
|
|
1128
|
-
__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_removeResolutionIssueAssociation).call(this, testResult.id);
|
|
1129
|
-
if (rule?.resolution !== "issue") {
|
|
1191
|
+
if (!rule?.resolution) {
|
|
1130
1192
|
return;
|
|
1131
1193
|
}
|
|
1132
|
-
|
|
1133
|
-
|
|
1194
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_removeResolutionIssueAssociation).call(this, testResult.id);
|
|
1195
|
+
testResult.resolution = rule.resolution;
|
|
1196
|
+
testResult.resolutionComment = rule.comment;
|
|
1197
|
+
if (rule.resolution === "issue") {
|
|
1198
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_associateResolutionIssue).call(this, { ...rule.issue, comment: rule.comment }, testResult.id);
|
|
1199
|
+
}
|
|
1134
1200
|
}, _DefaultAllureStore_associateResolutionIssue = function _DefaultAllureStore_associateResolutionIssue(resolutionIssue, testResultId) {
|
|
1135
1201
|
__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_removeResolutionIssueAssociation).call(this, testResultId);
|
|
1136
1202
|
__classPrivateFieldGet(this, _DefaultAllureStore_resolutionIssues, "f").set(resolutionIssue.id, resolutionIssue);
|
|
@@ -1177,30 +1243,41 @@ _DefaultAllureStore_testResults = new WeakMap(), _DefaultAllureStore_environment
|
|
|
1177
1243
|
return DEFAULT_ENVIRONMENT_IDENTITY;
|
|
1178
1244
|
}, _DefaultAllureStore_globalAttachmentId = function _DefaultAllureStore_globalAttachmentId(originalFileName, environmentId) {
|
|
1179
1245
|
return md5(environmentId ? `${environmentId}:${originalFileName}` : originalFileName);
|
|
1180
|
-
},
|
|
1246
|
+
}, _DefaultAllureStore_processGlobalAttachmentId = function _DefaultAllureStore_processGlobalAttachmentId(originalFileName, environmentId) {
|
|
1247
|
+
return md5(`process:${environmentId}:${originalFileName}`);
|
|
1248
|
+
}, _DefaultAllureStore_indexGlobalError = function _DefaultAllureStore_indexGlobalError(error, errorsByEnv = __classPrivateFieldGet(this, _DefaultAllureStore_globalErrorsByEnv, "f")) {
|
|
1181
1249
|
const resolvedEnvironment = __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_resolveGlobalEnvironmentIdentity).call(this, error.environment);
|
|
1182
1250
|
if (!resolvedEnvironment) {
|
|
1183
1251
|
return error;
|
|
1184
1252
|
}
|
|
1185
1253
|
error.environment = resolvedEnvironment.name;
|
|
1186
1254
|
__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_addEnvironments).call(this, [resolvedEnvironment]);
|
|
1187
|
-
index(
|
|
1255
|
+
index(errorsByEnv, resolvedEnvironment.id, error);
|
|
1188
1256
|
return error;
|
|
1189
|
-
}, _DefaultAllureStore_addGlobalError = function _DefaultAllureStore_addGlobalError(error) {
|
|
1190
|
-
|
|
1191
|
-
}, _DefaultAllureStore_indexGlobalAttachment = function _DefaultAllureStore_indexGlobalAttachment(attachmentLink) {
|
|
1257
|
+
}, _DefaultAllureStore_addGlobalError = function _DefaultAllureStore_addGlobalError(error, errors = __classPrivateFieldGet(this, _DefaultAllureStore_globalErrors, "f"), errorsByEnv = __classPrivateFieldGet(this, _DefaultAllureStore_globalErrorsByEnv, "f")) {
|
|
1258
|
+
errors.push(__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_indexGlobalError).call(this, error, errorsByEnv));
|
|
1259
|
+
}, _DefaultAllureStore_indexGlobalAttachment = function _DefaultAllureStore_indexGlobalAttachment(attachmentLink, attachmentIdsByEnv = __classPrivateFieldGet(this, _DefaultAllureStore_globalAttachmentIdsByEnv, "f")) {
|
|
1192
1260
|
const resolvedEnvironment = __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_resolveGlobalEnvironmentIdentity).call(this, attachmentLink.environment);
|
|
1193
1261
|
attachmentLink.environment = resolvedEnvironment.name;
|
|
1194
1262
|
__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_addEnvironments).call(this, [resolvedEnvironment]);
|
|
1195
|
-
index(
|
|
1263
|
+
index(attachmentIdsByEnv, resolvedEnvironment.id, attachmentLink.id);
|
|
1196
1264
|
return attachmentLink;
|
|
1197
|
-
}, _DefaultAllureStore_addGlobalAttachment = function _DefaultAllureStore_addGlobalAttachment(attachmentLink, attachment) {
|
|
1198
|
-
const indexedAttachment = __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_indexGlobalAttachment).call(this, { ...attachmentLink });
|
|
1265
|
+
}, _DefaultAllureStore_addGlobalAttachment = function _DefaultAllureStore_addGlobalAttachment(attachmentLink, attachment, attachmentIds = __classPrivateFieldGet(this, _DefaultAllureStore_globalAttachmentIds, "f"), attachmentIdsByEnv = __classPrivateFieldGet(this, _DefaultAllureStore_globalAttachmentIdsByEnv, "f")) {
|
|
1266
|
+
const indexedAttachment = __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_indexGlobalAttachment).call(this, { ...attachmentLink }, attachmentIdsByEnv);
|
|
1199
1267
|
__classPrivateFieldGet(this, _DefaultAllureStore_attachments, "f").set(indexedAttachment.id, indexedAttachment);
|
|
1200
1268
|
if (attachment) {
|
|
1201
1269
|
__classPrivateFieldGet(this, _DefaultAllureStore_attachmentContents, "f").set(indexedAttachment.id, attachment);
|
|
1202
1270
|
}
|
|
1203
|
-
|
|
1271
|
+
attachmentIds.push(indexedAttachment.id);
|
|
1272
|
+
}, _DefaultAllureStore_resetProcessGlobals = function _DefaultAllureStore_resetProcessGlobals() {
|
|
1273
|
+
for (const id of __classPrivateFieldGet(this, _DefaultAllureStore_processGlobalAttachmentIds, "f")) {
|
|
1274
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_attachments, "f").delete(id);
|
|
1275
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_attachmentContents, "f").delete(id);
|
|
1276
|
+
}
|
|
1277
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_processGlobalAttachmentIds, "f").length = 0;
|
|
1278
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_processGlobalAttachmentIdsByEnv, "f").clear();
|
|
1279
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_processGlobalErrors, "f").length = 0;
|
|
1280
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_processGlobalErrorsByEnv, "f").clear();
|
|
1204
1281
|
}, _DefaultAllureStore_restoreAttachmentContent = function _DefaultAllureStore_restoreAttachmentContent(id, content) {
|
|
1205
1282
|
const attachment = __classPrivateFieldGet(this, _DefaultAllureStore_attachments, "f").get(id);
|
|
1206
1283
|
__classPrivateFieldGet(this, _DefaultAllureStore_attachmentContents, "f").set(id, content);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const ARTIFACTS_MANIFEST_FILENAME = "artifacts.json";
|
|
2
|
+
export type ReportArtifact = {
|
|
3
|
+
name: string;
|
|
4
|
+
path: string;
|
|
5
|
+
};
|
|
6
|
+
export type ReportArtifactsManifest = ReportArtifact[];
|
|
7
|
+
export type RestoreStateDumpInput = {
|
|
8
|
+
artifactPath?: string;
|
|
9
|
+
path: string;
|
|
10
|
+
recordArtifact?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export declare const normalizeArtifactPath: (filePath: string, cwd: string) => string;
|
|
13
|
+
export declare const createReportArtifact: (filePath: string, cwd: string, name?: string) => ReportArtifact;
|
|
14
|
+
export declare const deduplicateDumpInputs: (dumps: RestoreStateDumpInput[], cwd: string) => RestoreStateDumpInput[];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { realpathSync } from "node:fs";
|
|
2
|
+
import { basename, relative, resolve, sep } from "node:path";
|
|
3
|
+
export const ARTIFACTS_MANIFEST_FILENAME = "artifacts.json";
|
|
4
|
+
const existingRealPath = (filePath) => {
|
|
5
|
+
try {
|
|
6
|
+
return realpathSync(filePath);
|
|
7
|
+
}
|
|
8
|
+
catch {
|
|
9
|
+
return filePath;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
export const normalizeArtifactPath = (filePath, cwd) => {
|
|
13
|
+
const path = relative(resolve(cwd), resolve(cwd, filePath)).split(sep).join("/");
|
|
14
|
+
return path || ".";
|
|
15
|
+
};
|
|
16
|
+
export const createReportArtifact = (filePath, cwd, name = basename(filePath)) => ({
|
|
17
|
+
name,
|
|
18
|
+
path: normalizeArtifactPath(filePath, cwd),
|
|
19
|
+
});
|
|
20
|
+
export const deduplicateDumpInputs = (dumps, cwd) => {
|
|
21
|
+
const seen = new Set();
|
|
22
|
+
return dumps.reduce((acc, dump) => {
|
|
23
|
+
const absolutePath = resolve(cwd, dump.path);
|
|
24
|
+
const dedupeKey = existingRealPath(absolutePath);
|
|
25
|
+
if (seen.has(dedupeKey)) {
|
|
26
|
+
return acc;
|
|
27
|
+
}
|
|
28
|
+
seen.add(dedupeKey);
|
|
29
|
+
acc.push({
|
|
30
|
+
...dump,
|
|
31
|
+
path: absolutePath,
|
|
32
|
+
});
|
|
33
|
+
return acc;
|
|
34
|
+
}, []);
|
|
35
|
+
};
|
package/dist/utils/event.d.ts
CHANGED
|
@@ -7,6 +7,9 @@ export declare enum RealtimeEvents {
|
|
|
7
7
|
QualityGateResults = "qualityGateResults",
|
|
8
8
|
GlobalAttachment = "globalAttachment",
|
|
9
9
|
GlobalError = "globalError",
|
|
10
|
+
ProcessGlobalAttachment = "processGlobalAttachment",
|
|
11
|
+
ProcessGlobalError = "processGlobalError",
|
|
12
|
+
ProcessGlobalsReset = "processGlobalsReset",
|
|
10
13
|
GlobalExitCode = "globalExitCode"
|
|
11
14
|
}
|
|
12
15
|
export interface AllureStoreEvents {
|
|
@@ -19,15 +22,25 @@ export interface AllureStoreEvents {
|
|
|
19
22
|
fileName?: string;
|
|
20
23
|
environment?: string;
|
|
21
24
|
}];
|
|
25
|
+
[RealtimeEvents.ProcessGlobalAttachment]: [{
|
|
26
|
+
attachment: ResultFile;
|
|
27
|
+
fileName?: string;
|
|
28
|
+
environment?: string;
|
|
29
|
+
}];
|
|
22
30
|
[RealtimeEvents.GlobalExitCode]: [ExitCode];
|
|
23
31
|
[RealtimeEvents.GlobalError]: [PluginGlobalError];
|
|
32
|
+
[RealtimeEvents.ProcessGlobalError]: [PluginGlobalError];
|
|
33
|
+
[RealtimeEvents.ProcessGlobalsReset]: [];
|
|
24
34
|
}
|
|
25
35
|
export declare class RealtimeEventsDispatcher implements RealtimeEventsDispatcherType {
|
|
26
36
|
#private;
|
|
27
37
|
constructor(emitter: EventEmitter<AllureStoreEvents>);
|
|
28
38
|
sendGlobalAttachment(attachment: ResultFile, fileName?: string, environment?: string): void;
|
|
39
|
+
sendProcessGlobalAttachment(attachment: ResultFile, fileName?: string, environment?: string): void;
|
|
29
40
|
sendGlobalExitCode(codes: ExitCode): void;
|
|
30
41
|
sendGlobalError(error: PluginGlobalError): void;
|
|
42
|
+
sendProcessGlobalError(error: PluginGlobalError): void;
|
|
43
|
+
sendProcessGlobalsReset(): void;
|
|
31
44
|
sendQualityGateResults(payload: QualityGateValidationResult[]): void;
|
|
32
45
|
sendTestResult(trId: string): void;
|
|
33
46
|
sendTestFixtureResult(tfrId: string): void;
|
|
@@ -41,8 +54,15 @@ export declare class RealtimeSubscriber implements RealtimeSubscriberType {
|
|
|
41
54
|
fileName?: string;
|
|
42
55
|
environment?: string;
|
|
43
56
|
}) => RealtimeListenerResult): () => void;
|
|
57
|
+
onProcessGlobalAttachment(listener: (payload: {
|
|
58
|
+
attachment: ResultFile;
|
|
59
|
+
fileName?: string;
|
|
60
|
+
environment?: string;
|
|
61
|
+
}) => RealtimeListenerResult): () => void;
|
|
44
62
|
onGlobalExitCode(listener: (payload: ExitCode) => RealtimeListenerResult): () => void;
|
|
45
63
|
onGlobalError(listener: (error: PluginGlobalError) => RealtimeListenerResult): () => void;
|
|
64
|
+
onProcessGlobalError(listener: (error: PluginGlobalError) => RealtimeListenerResult): () => void;
|
|
65
|
+
onProcessGlobalsReset(listener: () => RealtimeListenerResult): () => void;
|
|
46
66
|
onQualityGateResults(listener: (payload: QualityGateValidationResult[]) => RealtimeListenerResult): () => void;
|
|
47
67
|
onTestResults(listener: (trIds: string[]) => RealtimeListenerResult, options?: BatchOptions): () => void;
|
|
48
68
|
onTestFixtureResults(listener: (tfrIds: string[]) => RealtimeListenerResult, options?: BatchOptions): () => void;
|
package/dist/utils/event.js
CHANGED
|
@@ -20,6 +20,9 @@ export var RealtimeEvents;
|
|
|
20
20
|
RealtimeEvents["QualityGateResults"] = "qualityGateResults";
|
|
21
21
|
RealtimeEvents["GlobalAttachment"] = "globalAttachment";
|
|
22
22
|
RealtimeEvents["GlobalError"] = "globalError";
|
|
23
|
+
RealtimeEvents["ProcessGlobalAttachment"] = "processGlobalAttachment";
|
|
24
|
+
RealtimeEvents["ProcessGlobalError"] = "processGlobalError";
|
|
25
|
+
RealtimeEvents["ProcessGlobalsReset"] = "processGlobalsReset";
|
|
23
26
|
RealtimeEvents["GlobalExitCode"] = "globalExitCode";
|
|
24
27
|
})(RealtimeEvents || (RealtimeEvents = {}));
|
|
25
28
|
const runListener = (listener, ...args) => {
|
|
@@ -44,12 +47,21 @@ export class RealtimeEventsDispatcher {
|
|
|
44
47
|
sendGlobalAttachment(attachment, fileName, environment) {
|
|
45
48
|
__classPrivateFieldGet(this, _RealtimeEventsDispatcher_emitter, "f").emit(RealtimeEvents.GlobalAttachment, { attachment, fileName, environment });
|
|
46
49
|
}
|
|
50
|
+
sendProcessGlobalAttachment(attachment, fileName, environment) {
|
|
51
|
+
__classPrivateFieldGet(this, _RealtimeEventsDispatcher_emitter, "f").emit(RealtimeEvents.ProcessGlobalAttachment, { attachment, fileName, environment });
|
|
52
|
+
}
|
|
47
53
|
sendGlobalExitCode(codes) {
|
|
48
54
|
__classPrivateFieldGet(this, _RealtimeEventsDispatcher_emitter, "f").emit(RealtimeEvents.GlobalExitCode, codes);
|
|
49
55
|
}
|
|
50
56
|
sendGlobalError(error) {
|
|
51
57
|
__classPrivateFieldGet(this, _RealtimeEventsDispatcher_emitter, "f").emit(RealtimeEvents.GlobalError, error);
|
|
52
58
|
}
|
|
59
|
+
sendProcessGlobalError(error) {
|
|
60
|
+
__classPrivateFieldGet(this, _RealtimeEventsDispatcher_emitter, "f").emit(RealtimeEvents.ProcessGlobalError, error);
|
|
61
|
+
}
|
|
62
|
+
sendProcessGlobalsReset() {
|
|
63
|
+
__classPrivateFieldGet(this, _RealtimeEventsDispatcher_emitter, "f").emit(RealtimeEvents.ProcessGlobalsReset);
|
|
64
|
+
}
|
|
53
65
|
sendQualityGateResults(payload) {
|
|
54
66
|
__classPrivateFieldGet(this, _RealtimeEventsDispatcher_emitter, "f").emit(RealtimeEvents.QualityGateResults, payload ?? []);
|
|
55
67
|
}
|
|
@@ -74,12 +86,21 @@ export class RealtimeSubscriber {
|
|
|
74
86
|
onGlobalAttachment(listener) {
|
|
75
87
|
return __classPrivateFieldGet(this, _RealtimeSubscriber_instances, "m", _RealtimeSubscriber_onEvent).call(this, RealtimeEvents.GlobalAttachment, listener);
|
|
76
88
|
}
|
|
89
|
+
onProcessGlobalAttachment(listener) {
|
|
90
|
+
return __classPrivateFieldGet(this, _RealtimeSubscriber_instances, "m", _RealtimeSubscriber_onEvent).call(this, RealtimeEvents.ProcessGlobalAttachment, listener);
|
|
91
|
+
}
|
|
77
92
|
onGlobalExitCode(listener) {
|
|
78
93
|
return __classPrivateFieldGet(this, _RealtimeSubscriber_instances, "m", _RealtimeSubscriber_onEvent).call(this, RealtimeEvents.GlobalExitCode, listener);
|
|
79
94
|
}
|
|
80
95
|
onGlobalError(listener) {
|
|
81
96
|
return __classPrivateFieldGet(this, _RealtimeSubscriber_instances, "m", _RealtimeSubscriber_onEvent).call(this, RealtimeEvents.GlobalError, listener);
|
|
82
97
|
}
|
|
98
|
+
onProcessGlobalError(listener) {
|
|
99
|
+
return __classPrivateFieldGet(this, _RealtimeSubscriber_instances, "m", _RealtimeSubscriber_onEvent).call(this, RealtimeEvents.ProcessGlobalError, listener);
|
|
100
|
+
}
|
|
101
|
+
onProcessGlobalsReset(listener) {
|
|
102
|
+
return __classPrivateFieldGet(this, _RealtimeSubscriber_instances, "m", _RealtimeSubscriber_onEvent).call(this, RealtimeEvents.ProcessGlobalsReset, listener);
|
|
103
|
+
}
|
|
83
104
|
onQualityGateResults(listener) {
|
|
84
105
|
return __classPrivateFieldGet(this, _RealtimeSubscriber_instances, "m", _RealtimeSubscriber_onEvent).call(this, RealtimeEvents.QualityGateResults, listener);
|
|
85
106
|
}
|
package/dist/utils/perf.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import type { AllurePerformanceResult } from "@allurereport/core-api";
|
|
2
|
+
export declare const PERF_METRICS_FILE = "performance.json";
|
|
3
|
+
export declare const perfMetricsFileName: (reportUuid: string) => string;
|
|
2
4
|
export type PerfMetricSpan = {
|
|
3
5
|
name: string;
|
|
4
6
|
startTimeMs: number;
|
|
@@ -12,14 +14,8 @@ export type PerfMetricSummary = {
|
|
|
12
14
|
maxMs: number;
|
|
13
15
|
avgMs: number;
|
|
14
16
|
};
|
|
15
|
-
export type PerfMetricsPayload = {
|
|
16
|
-
version: 1;
|
|
17
|
-
generatedAt: string;
|
|
18
|
-
timeOriginMs: number;
|
|
19
|
-
spans: PerfMetricSpan[];
|
|
20
|
-
summary: PerfMetricSummary[];
|
|
21
|
-
};
|
|
22
17
|
export declare const PERF_METRIC_NAMES: {
|
|
18
|
+
readonly allureTotal: "allure.total";
|
|
23
19
|
readonly restoreStateTotal: "restoreState.total";
|
|
24
20
|
readonly restoreStateDump: "restoreState.dump";
|
|
25
21
|
readonly restoreStateAttachments: "restoreState.attachments";
|
|
@@ -37,6 +33,6 @@ export declare const PERF_METRIC_PREFIXES: {
|
|
|
37
33
|
export declare const isPerfMetricsEnabled: () => boolean;
|
|
38
34
|
export declare const startPerfSpan: (name: string) => (() => void);
|
|
39
35
|
export declare const measurePerf: <T>(name: string, fn: () => Promise<T>) => Promise<T>;
|
|
40
|
-
export declare const
|
|
41
|
-
export declare const writePerfMetrics: (output: string) => Promise<boolean>;
|
|
36
|
+
export declare const getPerfMetricsResults: () => AllurePerformanceResult[];
|
|
37
|
+
export declare const writePerfMetrics: (output: string, fileName?: string) => Promise<boolean>;
|
|
42
38
|
export declare const resetPerfMetrics: () => void;
|
package/dist/utils/perf.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
1
2
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
2
3
|
import { join } from "node:path";
|
|
3
4
|
import { performance } from "node:perf_hooks";
|
|
4
|
-
export const PERF_METRICS_FILE = "
|
|
5
|
+
export const PERF_METRICS_FILE = "performance.json";
|
|
6
|
+
export const perfMetricsFileName = (reportUuid) => `${reportUuid}-perf.json`;
|
|
5
7
|
const MARK_PREFIX = "allure:perf:";
|
|
6
8
|
const ENABLED_VALUES = new Set(["1", "true", "yes", "on"]);
|
|
7
9
|
const SPANS = [];
|
|
@@ -10,6 +12,7 @@ const MEASURES = new Set();
|
|
|
10
12
|
let sequence = 0;
|
|
11
13
|
const round = (value) => Number(value.toFixed(3));
|
|
12
14
|
export const PERF_METRIC_NAMES = {
|
|
15
|
+
allureTotal: "allure.total",
|
|
13
16
|
restoreStateTotal: "restoreState.total",
|
|
14
17
|
restoreStateDump: "restoreState.dump",
|
|
15
18
|
restoreStateAttachments: "restoreState.attachments",
|
|
@@ -24,6 +27,22 @@ export const PERF_METRIC_PREFIXES = {
|
|
|
24
27
|
generatePluginDone: "generate.plugin.done.",
|
|
25
28
|
publishUploadPlugin: "publish.upload.plugin.",
|
|
26
29
|
};
|
|
30
|
+
const getCoveredDurationSummary = () => {
|
|
31
|
+
if (SPANS.length === 0) {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
const startTimeMs = Math.min(...SPANS.map(({ startTimeMs }) => startTimeMs));
|
|
35
|
+
const endTimeMs = Math.max(...SPANS.map(({ startTimeMs, durationMs }) => startTimeMs + durationMs));
|
|
36
|
+
const durationMs = round(endTimeMs - startTimeMs);
|
|
37
|
+
return {
|
|
38
|
+
name: PERF_METRIC_NAMES.allureTotal,
|
|
39
|
+
count: 1,
|
|
40
|
+
totalMs: durationMs,
|
|
41
|
+
minMs: durationMs,
|
|
42
|
+
maxMs: durationMs,
|
|
43
|
+
avgMs: durationMs,
|
|
44
|
+
};
|
|
45
|
+
};
|
|
27
46
|
export const isPerfMetricsEnabled = () => ENABLED_VALUES.has((process.env.ALLURE_PERF_METRICS ?? "").toLowerCase());
|
|
28
47
|
export const startPerfSpan = (name) => {
|
|
29
48
|
if (!isPerfMetricsEnabled()) {
|
|
@@ -72,39 +91,33 @@ export const measurePerf = async (name, fn) => {
|
|
|
72
91
|
end();
|
|
73
92
|
}
|
|
74
93
|
};
|
|
75
|
-
export const
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
94
|
+
export const getPerfMetricsResults = () => {
|
|
95
|
+
const totalSummary = getCoveredDurationSummary();
|
|
96
|
+
const results = SPANS.map((span) => ({
|
|
97
|
+
id: randomUUID(),
|
|
98
|
+
key: span.name,
|
|
99
|
+
value: span.durationMs,
|
|
100
|
+
start: round(performance.timeOrigin + span.startTimeMs),
|
|
101
|
+
stop: round(performance.timeOrigin + span.startTimeMs + span.durationMs),
|
|
102
|
+
}));
|
|
103
|
+
if (totalSummary) {
|
|
104
|
+
results.unshift({
|
|
105
|
+
id: randomUUID(),
|
|
106
|
+
key: PERF_METRIC_NAMES.allureTotal,
|
|
107
|
+
value: totalSummary.avgMs,
|
|
108
|
+
start: round(performance.timeOrigin + Math.min(...SPANS.map(({ startTimeMs }) => startTimeMs))),
|
|
109
|
+
stop: round(performance.timeOrigin + Math.max(...SPANS.map(({ startTimeMs, durationMs }) => startTimeMs + durationMs))),
|
|
110
|
+
});
|
|
81
111
|
}
|
|
82
|
-
return
|
|
83
|
-
version: 1,
|
|
84
|
-
generatedAt: new Date().toISOString(),
|
|
85
|
-
timeOriginMs: round(performance.timeOrigin),
|
|
86
|
-
spans: [...SPANS],
|
|
87
|
-
summary: [...byName.entries()].map(([name, group]) => {
|
|
88
|
-
const durations = group.map(({ durationMs }) => durationMs);
|
|
89
|
-
const totalMs = durations.reduce((acc, duration) => acc + duration, 0);
|
|
90
|
-
return {
|
|
91
|
-
name,
|
|
92
|
-
count: group.length,
|
|
93
|
-
totalMs: round(totalMs),
|
|
94
|
-
minMs: round(Math.min(...durations)),
|
|
95
|
-
maxMs: round(Math.max(...durations)),
|
|
96
|
-
avgMs: round(totalMs / group.length),
|
|
97
|
-
};
|
|
98
|
-
}),
|
|
99
|
-
};
|
|
112
|
+
return results;
|
|
100
113
|
};
|
|
101
|
-
export const writePerfMetrics = async (output) => {
|
|
114
|
+
export const writePerfMetrics = async (output, fileName = PERF_METRICS_FILE) => {
|
|
102
115
|
if (!isPerfMetricsEnabled()) {
|
|
103
116
|
return false;
|
|
104
117
|
}
|
|
105
|
-
const
|
|
118
|
+
const results = getPerfMetricsResults();
|
|
106
119
|
await mkdir(output, { recursive: true });
|
|
107
|
-
await writeFile(join(output,
|
|
120
|
+
await writeFile(join(output, fileName), `${JSON.stringify(results, null, 2)}\n`, "utf8");
|
|
108
121
|
resetPerfMetrics();
|
|
109
122
|
return true;
|
|
110
123
|
};
|