@allurereport/core 3.18.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_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;
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();
@@ -99,8 +97,9 @@ export class DefaultAllureStore {
99
97
  _DefaultAllureStore_metrics.set(this, []);
100
98
  _DefaultAllureStore_performance.set(this, {});
101
99
  _DefaultAllureStore_historyPoints.set(this, []);
100
+ _DefaultAllureStore_historyLookup.set(this, void 0);
102
101
  _DefaultAllureStore_environments.set(this, []);
103
- 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 ?? {};
104
103
  const errors = [];
105
104
  const { normalized: normalizedEnvironmentsConfig, identities, errors: configErrors, } = normalizeEnvironmentDescriptorMap(environmentsConfig, "environmentsConfig");
106
105
  errors.push(...configErrors);
@@ -117,14 +116,13 @@ export class DefaultAllureStore {
117
116
  environments.push(resolvedEnvironment);
118
117
  }
119
118
  __classPrivateFieldSet(this, _DefaultAllureStore_testResults, new Map(), "f");
120
- __classPrivateFieldSet(this, _DefaultAllureStore_environmentDisplayNames, new Map(), "f");
121
- __classPrivateFieldSet(this, _DefaultAllureStore_environmentNameToId, new Map(), "f");
122
119
  __classPrivateFieldSet(this, _DefaultAllureStore_attachments, new Map(), "f");
123
120
  __classPrivateFieldSet(this, _DefaultAllureStore_attachmentContents, new Map(), "f");
124
121
  __classPrivateFieldSet(this, _DefaultAllureStore_testCases, new Map(), "f");
125
122
  __classPrivateFieldSet(this, _DefaultAllureStore_metadata, new Map(), "f");
126
123
  __classPrivateFieldSet(this, _DefaultAllureStore_fixtures, new Map(), "f");
127
124
  __classPrivateFieldSet(this, _DefaultAllureStore_history, history, "f");
125
+ __classPrivateFieldSet(this, _DefaultAllureStore_detectFlaky, createFlakyDetector(flakyDetection), "f");
128
126
  __classPrivateFieldSet(this, _DefaultAllureStore_resolutionsConfig, resolutionsConfig, "f");
129
127
  __classPrivateFieldSet(this, _DefaultAllureStore_performance, performance, "f");
130
128
  __classPrivateFieldSet(this, _DefaultAllureStore_realtimeDispatcher, realtimeDispatcher, "f");
@@ -135,7 +133,6 @@ export class DefaultAllureStore {
135
133
  __classPrivateFieldSet(this, _DefaultAllureStore_reportVariables, reportVariables, "f");
136
134
  __classPrivateFieldSet(this, _DefaultAllureStore_allowedEnvironmentIds, new Set(allowedEnvironments ?? []), "f");
137
135
  __classPrivateFieldSet(this, _DefaultAllureStore_retrySubstore, new RetrySubstore(), "f");
138
- __classPrivateFieldSet(this, _DefaultAllureStore_cachedEnvironmentEntries, Object.entries(__classPrivateFieldGet(this, _DefaultAllureStore_environmentsConfig, "f")), "f");
139
136
  __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_addEnvironments).call(this, environments);
140
137
  __classPrivateFieldGet(this, _DefaultAllureStore_realtimeSubscriber, "f")?.onQualityGateResults((results) => {
141
138
  __classPrivateFieldGet(this, _DefaultAllureStore_qualityGateResults, "f").push(...results);
@@ -215,12 +212,22 @@ export class DefaultAllureStore {
215
212
  if (!__classPrivateFieldGet(this, _DefaultAllureStore_history, "f")) {
216
213
  return [];
217
214
  }
215
+ __classPrivateFieldSet(this, _DefaultAllureStore_historyLookup, undefined, "f");
218
216
  __classPrivateFieldSet(this, _DefaultAllureStore_historyPoints, ((await __classPrivateFieldGet(this, _DefaultAllureStore_history, "f").readHistory()) ?? [])
219
217
  .filter((historyPoint) => typeof historyPoint === "object" && historyPoint !== null)
220
218
  .map(normalizeHistoryDataPoint), "f");
221
219
  __classPrivateFieldGet(this, _DefaultAllureStore_historyPoints, "f").sort(compareBy("timestamp", reverse(ordinal())));
222
220
  return __classPrivateFieldGet(this, _DefaultAllureStore_historyPoints, "f");
223
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
+ }
224
231
  async appendHistory(history) {
225
232
  if (!__classPrivateFieldGet(this, _DefaultAllureStore_history, "f")) {
226
233
  return;
@@ -360,33 +367,38 @@ export class DefaultAllureStore {
360
367
  }
361
368
  });
362
369
  }
363
- const environmentIdentity = __classPrivateFieldGet(this, _DefaultAllureStore_environment, "f") ??
364
- (() => {
365
- const match = __classPrivateFieldGet(this, _DefaultAllureStore_cachedEnvironmentEntries, "f").find(([, { matcher }]) => matcher({ labels: testResult.labels }));
366
- if (!match) {
367
- 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],
368
379
  }
369
- const [id, descriptor] = match;
370
- return { id, name: descriptor.name ?? id };
371
- })();
372
- testResult.environment = environmentIdentity.name;
380
+ : undefined);
381
+ const environmentIdentity = namedEnvironmentIdentity ?? DEFAULT_ENVIRONMENT_IDENTITY;
382
+ testResult.environment = environmentIdentity.id;
373
383
  __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_addEnvironments).call(this, [environmentIdentity]);
