@allurereport/core 3.17.0 → 3.19.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.
@@ -9,16 +9,16 @@ 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_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_indexGlobalError, _DefaultAllureStore_addGlobalError, _DefaultAllureStore_indexGlobalAttachment, _DefaultAllureStore_addGlobalAttachment, _DefaultAllureStore_restoreAttachmentContent, _DefaultAllureStore_relinkRestoredAttachmentSteps, _DefaultAllureStore_retriesByTr, _DefaultAllureStore_historyByTr;
12
+ var _DefaultAllureStore_instances, _DefaultAllureStore_testResults, _DefaultAllureStore_attachments, _DefaultAllureStore_attachmentContents, _DefaultAllureStore_testCases, _DefaultAllureStore_metadata, _DefaultAllureStore_history, _DefaultAllureStore_detectFlaky, _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_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_historyLookup, _DefaultAllureStore_environments, _DefaultAllureStore_mergeEnvironmentIdentity, _DefaultAllureStore_environmentIdForLookup, _DefaultAllureStore_environmentIdByName, _DefaultAllureStore_addEnvironments, _DefaultAllureStore_setTestResultEnvironmentId, _DefaultAllureStore_assertAllowedEnvironmentId, _DefaultAllureStore_assertAllowedStoredEnvironment, _DefaultAllureStore_environmentIdByTestResult, _DefaultAllureStore_assignIdentityHashes, _DefaultAllureStore_classifyResolution, _DefaultAllureStore_associateResolutionIssue, _DefaultAllureStore_removeResolutionIssueAssociation, _DefaultAllureStore_rebuildRetrySubstore, _DefaultAllureStore_rebuildIdentityIndexes, _DefaultAllureStore_rebuildEnvironmentIndexes, _DefaultAllureStore_resolveGlobalEnvironmentIdentity, _DefaultAllureStore_globalAttachmentId, _DefaultAllureStore_processGlobalAttachmentId, _DefaultAllureStore_indexGlobalError, _DefaultAllureStore_addGlobalError, _DefaultAllureStore_indexGlobalAttachment, _DefaultAllureStore_addGlobalAttachment, _DefaultAllureStore_resetProcessGlobals, _DefaultAllureStore_getHistoryLookup, _DefaultAllureStore_historyFor, _DefaultAllureStore_applyHistoryFlags, _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, resolveMetricSamples, selectHistoryTestResults, validateEnvironmentId, validateEnvironmentName, } from "@allurereport/core-api";
14
+ import { DEFAULT_ENVIRONMENT, DEFAULT_ENVIRONMENT_IDENTITY, calculateEnvironmentHash, calculateParametersHash, calculateRetryHash, calculateTestCaseHash, compareBy, createDictionary, fallbackTestCaseIdLabelName, getWorstStatus, createHistoryTestResultLookup, normalizeHistoryDataPoint, ordinal, reverse, resolveMetricSamples, 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";
18
- import { isFlaky } from "../utils/flaky.js";
18
+ import { createFlakyDetector } from "../utils/flaky.js";
19
19
  import { getStatusTransition } from "../utils/new.js";
20
20
  import { testFixtureResultRawToState, testResultRawToState } from "./convert.js";
21
- import { calculateParametersHash, calculateRetryHash, RetrySubstore } from "./retrySubstore.js";
21
+ import { RetrySubstore } from "./retrySubstore.js";
22
22
  const index = (indexMap, key, ...items) => {
23
23
  if (key) {
24
24
  if (!indexMap.has(key)) {
@@ -57,13 +57,12 @@ export class DefaultAllureStore {
57
57
  constructor(params) {
58
58
  _DefaultAllureStore_instances.add(this);
59
59
  _DefaultAllureStore_testResults.set(this, void 0);
60
- _DefaultAllureStore_environmentDisplayNames.set(this, void 0);
61
- _DefaultAllureStore_environmentNameToId.set(this, void 0);
62
60
  _DefaultAllureStore_attachments.set(this, void 0);
63
61
  _DefaultAllureStore_attachmentContents.set(this, void 0);
64
62
  _DefaultAllureStore_testCases.set(this, void 0);
65
63
  _DefaultAllureStore_metadata.set(this, void 0);
66
64
  _DefaultAllureStore_history.set(this, void 0);
65
+ _DefaultAllureStore_detectFlaky.set(this, void 0);
67
66
  _DefaultAllureStore_resolutionsConfig.set(this, void 0);
68
67
  _DefaultAllureStore_resolutionIssues.set(this, new Map());
69
68
  _DefaultAllureStore_testResultIdsByResolutionIssueId.set(this, new Map());
@@ -78,10 +77,9 @@ export class DefaultAllureStore {
78
77
  _DefaultAllureStore_allowedEnvironmentIds.set(this, void 0);
79
78
  _DefaultAllureStore_retrySubstore.set(this, void 0);
80
79
  _DefaultAllureStore_testResultIdsByEnvironmentId.set(this, new Map());
81
- _DefaultAllureStore_cachedEnvironmentEntries.set(this, []);
82
80
  this.indexTestResultByTestCase = new Map();
83
81
  this.indexTestResultByEnvironmentId = new Map();
84
- this.indexTestResultByHistoryId = new Map();
82
+ this.indexTestResultByRetryHash = new Map();
85
83
  this.indexAttachmentByTestResult = new Map();
86
84
  this.indexAttachmentByFixture = new Map();
87
85
  this.indexFixturesByTestResult = new Map();
@@ -89,14 +87,19 @@ export class DefaultAllureStore {
89
87
  _DefaultAllureStore_globalAttachmentIdsByEnv.set(this, new Map());
90
88
  _DefaultAllureStore_globalErrors.set(this, []);
91
89
  _DefaultAllureStore_globalErrorsByEnv.set(this, new Map());
90
+ _DefaultAllureStore_processGlobalAttachmentIds.set(this, []);
91
+ _DefaultAllureStore_processGlobalAttachmentIdsByEnv.set(this, new Map());
92
+ _DefaultAllureStore_processGlobalErrors.set(this, []);
93
+ _DefaultAllureStore_processGlobalErrorsByEnv.set(this, new Map());
92
94
  _DefaultAllureStore_globalExitCode.set(this, void 0);
93
95
  _DefaultAllureStore_checkResultsById.set(this, new Map());
94
96
  _DefaultAllureStore_qualityGateResults.set(this, []);
95
97
  _DefaultAllureStore_metrics.set(this, []);
96
98
  _DefaultAllureStore_performance.set(this, {});
97
99
  _DefaultAllureStore_historyPoints.set(this, []);
100
+ _DefaultAllureStore_historyLookup.set(this, void 0);
98
101
  _DefaultAllureStore_environments.set(this, []);
99
- const { history, resolutionsConfig, realtimeDispatcher, realtimeSubscriber, defaultLabels = {}, environment, allowedEnvironments, environmentsConfig = {}, reportVariables = {}, performance = {}, } = params ?? {};
102
+ const { history, flakyDetection, resolutionsConfig, realtimeDispatcher, realtimeSubscriber, defaultLabels = {}, environment, allowedEnvironments, environmentsConfig = {}, reportVariables = {}, performance = {}, } = params ?? {};
100
103
  const errors = [];
101
104
  const { normalized: normalizedEnvironmentsConfig, identities, errors: configErrors, } = normalizeEnvironmentDescriptorMap(environmentsConfig, "environmentsConfig");
102
105
  errors.push(...configErrors);
@@ -113,14 +116,13 @@ export class DefaultAllureStore {
113
116
  environments.push(resolvedEnvironment);
114
117
  }
115
118
  __classPrivateFieldSet(this, _DefaultAllureStore_testResults, new Map(), "f");
116
- __classPrivateFieldSet(this, _DefaultAllureStore_environmentDisplayNames, new Map(), "f");
117
- __classPrivateFieldSet(this, _DefaultAllureStore_environmentNameToId, new Map(), "f");
118
119
  __classPrivateFieldSet(this, _DefaultAllureStore_attachments, new Map(), "f");
119
120
  __classPrivateFieldSet(this, _DefaultAllureStore_attachmentContents, new Map(), "f");
120
121
  __classPrivateFieldSet(this, _DefaultAllureStore_testCases, new Map(), "f");
121
122
  __classPrivateFieldSet(this, _DefaultAllureStore_metadata, new Map(), "f");
122
123
  __classPrivateFieldSet(this, _DefaultAllureStore_fixtures, new Map(), "f");
123
124
  __classPrivateFieldSet(this, _DefaultAllureStore_history, history, "f");
125
+ __classPrivateFieldSet(this, _DefaultAllureStore_detectFlaky, createFlakyDetector(flakyDetection), "f");
124
126
  __classPrivateFieldSet(this, _DefaultAllureStore_resolutionsConfig, resolutionsConfig, "f");
125
127
  __classPrivateFieldSet(this, _DefaultAllureStore_performance, performance, "f");
126
128
  __classPrivateFieldSet(this, _DefaultAllureStore_realtimeDispatcher, realtimeDispatcher, "f");
@@ -131,7 +133,6 @@ export class DefaultAllureStore {
131
133
  __classPrivateFieldSet(this, _DefaultAllureStore_reportVariables, reportVariables, "f");
132
134
  __classPrivateFieldSet(this, _DefaultAllureStore_allowedEnvironmentIds, new Set(allowedEnvironments ?? []), "f");
133
135
  __classPrivateFieldSet(this, _DefaultAllureStore_retrySubstore, new RetrySubstore(), "f");
134
- __classPrivateFieldSet(this, _DefaultAllureStore_cachedEnvironmentEntries, Object.entries(__classPrivateFieldGet(this, _DefaultAllureStore_environmentsConfig, "f")), "f");
135
136
  __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_addEnvironments).call(this, environments);
136
137
  __classPrivateFieldGet(this, _DefaultAllureStore_realtimeSubscriber, "f")?.onQualityGateResults((results) => {
137
138
  __classPrivateFieldGet(this, _DefaultAllureStore_qualityGateResults, "f").push(...results);
@@ -180,17 +181,53 @@ export class DefaultAllureStore {
180
181
  };
181
182
  __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_addGlobalAttachment).call(this, attachmentLink, attachment);
182
183
  });
184
+ __classPrivateFieldGet(this, _DefaultAllureStore_realtimeSubscriber, "f")?.onProcessGlobalError?.((error) => {
185
+ const resolvedEnvironment = __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_resolveGlobalEnvironmentIdentity).call(this, error.environment);
186
+ __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_addGlobalError).call(this, {
187
+ ...error,
188
+ environment: resolvedEnvironment.id,
189
+ }, __classPrivateFieldGet(this, _DefaultAllureStore_processGlobalErrors, "f"), __classPrivateFieldGet(this, _DefaultAllureStore_processGlobalErrorsByEnv, "f"));
190
+ });
191
+ __classPrivateFieldGet(this, _DefaultAllureStore_realtimeSubscriber, "f")?.onProcessGlobalAttachment?.(({ attachment, fileName, environment }) => {
192
+ const originalFileName = attachment.getOriginalFileName();
193
+ const resolvedEnvironment = __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_resolveGlobalEnvironmentIdentity).call(this, environment);
194
+ const attachmentLink = {
195
+ id: __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_processGlobalAttachmentId).call(this, originalFileName, resolvedEnvironment.id),
196
+ name: fileName || originalFileName,
197
+ missed: false,
198
+ used: true,
199
+ ext: attachment.getExtension(),
200
+ contentType: attachment.getContentType(),
201
+ contentLength: attachment.getContentLength(),
202
+ originalFileName,
203
+ environment: resolvedEnvironment.id,
204
+ };
205
+ __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_addGlobalAttachment).call(this, attachmentLink, attachment, __classPrivateFieldGet(this, _DefaultAllureStore_processGlobalAttachmentIds, "f"), __classPrivateFieldGet(this, _DefaultAllureStore_processGlobalAttachmentIdsByEnv, "f"));
206
+ });
207
+ __classPrivateFieldGet(this, _DefaultAllureStore_realtimeSubscriber, "f")?.onProcessGlobalsReset?.(() => {
208
+ __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_resetProcessGlobals).call(this);
209
+ });
183
210
  }