374
- const parametersHash = typeof raw.parametersHash === "string" && raw.parametersHash.length > 0
375
- ? raw.parametersHash
376
- : calculateParametersHash(testResult.parameters);
377
- testResult.retryHash = calculateRetryHash(testResult.testCase?.id, parametersHash, environmentIdentity.id);
378
- const trHistory = __classPrivateFieldGet(this, _DefaultAllureStore_history, "f") ? await this.historyByTr(testResult) : undefined;
379
- if (trHistory !== undefined) {
380
- testResult.transition = getStatusTransition(testResult, trHistory);
381
- 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));
382
393
  }
383
394
  __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_classifyResolution).call(this, testResult);
384
395
  __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f").set(testResult.id, testResult);
396
+ __classPrivateFieldSet(this, _DefaultAllureStore_historyLookup, undefined, "f");
385
397
  __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_setTestResultEnvironmentId).call(this, testResult, environmentIdentity.id);
386
398
  __classPrivateFieldGet(this, _DefaultAllureStore_retrySubstore, "f").recordIngestOrder(testResult.id);
387
399
  __classPrivateFieldGet(this, _DefaultAllureStore_retrySubstore, "f").upsert(testResult);
388
400
  index(this.indexTestResultByTestCase, testResult.testCase?.id, testResult);
389
- index(this.indexTestResultByHistoryId, testResult.historyId, testResult);
401
+ index(this.indexTestResultByRetryHash, testResult.retryHash, testResult);
390
402
  index(this.indexAttachmentByTestResult, testResult.id, ...attachmentLinks);
391
403
  __classPrivateFieldGet(this, _DefaultAllureStore_realtimeDispatcher, "f")?.sendTestResult(testResult.id);
392
404
  }