184
211
  async readHistory() {
185
212
  if (!__classPrivateFieldGet(this, _DefaultAllureStore_history, "f")) {
186
213
  return [];
187
214
  }
215
+ __classPrivateFieldSet(this, _DefaultAllureStore_historyLookup, undefined, "f");
188
216
  __classPrivateFieldSet(this, _DefaultAllureStore_historyPoints, ((await __classPrivateFieldGet(this, _DefaultAllureStore_history, "f").readHistory()) ?? [])
189
217
  .filter((historyPoint) => typeof historyPoint === "object" && historyPoint !== null)
190
218
  .map(normalizeHistoryDataPoint), "f");
191
219
  __classPrivateFieldGet(this, _DefaultAllureStore_historyPoints, "f").sort(compareBy("timestamp", reverse(ordinal())));
192
220
  return __classPrivateFieldGet(this, _DefaultAllureStore_historyPoints, "f");
193
221
  }
222
+ updateHistoryFlags(testResults = __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f").values()) {
223
+ if (!__classPrivateFieldGet(this, _DefaultAllureStore_history, "f")) {
224
+ return;
225
+ }
226
+ const lookup = __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_getHistoryLookup).call(this);
227
+ for (const result of testResults) {
228
+ __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_applyHistoryFlags).call(this, result, __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_historyFor).call(this, result, lookup));
229
+ }
230
+ }
194
231
  async appendHistory(history) {
195
232
  if (!__classPrivateFieldGet(this, _DefaultAllureStore_history, "f")) {
196
233
  return;
@@ -261,13 +298,19 @@ export class DefaultAllureStore {
261
298
  return __classPrivateFieldGet(this, _DefaultAllureStore_globalExitCode, "f");
262
299
  }
263
300
  async allGlobalErrors() {
264
- return __classPrivateFieldGet(this, _DefaultAllureStore_globalErrors, "f");
301
+ return [...__classPrivateFieldGet(this, _DefaultAllureStore_globalErrors, "f"), ...__classPrivateFieldGet(this, _DefaultAllureStore_processGlobalErrors, "f")];
265
302
  }
266
303
  async allGlobalErrorsByEnv() {
267
- return mapToObject(__classPrivateFieldGet(this, _DefaultAllureStore_globalErrorsByEnv, "f"));
304
+ const result = {};
305
+ for (const errorsByEnv of [__classPrivateFieldGet(this, _DefaultAllureStore_globalErrorsByEnv, "f"), __classPrivateFieldGet(this, _DefaultAllureStore_processGlobalErrorsByEnv, "f")]) {
306
+ errorsByEnv.forEach((errors, environmentId) => {
307
+ result[environmentId] = [...(result[environmentId] ?? []), ...errors];
308
+ });
309
+ }
310
+ return result;
268
311
  }
269
312
  async allGlobalAttachments() {
270
- return __classPrivateFieldGet(this, _DefaultAllureStore_globalAttachmentIds, "f").reduce((acc, id) => {
313
+ return [...__classPrivateFieldGet(this, _DefaultAllureStore_globalAttachmentIds, "f"), ...__classPrivateFieldGet(this, _DefaultAllureStore_processGlobalAttachmentIds, "f")].reduce((acc, id) => {
271
314
  const attachment = __classPrivateFieldGet(this, _DefaultAllureStore_attachments, "f").get(id);
272
315
  if (!attachment) {
273
316
  return acc;
@@ -278,16 +321,19 @@ export class DefaultAllureStore {
278
321
  }
279
322
  async allGlobalAttachmentsByEnv() {
280
323
  const result = {};
281
- __classPrivateFieldGet(this, _DefaultAllureStore_globalAttachmentIdsByEnv, "f").forEach((attachmentIds, environmentId) => {
282
- result[environmentId] = attachmentIds.reduce((acc, id) => {
283
- const attachment = __classPrivateFieldGet(this, _DefaultAllureStore_attachments, "f").get(id);
284
- if (!attachment) {
324
+ for (const attachmentIdsByEnv of [__classPrivateFieldGet(this, _DefaultAllureStore_globalAttachmentIdsByEnv, "f"), __classPrivateFieldGet(this, _DefaultAllureStore_processGlobalAttachmentIdsByEnv, "f")]) {
325
+ attachmentIdsByEnv.forEach((attachmentIds, environmentId) => {
326
+ const attachments = attachmentIds.reduce((acc, id) => {
327
+ const attachment = __classPrivateFieldGet(this, _DefaultAllureStore_attachments, "f").get(id);
328
+ if (!attachment) {
329
+ return acc;
330
+ }
331
+ acc.push(attachment);
285
332
  return acc;
286
- }
287
- acc.push(attachment);
288
- return acc;
289
- }, []);
290
- });
333
+ }, []);
334
+ result[environmentId] = [...(result[environmentId] ?? []), ...attachments];
335
+ });
336
+ }
291
337
  return result;
292
338
  }
293
339
  async visitCheckResult(result) {
@@ -321,33 +367,38 @@ export class DefaultAllureStore {
321
367
  }
322
368
  });
323
369
  }
324
- const environmentIdentity = __classPrivateFieldGet(this, _DefaultAllureStore_environment, "f") ??
325
- (() => {
326
- const match = __classPrivateFieldGet(this, _DefaultAllureStore_cachedEnvironmentEntries, "f").find(([, { matcher }]) => matcher({ labels: testResult.labels }));
327
- if (!match) {
328
- return DEFAULT_ENVIRONMENT_IDENTITY;
370
+ const environmentMatcherLabels = testResult.labels.filter(({ name }) => name !== "ALLURE_ID" && name !== fallbackTestCaseIdLabelName);
371
+ const environmentMatch = __classPrivateFieldGet(this, _DefaultAllureStore_environment, "f")
372
+ ? undefined
373
+ : Object.entries(__classPrivateFieldGet(this, _DefaultAllureStore_environmentsConfig, "f")).find(([, { matcher }]) => matcher({ labels: environmentMatcherLabels }));
374
+ const namedEnvironmentIdentity = __classPrivateFieldGet(this, _DefaultAllureStore_environment, "f") ??
375
+ (environmentMatch
376
+ ? {
377
+ id: environmentMatch[0],
378
+ name: environmentMatch[1].name ?? environmentMatch[0],
329
379
  }
330
- const [id, descriptor] = match;
331
- return { id, name: descriptor.name ?? id };
332
- })();
333
- testResult.environment = environmentIdentity.name;
380
+ : undefined);
381
+ const environmentIdentity = namedEnvironmentIdentity ?? DEFAULT_ENVIRONMENT_IDENTITY;
382
+ testResult.environment = environmentIdentity.id;
334
383
  __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_addEnvironments).call(this, [environmentIdentity]);
335
- const parametersHash = typeof raw.parametersHash === "string" && raw.parametersHash.length > 0
336
- ? raw.parametersHash
337
- : calculateParametersHash(testResult.parameters);
338
- testResult.retryHash = calculateRetryHash(testResult.testCase?.id, parametersHash, environmentIdentity.id);
339
- const trHistory = __classPrivateFieldGet(this, _DefaultAllureStore_history, "f") ? await this.historyByTr(testResult) : undefined;
340
- if (trHistory !== undefined) {
341
- testResult.transition = getStatusTransition(testResult, trHistory);
342
- testResult.flaky = isFlaky(testResult, trHistory);
384
+ testResult.environmentHash = calculateEnvironmentHash(environmentIdentity.id);
385
+ testResult.retryHash = calculateRetryHash({
386
+ testCaseHash: testResult.testCaseHash,
387
+ parametersHash: testResult.parametersHash,
388
+ environmentHash: testResult.environmentHash,
389
+ });
390
+ if (__classPrivateFieldGet(this, _DefaultAllureStore_history, "f")) {
391
+ const lookup = createHistoryTestResultLookup([testResult]);
392
+ __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_applyHistoryFlags).call(this, testResult, __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_historyFor).call(this, testResult, lookup));
343
393
  }
344
394
  __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_classifyResolution).call(this, testResult);
345
395
  __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f").set(testResult.id, testResult);
396
+ __classPrivateFieldSet(this, _DefaultAllureStore_historyLookup, undefined, "f");
346
397
  __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_setTestResultEnvironmentId).call(this, testResult, environmentIdentity.id);
347
398
  __classPrivateFieldGet(this, _DefaultAllureStore_retrySubstore, "f").recordIngestOrder(testResult.id);
348
399
  __classPrivateFieldGet(this, _DefaultAllureStore_retrySubstore, "f").upsert(testResult);
349
400
  index(this.indexTestResultByTestCase, testResult.testCase?.id, testResult);
350
- index(this.indexTestResultByHistoryId, testResult.historyId, testResult);
401
+ index(this.indexTestResultByRetryHash, testResult.retryHash, testResult);
351
402
  index(this.indexAttachmentByTestResult, testResult.id, ...attachmentLinks);
352
403
  __classPrivateFieldGet(this, _DefaultAllureStore_realtimeDispatcher, "f")?.sendTestResult(testResult.id);
353
404
  }
@@ -387,7 +438,7 @@ export class DefaultAllureStore {
387
438
  contentLength: resultFile.getContentLength(),
388
439
  });
389
440
  }
390
- for (const globalAttachmentId of __classPrivateFieldGet(this, _DefaultAllureStore_globalAttachmentIds, "f")) {
441
+ for (const globalAttachmentId of [...__classPrivateFieldGet(this, _DefaultAllureStore_globalAttachmentIds, "f"), ...__classPrivateFieldGet(this, _DefaultAllureStore_processGlobalAttachmentIds, "f")]) {
391
442
  const globalAttachment = __classPrivateFieldGet(this, _DefaultAllureStore_attachments, "f").get(globalAttachmentId);
392
443
  if (!globalAttachment || globalAttachment.originalFileName !== originalFileName) {
393
444
  continue;
@@ -497,14 +548,7 @@ export class DefaultAllureStore {
497
548
  return __classPrivateFieldGet(this, _DefaultAllureStore_historyPoints, "f").reduce((result, dp) => {
498
549
  const filteredTestResults = [];
499
550
  for (const tr of Object.values(dp.testResults ?? {})) {
500
- const storedEnvironmentKey = typeof tr.environment === "string" ? tr.environment : undefined;
501
- const trEnvId = (storedEnvironmentKey ? __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_environmentIdByName).call(this, storedEnvironmentKey) : undefined) ??
502
- resolveStoredEnvironmentIdentity({
503
- environment: tr.environment,
504
- labels: tr.labels ?? [],
505
- }, __classPrivateFieldGet(this, _DefaultAllureStore_environmentsConfig, "f"), {
506
- forcedEnvironment: __classPrivateFieldGet(this, _DefaultAllureStore_environment, "f"),
507
- })?.id;
551
+ const trEnvId = tr.environment ?? DEFAULT_ENVIRONMENT;
508
552
  if (trEnvId === normalizedEnvironmentId) {
509
553
  filteredTestResults.push(tr);
510
554
  }
@@ -515,7 +559,7 @@ export class DefaultAllureStore {
515
559
  testResults: hasNoEnvironmentTestResults
516
560
  ? {}
517
561
  : filteredTestResults.reduce((acc, tr) => {
518
- acc[tr.historyId] = tr;
562
+ acc[tr.retryHash] = tr;
519
563
  return acc;
520
564
  }, {}),
521
565
  knownTestCaseIds: hasNoEnvironmentTestResults ? [] : filteredTestResults.map((tr) => tr.id),
@@ -550,7 +594,7 @@ export class DefaultAllureStore {
550
594
  if (allHistoryDps.length === 0) {
551
595
  return Array.from(__classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f").values());
552
596
  }
553
- const historicalIds = new Set(allHistoryDps.flatMap((dp) => Object.keys(dp.testResults ?? {})));
597
+ const lookup = __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_getHistoryLookup).call(this);
554
598
  const newTrs = [];
555
599
  for (const [, tr] of __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f")) {
556
600
  if (tr.isRetry) {
@@ -559,8 +603,7 @@ export class DefaultAllureStore {
559
603
  if (typeof filter === "function" && !filter(tr)) {
560
604
  continue;
561
605
  }
562
- const historyIdCandidates = getHistoryIdCandidates(tr);
563
- if (historyIdCandidates.length === 0 || historyIdCandidates.every((historyId) => !historicalIds.has(historyId))) {
606
+ if (!allHistoryDps.some((point) => lookup(point, tr))) {
564
607
  newTrs.push(tr);
565
608
  }
566
609
  }
@@ -754,26 +797,29 @@ export class DefaultAllureStore {
754
797
  return options.includeRetries ? [...trs] : trs.filter((tr) => !tr.isRetry);
755
798
  }
756
799
  async allTestEnvGroups() {
757
- const trByTestCaseId = {};
800
+ const trByEnvironmentNeutralRetryHash = {};
758
801
  for (const [, tr] of __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f")) {
759
- const testCaseId = tr?.testCase?.id;
760
- if (!testCaseId) {
802
+ const environmentNeutralRetryHash = calculateRetryHash({
803
+ testCaseHash: tr?.testCaseHash,
804
+ parametersHash: tr?.parametersHash,
805
+ });
806
+ if (!environmentNeutralRetryHash) {
761
807
  continue;
762
808
  }
763
- if (trByTestCaseId[testCaseId]) {
764
- trByTestCaseId[testCaseId].push(tr);
809
+ if (trByEnvironmentNeutralRetryHash[environmentNeutralRetryHash]) {
810
+ trByEnvironmentNeutralRetryHash[environmentNeutralRetryHash].push(tr);
765
811
  }
766
812
  else {
767
- trByTestCaseId[testCaseId] = [tr];
813
+ trByEnvironmentNeutralRetryHash[environmentNeutralRetryHash] = [tr];
768
814
  }
769
815
  }
770
- return Object.entries(trByTestCaseId).reduce((acc, [testCaseId, trs]) => {
816
+ return Object.entries(trByEnvironmentNeutralRetryHash).reduce((acc, [environmentNeutralRetryHash, trs]) => {
771
817
  if (trs.length === 0) {
772
818
  return acc;
773
819
  }
774
820
  const { fullName, name } = trs[0];
775
821
  const envGroup = {
776
- id: testCaseId,
822
+ id: environmentNeutralRetryHash,
777
823
  fullName,
778
824
  name,
779
825
  status: getWorstStatus(trs.map(({ status }) => status)) ?? "passed",
@@ -828,11 +874,11 @@ export class DefaultAllureStore {
828
874
  fixtures: mapToObject(__classPrivateFieldGet(this, _DefaultAllureStore_fixtures, "f")),
829
875
  environments: __classPrivateFieldGet(this, _DefaultAllureStore_environments, "f"),
830
876
  reportVariables: __classPrivateFieldGet(this, _DefaultAllureStore_reportVariables, "f"),
831
- globalAttachmentIds: __classPrivateFieldGet(this, _DefaultAllureStore_globalAttachmentIds, "f"),
832
- globalErrors: __classPrivateFieldGet(this, _DefaultAllureStore_globalErrors, "f"),
877
+ globalAttachmentIds: [...__classPrivateFieldGet(this, _DefaultAllureStore_globalAttachmentIds, "f"), ...__classPrivateFieldGet(this, _DefaultAllureStore_processGlobalAttachmentIds, "f")],
878
+ globalErrors: [...__classPrivateFieldGet(this, _DefaultAllureStore_globalErrors, "f"), ...__classPrivateFieldGet(this, _DefaultAllureStore_processGlobalErrors, "f")],
833
879
  checkResults: mapToObject(__classPrivateFieldGet(this, _DefaultAllureStore_checkResultsById, "f")),
834
880
  indexAttachmentByTestResult: {},
835
- indexTestResultByHistoryId: {},
881
+ indexTestResultByRetryHash: {},
836
882
  indexTestResultByTestCase: {},
837
883
  indexTestResultByResolutionIssue: {},
838
884
  indexAttachmentByFixture: {},
@@ -848,8 +894,8 @@ export class DefaultAllureStore {
848
894
  this.indexAttachmentByTestResult.forEach((links, trId) => {
849
895
  storeDump.indexAttachmentByTestResult[trId] = links.map((l) => l.id);
850
896
  });
851
- this.indexTestResultByHistoryId.forEach((trs, historyId) => {
852
- storeDump.indexTestResultByHistoryId[historyId] = trs.map((tr) => tr.id);
897
+ this.indexTestResultByRetryHash.forEach((trs, retryHash) => {
898
+ storeDump.indexTestResultByRetryHash[retryHash] = trs.map((tr) => tr.id);
853
899
  });
854
900
  this.indexTestResultByTestCase.forEach((trs, tcId) => {
855
901
  storeDump.indexTestResultByTestCase[tcId] = trs.map((tr) => tr.id);
@@ -863,22 +909,15 @@ export class DefaultAllureStore {
863
909
  return storeDump;
864
910
  }
865
911
  async restoreState(stateDump, attachmentsContents = {}) {
866
- const { testResults, attachments, testCases, fixtures, reportVariables, environments, globalAttachmentIds = [], globalErrors = [], checkResults, indexAttachmentByTestResult = {}, indexTestResultByHistoryId = {}, indexTestResultByTestCase = {}, indexTestResultByResolutionIssue = {}, indexAttachmentByFixture = {}, indexFixturesByTestResult = {}, resolutionIssues = {}, qualityGateResults = [], metrics = [], testResultIdsIngestOrder = [], } = stateDump;
867
- const storedEnvironmentAliases = environments.flatMap((environmentValue) => {
868
- if (typeof environmentValue === "string") {
869
- return [{ id: environmentValue, name: environmentValue }];
870
- }
871
- const idValidation = validateEnvironmentId(environmentValue.id);
872
- if (!idValidation.valid) {
873
- return [];
874
- }
875
- return [
876
- {
877
- id: idValidation.normalized,
878
- name: environmentValue.name ?? idValidation.normalized,
879
- },
880
- ];
881
- });
912
+ __classPrivateFieldSet(this, _DefaultAllureStore_historyLookup, undefined, "f");
913
+ const { testResults, attachments, testCases, fixtures, reportVariables, environments, globalAttachmentIds = [], globalErrors = [], checkResults, indexAttachmentByTestResult = {}, indexAttachmentByFixture = {}, indexFixturesByTestResult = {}, qualityGateResults = [], metrics = [], testResultIdsIngestOrder = [], } = stateDump;
914
+ __classPrivateFieldGet(this, _DefaultAllureStore_resolutionIssues, "f").clear();
915
+ __classPrivateFieldGet(this, _DefaultAllureStore_testResultIdsByResolutionIssueId, "f").clear();
916
+ __classPrivateFieldGet(this, _DefaultAllureStore_resolutionIssueIdByTestResultId, "f").clear();
917
+ for (const testResult of __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f").values()) {
918
+ delete testResult.resolution;
919
+ delete testResult.resolutionComment;
920
+ }
882
921
  const normalizedEnvironments = environments
883
922
  .map((environmentValue) => {
884
923
  if (typeof environmentValue === "string") {
@@ -906,41 +945,54 @@ export class DefaultAllureStore {
906
945
  fallbackToMatch: false,
907
946
  });
908
947
  });
909
- __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_addEnvironments).call(this, [...storedEnvironmentAliases, ...normalizedEnvironments]);
910
- const envNameToId = new Map();
911
- for (const { id, name } of __classPrivateFieldGet(this, _DefaultAllureStore_environments, "f")) {
912
- envNameToId.set(name, id);
913
- envNameToId.set(id, id);
914
- }
948
+ __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_addEnvironments).call(this, normalizedEnvironments);
949
+ Object.values(testCases).forEach((testCase) => {
950
+ const testCaseHash = calculateTestCaseHash(testCase.externalId, testCase.fullName);
951
+ if (!testCaseHash) {
952
+ return;
953
+ }
954
+ const existingTestCase = __classPrivateFieldGet(this, _DefaultAllureStore_testCases, "f").get(testCaseHash);
955
+ if (!existingTestCase) {
956
+ __classPrivateFieldGet(this, _DefaultAllureStore_testCases, "f").set(testCaseHash, {
957
+ ...testCase,
958
+ id: testCaseHash,
959
+ allureId: testCase.allureId?.trim() || undefined,
960
+ });
961
+ }
962
+ else if (!existingTestCase.allureId?.trim()) {
963
+ existingTestCase.allureId = testCase.allureId?.trim() || undefined;
964
+ }
965
+ });
915
966
  Object.values(testResults).forEach((testResult) => {
916
967
  __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_removeResolutionIssueAssociation).call(this, testResult.id);
968
+ delete testResult.resolution;
969
+ delete testResult.resolutionComment;
917
970
  __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f").set(testResult.id, testResult);
918
- const storedEnvKey = typeof testResult.environment === "string" ? testResult.environment : undefined;
919
- const envId = (storedEnvKey ? envNameToId.get(storedEnvKey) : undefined) ?? __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_environmentIdByTestResult).call(this, testResult);
971
+ const envId = __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_environmentIdByTestResult).call(this, testResult);
920
972
  __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_assertAllowedEnvironmentId).call(this, envId, `restored testResults[${JSON.stringify(testResult.id)}]`);
921
- __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_setTestResultEnvironmentId).call(this, testResult, envId);
922
- __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_assignRetryHash).call(this, testResult, { environmentId: envId });
973
+ __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_assignIdentityHashes).call(this, testResult, { environmentId: envId });
974
+ if (!testResult.testCaseHash) {
975
+ testResult.testCase = undefined;
976
+ }
977
+ else if (testResult.testCase) {
978
+ const restoredTestCase = __classPrivateFieldGet(this, _DefaultAllureStore_testCases, "f").get(testResult.testCaseHash);
979
+ if (restoredTestCase) {
980
+ if (!restoredTestCase.allureId?.trim()) {
981
+ restoredTestCase.allureId = testResult.testCase.allureId?.trim() || undefined;
982
+ }
983
+ testResult.testCase = restoredTestCase;
984
+ }
985
+ else {
986
+ testResult.testCase.id = testResult.testCaseHash;
987
+ testResult.testCase.allureId = testResult.testCase.allureId?.trim() || undefined;
988
+ __classPrivateFieldGet(this, _DefaultAllureStore_testCases, "f").set(testResult.testCaseHash, testResult.testCase);
989
+ }
990
+ }
923
991
  });
924
992
  __classPrivateFieldGet(this, _DefaultAllureStore_retrySubstore, "f").restoreIngestOrder(testResultIdsIngestOrder, (id) => __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f").has(id));
925
- this.indexTestResultByEnvironmentId.forEach((trs, envId) => {
926
- __classPrivateFieldGet(this, _DefaultAllureStore_testResultIdsByEnvironmentId, "f").set(envId, new Set(trs.map((tr) => tr.id)));
927
- });
928
993
  updateMapWithRecord(__classPrivateFieldGet(this, _DefaultAllureStore_checkResultsById, "f"), checkResults);
929
994
  updateMapWithRecord(__classPrivateFieldGet(this, _DefaultAllureStore_attachments, "f"), attachments);
930
- updateMapWithRecord(__classPrivateFieldGet(this, _DefaultAllureStore_testCases, "f"), testCases);
931
995
  updateMapWithRecord(__classPrivateFieldGet(this, _DefaultAllureStore_fixtures, "f"), fixtures);
932
- updateMapWithRecord(__classPrivateFieldGet(this, _DefaultAllureStore_resolutionIssues, "f"), resolutionIssues);
933
- Object.entries(indexTestResultByResolutionIssue).forEach(([resolutionIssueId, testResultIds]) => {
934
- const resolutionIssue = __classPrivateFieldGet(this, _DefaultAllureStore_resolutionIssues, "f").get(resolutionIssueId);
935
- if (!resolutionIssue) {
936
- return;
937
- }
938
- testResultIds.forEach((testResultId) => {
939
- if (__classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f").has(testResultId)) {
940
- __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_associateResolutionIssue).call(this, resolutionIssue, testResultId);
941
- }
942
- });
943
- });
944
996
  Object.entries(attachmentsContents).forEach(([id, content]) => {
945
997
  __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_restoreAttachmentContent).call(this, id, content);
946
998
  });
@@ -981,30 +1033,6 @@ export class DefaultAllureStore {
981
1033
  }
982
1034
  existingLinks.push(...attachmentsLinks);
983
1035
  });
984
- Object.entries(indexTestResultByHistoryId).forEach(([historyId, trIds]) => {
985
- const trs = trIds.map((id) => __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f").get(id)).filter(Boolean);
986
- if (trs.length === 0) {
987
- return;
988
- }
989
- const existingTrs = this.indexTestResultByHistoryId.get(historyId);
990
- if (!existingTrs) {
991
- this.indexTestResultByHistoryId.set(historyId, trs);
992
- return;
993
- }
994
- existingTrs.push(...trs);
995
- });
996
- Object.entries(indexTestResultByTestCase).forEach(([tcId, trIds]) => {
997
- const trs = trIds.map((id) => __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f").get(id)).filter(Boolean);
998
- if (trs.length === 0) {
999
- return;
1000
- }
1001
- const existingTrs = this.indexTestResultByTestCase.get(tcId);
1002
- if (!existingTrs) {
1003
- this.indexTestResultByTestCase.set(tcId, trs);
1004
- return;
1005
- }
1006
- existingTrs.push(...trs);
1007
- });
1008
1036
  Object.entries(indexAttachmentByFixture).forEach(([fxId, attachmentIds]) => {
1009
1037
  const attachmentsLinks = attachmentIds.map((id) => __classPrivateFieldGet(this, _DefaultAllureStore_attachments, "f").get(id)).filter(Boolean);
1010
1038
  if (attachmentsLinks.length === 0) {
@@ -1029,14 +1057,11 @@ export class DefaultAllureStore {
1029
1057
  }
1030
1058
  existingFixtures.push(...fxs);
1031
1059
  });
1060
+ __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_rebuildIdentityIndexes).call(this);
1061
+ __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_rebuildEnvironmentIndexes).call(this);
1032
1062
  __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_rebuildRetrySubstore).call(this);
1033
- if (__classPrivateFieldGet(this, _DefaultAllureStore_resolutionsConfig, "f")) {
1034
- __classPrivateFieldGet(this, _DefaultAllureStore_resolutionIssues, "f").clear();
1035
- __classPrivateFieldGet(this, _DefaultAllureStore_testResultIdsByResolutionIssueId, "f").clear();
1036
- __classPrivateFieldGet(this, _DefaultAllureStore_resolutionIssueIdByTestResultId, "f").clear();
1037
- for (const testResult of __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f").values()) {
1038
- __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_classifyResolution).call(this, testResult);
1039
- }
1063
+ for (const testResult of __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f").values()) {
1064
+ __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_classifyResolution).call(this, testResult);
1040
1065
  }
1041
1066
  qualityGateResults.forEach((result, index) => {
1042
1067
  __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_assertAllowedStoredEnvironment).call(this, {
@@ -1050,7 +1075,7 @@ export class DefaultAllureStore {
1050
1075
  __classPrivateFieldGet(this, _DefaultAllureStore_metrics, "f").push(...metrics);
1051
1076
  }
1052
1077
  }
1053
- _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_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) {
1078
+ _DefaultAllureStore_testResults = new WeakMap(), _DefaultAllureStore_attachments = new WeakMap(), _DefaultAllureStore_attachmentContents = new WeakMap(), _DefaultAllureStore_testCases = new WeakMap(), _DefaultAllureStore_metadata = new WeakMap(), _DefaultAllureStore_history = new WeakMap(), _DefaultAllureStore_detectFlaky = 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_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_historyLookup = new WeakMap(), _DefaultAllureStore_environments = new WeakMap(), _DefaultAllureStore_instances = new WeakSet(), _DefaultAllureStore_mergeEnvironmentIdentity = function _DefaultAllureStore_mergeEnvironmentIdentity(existingEnvironment, incomingEnvironment) {
1054
1079
  const configuredEnvironment = environmentIdentityById(__classPrivateFieldGet(this, _DefaultAllureStore_environmentsConfig, "f"), incomingEnvironment.id);
1055
1080
  if (configuredEnvironment) {
1056
1081
  return configuredEnvironment;
@@ -1076,12 +1101,12 @@ _DefaultAllureStore_testResults = new WeakMap(), _DefaultAllureStore_environment
1076
1101
  name: incomingEnvironment.id,
1077
1102
  };
1078
1103
  }, _DefaultAllureStore_environmentIdForLookup = function _DefaultAllureStore_environmentIdForLookup(environmentKey) {
1079
- const aliasedEnvironmentId = __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_environmentIdByName).call(this, environmentKey);
1080
- if (aliasedEnvironmentId) {
1081
- return aliasedEnvironmentId;
1082
- }
1083
1104
  const environmentIdValidation = validateEnvironmentId(environmentKey);
1084
1105
  return environmentIdValidation.valid ? environmentIdValidation.normalized : undefined;
1106
+ }, _DefaultAllureStore_environmentIdByName = function _DefaultAllureStore_environmentIdByName(environmentName) {
1107
+ return (__classPrivateFieldGet(this, _DefaultAllureStore_environments, "f").find(({ id }) => id === environmentName)?.id ??
1108
+ __classPrivateFieldGet(this, _DefaultAllureStore_environments, "f").find(({ name }) => name === environmentName)?.id ??
1109
+ __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_environmentIdForLookup).call(this, environmentName));
1085
1110
  }, _DefaultAllureStore_addEnvironments = function _DefaultAllureStore_addEnvironments(envs) {
1086
1111
  if (__classPrivateFieldGet(this, _DefaultAllureStore_environments, "f").length === 0) {
1087
1112
  __classPrivateFieldGet(this, _DefaultAllureStore_environments, "f").push(DEFAULT_ENVIRONMENT_IDENTITY);
@@ -1091,19 +1116,6 @@ _DefaultAllureStore_testResults = new WeakMap(), _DefaultAllureStore_environment
1091
1116
  nextById.set(environment.id, __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_mergeEnvironmentIdentity).call(this, nextById.get(environment.id), environment));
1092
1117
  });
1093
1118
  __classPrivateFieldSet(this, _DefaultAllureStore_environments, Array.from(nextById.values()), "f");
1094
- __classPrivateFieldGet(this, _DefaultAllureStore_environmentNameToId, "f").clear();
1095
- __classPrivateFieldGet(this, _DefaultAllureStore_environments, "f").forEach(({ id, name }) => {
1096
- __classPrivateFieldGet(this, _DefaultAllureStore_environmentNameToId, "f").set(name, id);
1097
- });
1098
- envs.forEach(({ id, name }) => {
1099
- __classPrivateFieldGet(this, _DefaultAllureStore_environmentDisplayNames, "f").set(name, id);
1100
- });
1101
- }, _DefaultAllureStore_environmentIdByName = function _DefaultAllureStore_environmentIdByName(environmentName) {
1102
- const canonicalId = __classPrivateFieldGet(this, _DefaultAllureStore_environmentNameToId, "f").get(environmentName);
1103
- if (canonicalId) {
1104
- return canonicalId;
1105
- }
1106
- return __classPrivateFieldGet(this, _DefaultAllureStore_environmentDisplayNames, "f").get(environmentName);
1107
1119
  }, _DefaultAllureStore_setTestResultEnvironmentId = function _DefaultAllureStore_setTestResultEnvironmentId(testResult, environmentId) {
1108
1120
  if (!environmentId) {
1109
1121
  return;
@@ -1140,28 +1152,32 @@ _DefaultAllureStore_testResults = new WeakMap(), _DefaultAllureStore_environment
1140
1152
  }
1141
1153
  __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_assertAllowedEnvironmentId).call(this, environmentKey, sourcePath);
1142
1154
  }, _DefaultAllureStore_environmentIdByTestResult = function _DefaultAllureStore_environmentIdByTestResult(testResult) {
1143
- const storedEnvironmentKey = typeof testResult.environment === "string" ? testResult.environment : undefined;
1144
- return ((storedEnvironmentKey ? __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_environmentIdByName).call(this, storedEnvironmentKey) : undefined) ??
1145
- resolveStoredEnvironmentIdentity({
1146
- environment: testResult.environment,
1147
- labels: testResult.labels,
1148
- }, __classPrivateFieldGet(this, _DefaultAllureStore_environmentsConfig, "f"), {
1149
- forcedEnvironment: __classPrivateFieldGet(this, _DefaultAllureStore_environment, "f"),
1150
- })?.id);
1151
- }, _DefaultAllureStore_assignRetryHash = function _DefaultAllureStore_assignRetryHash(testResult, options) {
1155
+ const environment = typeof testResult.environment === "string" ? testResult.environment : undefined;
1156
+ const validation = environment === undefined ? undefined : validateEnvironmentId(environment);
1157
+ return validation?.valid ? validation.normalized : undefined;
1158
+ }, _DefaultAllureStore_assignIdentityHashes = function _DefaultAllureStore_assignIdentityHashes(testResult, options) {
1152
1159
  const environmentId = options?.environmentId ?? __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_environmentIdByTestResult).call(this, testResult);
1153
- const parametersHash = options?.parametersHash ?? calculateParametersHash(testResult.parameters);
1154
- testResult.retryHash = calculateRetryHash(testResult.testCase?.id, parametersHash, environmentId);
1160
+ const testCaseHash = calculateTestCaseHash(testResult.testCase?.externalId, testResult.fullName);
1161
+ const parametersHash = calculateParametersHash(testResult.parameters);
1162
+ const environmentHash = calculateEnvironmentHash(environmentId && environmentId !== DEFAULT_ENVIRONMENT ? environmentId : undefined);
1163
+ testResult.testCaseHash = testCaseHash;
1164
+ testResult.parametersHash = parametersHash;
1165
+ testResult.environmentHash = environmentHash;
1166
+ testResult.retryHash = calculateRetryHash({ testCaseHash, parametersHash, environmentHash });
1167
+ if (testResult.testCase && testCaseHash) {
1168
+ testResult.testCase.id = testCaseHash;
1169
+ }
1155
1170
  }, _DefaultAllureStore_classifyResolution = function _DefaultAllureStore_classifyResolution(testResult) {
1156
1171
  const rule = getResolutionByRules(testResult, __classPrivateFieldGet(this, _DefaultAllureStore_resolutionsConfig, "f"));
1157
- testResult.resolution = rule?.resolution;
1158
- testResult.resolutionComment = rule?.comment;
1159
- __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_removeResolutionIssueAssociation).call(this, testResult.id);
1160
- if (rule?.resolution !== "issue") {
1172
+ if (!rule?.resolution) {
1161
1173
  return;
1162
1174
  }
1163
- const resolutionIssue = { ...rule.issue, comment: rule.comment };
1164
- __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_associateResolutionIssue).call(this, resolutionIssue, testResult.id);
1175
+ __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_removeResolutionIssueAssociation).call(this, testResult.id);
1176
+ testResult.resolution = rule.resolution;
1177
+ testResult.resolutionComment = rule.comment;
1178
+ if (rule.resolution === "issue") {
1179
+ __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_associateResolutionIssue).call(this, { ...rule.issue, comment: rule.comment }, testResult.id);
1180
+ }
1165
1181
  }, _DefaultAllureStore_associateResolutionIssue = function _DefaultAllureStore_associateResolutionIssue(resolutionIssue, testResultId) {
1166
1182
  __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_removeResolutionIssueAssociation).call(this, testResultId);
1167
1183
  __classPrivateFieldGet(this, _DefaultAllureStore_resolutionIssues, "f").set(resolutionIssue.id, resolutionIssue);
@@ -1186,10 +1202,23 @@ _DefaultAllureStore_testResults = new WeakMap(), _DefaultAllureStore_environment
1186
1202
  __classPrivateFieldGet(this, _DefaultAllureStore_retrySubstore, "f").reset();
1187
1203
  for (const [, testResult] of __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f")) {
1188
1204
  if (!testResult.retryHash) {
1189
- __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_assignRetryHash).call(this, testResult);
1205
+ __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_assignIdentityHashes).call(this, testResult);
1190
1206
  }
1191
1207
  __classPrivateFieldGet(this, _DefaultAllureStore_retrySubstore, "f").upsert(testResult);
1192
1208
  }
1209
+ }, _DefaultAllureStore_rebuildIdentityIndexes = function _DefaultAllureStore_rebuildIdentityIndexes() {
1210
+ this.indexTestResultByTestCase.clear();
1211
+ this.indexTestResultByRetryHash.clear();
1212
+ for (const testResult of __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f").values()) {
1213
+ index(this.indexTestResultByTestCase, testResult.testCase?.id, testResult);
1214
+ index(this.indexTestResultByRetryHash, testResult.retryHash, testResult);
1215
+ }
1216
+ }, _DefaultAllureStore_rebuildEnvironmentIndexes = function _DefaultAllureStore_rebuildEnvironmentIndexes() {
1217
+ __classPrivateFieldGet(this, _DefaultAllureStore_testResultIdsByEnvironmentId, "f").clear();
1218
+ this.indexTestResultByEnvironmentId.clear();
1219
+ for (const testResult of __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f").values()) {
1220
+ __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_setTestResultEnvironmentId).call(this, testResult, __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_environmentIdByTestResult).call(this, testResult));
1221
+ }
1193
1222
  }, _DefaultAllureStore_resolveGlobalEnvironmentIdentity = function _DefaultAllureStore_resolveGlobalEnvironmentIdentity(environment) {
1194
1223
  if (environment !== undefined) {
1195
1224
  const resolvedEnvironment = resolveStoredEnvironmentIdentity({
@@ -1208,30 +1237,51 @@ _DefaultAllureStore_testResults = new WeakMap(), _DefaultAllureStore_environment
1208
1237
  return DEFAULT_ENVIRONMENT_IDENTITY;
1209
1238
  }, _DefaultAllureStore_globalAttachmentId = function _DefaultAllureStore_globalAttachmentId(originalFileName, environmentId) {
1210
1239
  return md5(environmentId ? `${environmentId}:${originalFileName}` : originalFileName);
1211
- }, _DefaultAllureStore_indexGlobalError = function _DefaultAllureStore_indexGlobalError(error) {
1240
+ }, _DefaultAllureStore_processGlobalAttachmentId = function _DefaultAllureStore_processGlobalAttachmentId(originalFileName, environmentId) {
1241
+ return md5(`process:${environmentId}:${originalFileName}`);
1242
+ }, _DefaultAllureStore_indexGlobalError = function _DefaultAllureStore_indexGlobalError(error, errorsByEnv = __classPrivateFieldGet(this, _DefaultAllureStore_globalErrorsByEnv, "f")) {
1212
1243
  const resolvedEnvironment = __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_resolveGlobalEnvironmentIdentity).call(this, error.environment);
1213
1244
  if (!resolvedEnvironment) {
1214
1245
  return error;
1215
1246
  }
1216
1247
  error.environment = resolvedEnvironment.name;
1217
1248
  __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_addEnvironments).call(this, [resolvedEnvironment]);
1218
- index(__classPrivateFieldGet(this, _DefaultAllureStore_globalErrorsByEnv, "f"), resolvedEnvironment.id, error);
1249
+ index(errorsByEnv, resolvedEnvironment.id, error);
1219
1250
  return error;
1220
- }, _DefaultAllureStore_addGlobalError = function _DefaultAllureStore_addGlobalError(error) {
1221
- __classPrivateFieldGet(this, _DefaultAllureStore_globalErrors, "f").push(__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_indexGlobalError).call(this, error));
1222
- }, _DefaultAllureStore_indexGlobalAttachment = function _DefaultAllureStore_indexGlobalAttachment(attachmentLink) {
1251
+ }, _DefaultAllureStore_addGlobalError = function _DefaultAllureStore_addGlobalError(error, errors = __classPrivateFieldGet(this, _DefaultAllureStore_globalErrors, "f"), errorsByEnv = __classPrivateFieldGet(this, _DefaultAllureStore_globalErrorsByEnv, "f")) {
1252
+ errors.push(__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_indexGlobalError).call(this, error, errorsByEnv));
1253
+ }, _DefaultAllureStore_indexGlobalAttachment = function _DefaultAllureStore_indexGlobalAttachment(attachmentLink, attachmentIdsByEnv = __classPrivateFieldGet(this, _DefaultAllureStore_globalAttachmentIdsByEnv, "f")) {
1223
1254
  const resolvedEnvironment = __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_resolveGlobalEnvironmentIdentity).call(this, attachmentLink.environment);