@@ -536,14 +548,7 @@ export class DefaultAllureStore {
536
548
  return __classPrivateFieldGet(this, _DefaultAllureStore_historyPoints, "f").reduce((result, dp) => {
537
549
  const filteredTestResults = [];
538
550
  for (const tr of Object.values(dp.testResults ?? {})) {
539
- const storedEnvironmentKey = typeof tr.environment === "string" ? tr.environment : undefined;
540
- const trEnvId = (storedEnvironmentKey ? __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_environmentIdByName).call(this, storedEnvironmentKey) : undefined) ??
541
- resolveStoredEnvironmentIdentity({
542
- environment: tr.environment,
543
- labels: tr.labels ?? [],
544
- }, __classPrivateFieldGet(this, _DefaultAllureStore_environmentsConfig, "f"), {
545
- forcedEnvironment: __classPrivateFieldGet(this, _DefaultAllureStore_environment, "f"),
546
- })?.id;
551
+ const trEnvId = tr.environment ?? DEFAULT_ENVIRONMENT;
547
552
  if (trEnvId === normalizedEnvironmentId) {
548
553
  filteredTestResults.push(tr);
549
554
  }
@@ -554,7 +559,7 @@ export class DefaultAllureStore {
554
559
  testResults: hasNoEnvironmentTestResults
555
560
  ? {}
556
561
  : filteredTestResults.reduce((acc, tr) => {
557
- acc[tr.historyId] = tr;
562
+ acc[tr.retryHash] = tr;
558
563
  return acc;
559
564
  }, {}),
560
565
  knownTestCaseIds: hasNoEnvironmentTestResults ? [] : filteredTestResults.map((tr) => tr.id),
@@ -589,7 +594,7 @@ export class DefaultAllureStore {
589
594
  if (allHistoryDps.length === 0) {
590
595
  return Array.from(__classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f").values());
591
596
  }
592
- const historicalIds = new Set(allHistoryDps.flatMap((dp) => Object.keys(dp.testResults ?? {})));
597
+ const lookup = __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_getHistoryLookup).call(this);
593
598
  const newTrs = [];
594
599
  for (const [, tr] of __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f")) {
595
600
  if (tr.isRetry) {
@@ -598,8 +603,7 @@ export class DefaultAllureStore {
598
603
  if (typeof filter === "function" && !filter(tr)) {
599
604
  continue;
600
605
  }
601
- const historyIdCandidates = getHistoryIdCandidates(tr);
602
- if (historyIdCandidates.length === 0 || historyIdCandidates.every((historyId) => !historicalIds.has(historyId))) {
606
+ if (!allHistoryDps.some((point) => lookup(point, tr))) {
603
607
  newTrs.push(tr);
604
608
  }
605
609
  }
@@ -793,26 +797,29 @@ export class DefaultAllureStore {
793
797
  return options.includeRetries ? [...trs] : trs.filter((tr) => !tr.isRetry);
794
798
  }
795
799
  async allTestEnvGroups() {
796
- const trByTestCaseId = {};
800
+ const trByEnvironmentNeutralRetryHash = {};
797
801
  for (const [, tr] of __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f")) {
798
- const testCaseId = tr?.testCase?.id;
799
- if (!testCaseId) {
802
+ const environmentNeutralRetryHash = calculateRetryHash({
803
+ testCaseHash: tr?.testCaseHash,
804
+ parametersHash: tr?.parametersHash,
805
+ });
806
+ if (!environmentNeutralRetryHash) {
800
807
  continue;
801
808
  }
802
- if (trByTestCaseId[testCaseId]) {
803
- trByTestCaseId[testCaseId].push(tr);
809
+ if (trByEnvironmentNeutralRetryHash[environmentNeutralRetryHash]) {
810
+ trByEnvironmentNeutralRetryHash[environmentNeutralRetryHash].push(tr);
804
811
  }
805
812
  else {
806
- trByTestCaseId[testCaseId] = [tr];
813
+ trByEnvironmentNeutralRetryHash[environmentNeutralRetryHash] = [tr];
807
814
  }
808
815
  }
809
- return Object.entries(trByTestCaseId).reduce((acc, [testCaseId, trs]) => {
816
+ return Object.entries(trByEnvironmentNeutralRetryHash).reduce((acc, [environmentNeutralRetryHash, trs]) => {
810
817
  if (trs.length === 0) {
811
818
  return acc;
812
819
  }
813
820
  const { fullName, name } = trs[0];
814
821
  const envGroup = {
815
- id: testCaseId,
822
+ id: environmentNeutralRetryHash,
816
823
  fullName,
817
824
  name,
818
825
  status: getWorstStatus(trs.map(({ status }) => status)) ?? "passed",
@@ -871,7 +878,7 @@ export class DefaultAllureStore {
871
878
  globalErrors: [...__classPrivateFieldGet(this, _DefaultAllureStore_globalErrors, "f"), ...__classPrivateFieldGet(this, _DefaultAllureStore_processGlobalErrors, "f")],
872
879
  checkResults: mapToObject(__classPrivateFieldGet(this, _DefaultAllureStore_checkResultsById, "f")),
873
880
  indexAttachmentByTestResult: {},
874
- indexTestResultByHistoryId: {},
881
+ indexTestResultByRetryHash: {},
875
882
  indexTestResultByTestCase: {},
876
883
  indexTestResultByResolutionIssue: {},
877
884
  indexAttachmentByFixture: {},
@@ -887,8 +894,8 @@ export class DefaultAllureStore {
887
894
  this.indexAttachmentByTestResult.forEach((links, trId) => {
888
895
  storeDump.indexAttachmentByTestResult[trId] = links.map((l) => l.id);
889
896
  });
890
- this.indexTestResultByHistoryId.forEach((trs, historyId) => {
891
- storeDump.indexTestResultByHistoryId[historyId] = trs.map((tr) => tr.id);
897
+ this.indexTestResultByRetryHash.forEach((trs, retryHash) => {
898
+ storeDump.indexTestResultByRetryHash[retryHash] = trs.map((tr) => tr.id);
892
899
  });
893
900
  this.indexTestResultByTestCase.forEach((trs, tcId) => {
894
901
  storeDump.indexTestResultByTestCase[tcId] = trs.map((tr) => tr.id);
@@ -902,22 +909,15 @@ export class DefaultAllureStore {
902
909
  return storeDump;
903
910
  }
904
911
  async restoreState(stateDump, attachmentsContents = {}) {
905
- const { testResults, attachments, testCases, fixtures, reportVariables, environments, globalAttachmentIds = [], globalErrors = [], checkResults, indexAttachmentByTestResult = {}, indexTestResultByHistoryId = {}, indexTestResultByTestCase = {}, indexTestResultByResolutionIssue = {}, indexAttachmentByFixture = {}, indexFixturesByTestResult = {}, resolutionIssues = {}, qualityGateResults = [], metrics = [], testResultIdsIngestOrder = [], } = stateDump;
906
- const storedEnvironmentAliases = environments.flatMap((environmentValue) => {
907
- if (typeof environmentValue === "string") {
908
- return [{ id: environmentValue, name: environmentValue }];
909
- }
910
- const idValidation = validateEnvironmentId(environmentValue.id);
911
- if (!idValidation.valid) {
912
- return [];
913
- }
914
- return [
915
- {
916
- id: idValidation.normalized,
917
- name: environmentValue.name ?? idValidation.normalized,
918
- },
919
- ];
920
- });
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
+ }
921
921
  const normalizedEnvironments = environments
922
922
  .map((environmentValue) => {
923
923
  if (typeof environmentValue === "string") {
@@ -945,41 +945,54 @@ export class DefaultAllureStore {
945
945
  fallbackToMatch: false,
946
946
  });
947
947
  });
948
- __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_addEnvironments).call(this, [...storedEnvironmentAliases, ...normalizedEnvironments]);
949
- const envNameToId = new Map();
950
- for (const { id, name } of __classPrivateFieldGet(this, _DefaultAllureStore_environments, "f")) {
951
- envNameToId.set(name, id);
952
- envNameToId.set(id, id);
953
- }
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
+ });
954
966
  Object.values(testResults).forEach((testResult) => {
955
967
  __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_removeResolutionIssueAssociation).call(this, testResult.id);
968
+ delete testResult.resolution;
969
+ delete testResult.resolutionComment;
956
970
  __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f").set(testResult.id, testResult);
957
- const storedEnvKey = typeof testResult.environment === "string" ? testResult.environment : undefined;
958
- 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);
959
972
  __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_assertAllowedEnvironmentId).call(this, envId, `restored testResults[${JSON.stringify(testResult.id)}]`);
960
- __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_setTestResultEnvironmentId).call(this, testResult, envId);
961
- __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
+ }
962
991
  });
963
992
  __classPrivateFieldGet(this, _DefaultAllureStore_retrySubstore, "f").restoreIngestOrder(testResultIdsIngestOrder, (id) => __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f").has(id));
964
- this.indexTestResultByEnvironmentId.forEach((trs, envId) => {
965
- __classPrivateFieldGet(this, _DefaultAllureStore_testResultIdsByEnvironmentId, "f").set(envId, new Set(trs.map((tr) => tr.id)));
966
- });
967
993
  updateMapWithRecord(__classPrivateFieldGet(this, _DefaultAllureStore_checkResultsById, "f"), checkResults);
968
994
  updateMapWithRecord(__classPrivateFieldGet(this, _DefaultAllureStore_attachments, "f"), attachments);
969
- updateMapWithRecord(__classPrivateFieldGet(this, _DefaultAllureStore_testCases, "f"), testCases);
970
995
  updateMapWithRecord(__classPrivateFieldGet(this, _DefaultAllureStore_fixtures, "f"), fixtures);
971
- updateMapWithRecord(__classPrivateFieldGet(this, _DefaultAllureStore_resolutionIssues, "f"), resolutionIssues);
972
- Object.entries(indexTestResultByResolutionIssue).forEach(([resolutionIssueId, testResultIds]) => {
973
- const resolutionIssue = __classPrivateFieldGet(this, _DefaultAllureStore_resolutionIssues, "f").get(resolutionIssueId);
974
- if (!resolutionIssue) {
975
- return;
976
- }
977
- testResultIds.forEach((testResultId) => {
978
- if (__classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f").has(testResultId)) {
979
- __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_associateResolutionIssue).call(this, resolutionIssue, testResultId);
980
- }
981
- });
982
- });
983
996
  Object.entries(attachmentsContents).forEach(([id, content]) => {
984
997
  __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_restoreAttachmentContent).call(this, id, content);
985
998
  });
@@ -1020,30 +1033,6 @@ export class DefaultAllureStore {
1020
1033
  }
1021
1034
  existingLinks.push(...attachmentsLinks);
1022
1035
  });
1023
- Object.entries(indexTestResultByHistoryId).forEach(([historyId, trIds]) => {
1024
- const trs = trIds.map((id) => __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f").get(id)).filter(Boolean);
1025
- if (trs.length === 0) {
1026
- return;
1027
- }
1028
- const existingTrs = this.indexTestResultByHistoryId.get(historyId);
1029
- if (!existingTrs) {
1030
- this.indexTestResultByHistoryId.set(historyId, trs);
1031
- return;
1032
- }
1033
- existingTrs.push(...trs);
1034
- });
1035
- Object.entries(indexTestResultByTestCase).forEach(([tcId, trIds]) => {
1036
- const trs = trIds.map((id) => __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f").get(id)).filter(Boolean);
1037
- if (trs.length === 0) {
1038
- return;
1039
- }
1040
- const existingTrs = this.indexTestResultByTestCase.get(tcId);
1041
- if (!existingTrs) {
1042
- this.indexTestResultByTestCase.set(tcId, trs);
1043
- return;
1044
- }
1045
- existingTrs.push(...trs);
1046
- });
1047
1036
  Object.entries(indexAttachmentByFixture).forEach(([fxId, attachmentIds]) => {
1048
1037
  const attachmentsLinks = attachmentIds.map((id) => __classPrivateFieldGet(this, _DefaultAllureStore_attachments, "f").get(id)).filter(Boolean);
1049
1038
  if (attachmentsLinks.length === 0) {
@@ -1068,6 +1057,8 @@ export class DefaultAllureStore {
1068
1057
  }
1069
1058
  existingFixtures.push(...fxs);
1070
1059
  });
1060
+ __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_rebuildIdentityIndexes).call(this);
1061
+ __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_rebuildEnvironmentIndexes).call(this);
1071
1062
  __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_rebuildRetrySubstore).call(this);
1072
1063
  for (const testResult of __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f").values()) {
1073
1064
  __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_classifyResolution).call(this, testResult);
@@ -1084,7 +1075,7 @@ export class DefaultAllureStore {
1084
1075
  __classPrivateFieldGet(this, _DefaultAllureStore_metrics, "f").push(...metrics);
1085
1076
  }
1086
1077
  }
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) {
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) {
1088
1079
  const configuredEnvironment = environmentIdentityById(__classPrivateFieldGet(this, _DefaultAllureStore_environmentsConfig, "f"), incomingEnvironment.id);
1089
1080
  if (configuredEnvironment) {
1090
1081
  return configuredEnvironment;
@@ -1110,12 +1101,12 @@ _DefaultAllureStore_testResults = new WeakMap(), _DefaultAllureStore_environment
1110
1101
  name: incomingEnvironment.id,
1111
1102
  };
1112
1103
  }, _DefaultAllureStore_environmentIdForLookup = function _DefaultAllureStore_environmentIdForLookup(environmentKey) {
1113
- const aliasedEnvironmentId = __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_environmentIdByName).call(this, environmentKey);
1114
- if (aliasedEnvironmentId) {
1115
- return aliasedEnvironmentId;
1116
- }
1117
1104
  const environmentIdValidation = validateEnvironmentId(environmentKey);
1118
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));
1119
1110
  }, _DefaultAllureStore_addEnvironments = function _DefaultAllureStore_addEnvironments(envs) {
1120
1111
  if (__classPrivateFieldGet(this, _DefaultAllureStore_environments, "f").length === 0) {
1121
1112
  __classPrivateFieldGet(this, _DefaultAllureStore_environments, "f").push(DEFAULT_ENVIRONMENT_IDENTITY);
@@ -1125,19 +1116,6 @@ _DefaultAllureStore_testResults = new WeakMap(), _DefaultAllureStore_environment
1125
1116
  nextById.set(environment.id, __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_mergeEnvironmentIdentity).call(this, nextById.get(environment.id), environment));
1126
1117
  });
1127
1118
  __classPrivateFieldSet(this, _DefaultAllureStore_environments, Array.from(nextById.values()), "f");
1128
- __classPrivateFieldGet(this, _DefaultAllureStore_environmentNameToId, "f").clear();
1129
- __classPrivateFieldGet(this, _DefaultAllureStore_environments, "f").forEach(({ id, name }) => {
1130
- __classPrivateFieldGet(this, _DefaultAllureStore_environmentNameToId, "f").set(name, id);
1131
- });
1132
- envs.forEach(({ id, name }) => {
1133
- __classPrivateFieldGet(this, _DefaultAllureStore_environmentDisplayNames, "f").set(name, id);
1134
- });
1135
- }, _DefaultAllureStore_environmentIdByName = function _DefaultAllureStore_environmentIdByName(environmentName) {
1136
- const canonicalId = __classPrivateFieldGet(this, _DefaultAllureStore_environmentNameToId, "f").get(environmentName);
1137
- if (canonicalId) {
1138
- return canonicalId;
1139
- }
1140
- return __classPrivateFieldGet(this, _DefaultAllureStore_environmentDisplayNames, "f").get(environmentName);
1141
1119
  }, _DefaultAllureStore_setTestResultEnvironmentId = function _DefaultAllureStore_setTestResultEnvironmentId(testResult, environmentId) {
1142
1120
  if (!environmentId) {
1143
1121
  return;
@@ -1174,18 +1152,21 @@ _DefaultAllureStore_testResults = new WeakMap(), _DefaultAllureStore_environment
1174
1152
  }
1175
1153
  __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_assertAllowedEnvironmentId).call(this, environmentKey, sourcePath);
1176
1154
  }, _DefaultAllureStore_environmentIdByTestResult = function _DefaultAllureStore_environmentIdByTestResult(testResult) {
1177
- const storedEnvironmentKey = typeof testResult.environment === "string" ? testResult.environment : undefined;
1178
- return ((storedEnvironmentKey ? __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_environmentIdByName).call(this, storedEnvironmentKey) : undefined) ??
1179
- resolveStoredEnvironmentIdentity({
1180
- environment: testResult.environment,
1181
- labels: testResult.labels,
1182
- }, __classPrivateFieldGet(this, _DefaultAllureStore_environmentsConfig, "f"), {
1183
- forcedEnvironment: __classPrivateFieldGet(this, _DefaultAllureStore_environment, "f"),
1184
- })?.id);
1185
- }, _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) {
1186
1159
  const environmentId = options?.environmentId ?? __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_environmentIdByTestResult).call(this, testResult);
1187
- const parametersHash = options?.parametersHash ?? calculateParametersHash(testResult.parameters);
1188
- 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
+ }
1189
1170
  }, _DefaultAllureStore_classifyResolution = function _DefaultAllureStore_classifyResolution(testResult) {
1190
1171
  const rule = getResolutionByRules(testResult, __classPrivateFieldGet(this, _DefaultAllureStore_resolutionsConfig, "f"));
1191
1172
  if (!rule?.resolution) {
@@ -1221,10 +1202,23 @@ _DefaultAllureStore_testResults = new WeakMap(), _DefaultAllureStore_environment
1221
1202
  __classPrivateFieldGet(this, _DefaultAllureStore_retrySubstore, "f").reset();
1222
1203
  for (const [, testResult] of __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f")) {
1223
1204
  if (!testResult.retryHash) {
1224
- __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_assignRetryHash).call(this, testResult);
1205
+ __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_assignIdentityHashes).call(this, testResult);
1225
1206
  }
1226
1207
  __classPrivateFieldGet(this, _DefaultAllureStore_retrySubstore, "f").upsert(testResult);
1227
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
+ }
1228
1222
  }, _DefaultAllureStore_resolveGlobalEnvironmentIdentity = function _DefaultAllureStore_resolveGlobalEnvironmentIdentity(environment) {
1229
1223
  if (environment !== undefined) {
1230
1224
  const resolvedEnvironment = resolveStoredEnvironmentIdentity({
@@ -1278,6 +1272,16 @@ _DefaultAllureStore_testResults = new WeakMap(), _DefaultAllureStore_environment
1278
1272
  __classPrivateFieldGet(this, _DefaultAllureStore_processGlobalAttachmentIdsByEnv, "f").clear();
1279
1273
  __classPrivateFieldGet(this, _DefaultAllureStore_processGlobalErrors, "f").length = 0;
1280
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);
1281
1285
  }, _DefaultAllureStore_restoreAttachmentContent = function _DefaultAllureStore_restoreAttachmentContent(id, content) {
1282
1286
  const attachment = __classPrivateFieldGet(this, _DefaultAllureStore_attachments, "f").get(id);
1283
1287
  __classPrivateFieldGet(this, _DefaultAllureStore_attachmentContents, "f").set(id, content);
@@ -1306,9 +1310,12 @@ _DefaultAllureStore_testResults = new WeakMap(), _DefaultAllureStore_environment
1306
1310
  if (!__classPrivateFieldGet(this, _DefaultAllureStore_history, "f")) {
1307
1311
  return undefined;
1308
1312
  }
1309
- const historyIdCandidates = getHistoryIdCandidates(tr);
1310
- if (historyIdCandidates.length === 0) {
1313
+ if (!tr.retryHash) {
1311
1314
  return [];
1312
1315
  }
1313
- 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
+ });
1314
1321
  };
@@ -48,7 +48,7 @@ export declare class RealtimeEventsDispatcher implements RealtimeEventsDispatche
48
48
  }
49
49
  export declare class RealtimeSubscriber implements RealtimeSubscriberType {
50
50
  #private;
51
- constructor(emitter: EventEmitter<AllureStoreEvents>);
51
+ constructor(emitter: EventEmitter<AllureStoreEvents>, beforeTestResults?: () => void);
52
52
  onGlobalAttachment(listener: (payload: {
53
53
  attachment: ResultFile;
54
54
  fileName?: string;