1224
1255
  attachmentLink.environment = resolvedEnvironment.name;
1225
1256
  __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_addEnvironments).call(this, [resolvedEnvironment]);
1226
- index(__classPrivateFieldGet(this, _DefaultAllureStore_globalAttachmentIdsByEnv, "f"), resolvedEnvironment.id, attachmentLink.id);
1257
+ index(attachmentIdsByEnv, resolvedEnvironment.id, attachmentLink.id);
1227
1258
  return attachmentLink;
1228
- }, _DefaultAllureStore_addGlobalAttachment = function _DefaultAllureStore_addGlobalAttachment(attachmentLink, attachment) {
1229
- const indexedAttachment = __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_indexGlobalAttachment).call(this, { ...attachmentLink });
1259
+ }, _DefaultAllureStore_addGlobalAttachment = function _DefaultAllureStore_addGlobalAttachment(attachmentLink, attachment, attachmentIds = __classPrivateFieldGet(this, _DefaultAllureStore_globalAttachmentIds, "f"), attachmentIdsByEnv = __classPrivateFieldGet(this, _DefaultAllureStore_globalAttachmentIdsByEnv, "f")) {
1260
+ const indexedAttachment = __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_indexGlobalAttachment).call(this, { ...attachmentLink }, attachmentIdsByEnv);
1230
1261
  __classPrivateFieldGet(this, _DefaultAllureStore_attachments, "f").set(indexedAttachment.id, indexedAttachment);
1231
1262
  if (attachment) {
1232
1263
  __classPrivateFieldGet(this, _DefaultAllureStore_attachmentContents, "f").set(indexedAttachment.id, attachment);
1233
1264
  }
1234
- __classPrivateFieldGet(this, _DefaultAllureStore_globalAttachmentIds, "f").push(indexedAttachment.id);
1265
+ attachmentIds.push(indexedAttachment.id);
1266
+ }, _DefaultAllureStore_resetProcessGlobals = function _DefaultAllureStore_resetProcessGlobals() {
1267
+ for (const id of __classPrivateFieldGet(this, _DefaultAllureStore_processGlobalAttachmentIds, "f")) {
1268
+ __classPrivateFieldGet(this, _DefaultAllureStore_attachments, "f").delete(id);
1269
+ __classPrivateFieldGet(this, _DefaultAllureStore_attachmentContents, "f").delete(id);
1270
+ }
1271
+ __classPrivateFieldGet(this, _DefaultAllureStore_processGlobalAttachmentIds, "f").length = 0;
1272
+ __classPrivateFieldGet(this, _DefaultAllureStore_processGlobalAttachmentIdsByEnv, "f").clear();
1273
+ __classPrivateFieldGet(this, _DefaultAllureStore_processGlobalErrors, "f").length = 0;
1274
+ __classPrivateFieldGet(this, _DefaultAllureStore_processGlobalErrorsByEnv, "f").clear();
1275
+ }, _DefaultAllureStore_getHistoryLookup = function _DefaultAllureStore_getHistoryLookup() {
1276
+ return (__classPrivateFieldSet(this, _DefaultAllureStore_historyLookup, __classPrivateFieldGet(this, _DefaultAllureStore_historyLookup, "f") ?? createHistoryTestResultLookup(__classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f").values()), "f"));
1277
+ }, _DefaultAllureStore_historyFor = function _DefaultAllureStore_historyFor(result, lookup) {
1278
+ return __classPrivateFieldGet(this, _DefaultAllureStore_historyPoints, "f").flatMap((point) => {
1279
+ const historicalResult = lookup(point, result);
1280
+ return historicalResult ? [historicalResult] : [];
1281
+ });
1282
+ }, _DefaultAllureStore_applyHistoryFlags = function _DefaultAllureStore_applyHistoryFlags(result, history) {
1283
+ result.flaky = result.sourceMetadata?.reportedFlaky === true || __classPrivateFieldGet(this, _DefaultAllureStore_detectFlaky, "f").call(this, result, history);
1284
+ result.transition = getStatusTransition(result, history);
1235
1285
  }, _DefaultAllureStore_restoreAttachmentContent = function _DefaultAllureStore_restoreAttachmentContent(id, content) {
1236
1286
  const attachment = __classPrivateFieldGet(this, _DefaultAllureStore_attachments, "f").get(id);
1237
1287
  __classPrivateFieldGet(this, _DefaultAllureStore_attachmentContents, "f").set(id, content);
@@ -1260,9 +1310,12 @@ _DefaultAllureStore_testResults = new WeakMap(), _DefaultAllureStore_environment
1260
1310
  if (!__classPrivateFieldGet(this, _DefaultAllureStore_history, "f")) {
1261
1311
  return undefined;
1262
1312
  }
1263
- const historyIdCandidates = getHistoryIdCandidates(tr);
1264
- if (historyIdCandidates.length === 0) {
1313
+ if (!tr.retryHash) {
1265
1314
  return [];
1266
1315
  }
1267
- return selectHistoryTestResults(__classPrivateFieldGet(this, _DefaultAllureStore_historyPoints, "f"), historyIdCandidates);
1316
+ const lookup = __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_getHistoryLookup).call(this);
1317
+ return __classPrivateFieldGet(this, _DefaultAllureStore_historyPoints, "f").flatMap((point) => {
1318
+ const historical = lookup(point, tr);
1319
+ return historical ? [historical] : [];
1320
+ });
1268
1321
  };