@allurereport/core 3.2.0 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.d.ts +4 -2
- package/dist/config.d.ts +2 -0
- package/dist/config.js +73 -6
- package/dist/history.d.ts +1 -1
- package/dist/history.js +39 -15
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/plugin.js +2 -1
- package/dist/qualityGate/qualityGate.js +2 -2
- package/dist/qualityGate/rules.d.ts +3 -1
- package/dist/qualityGate/rules.js +40 -6
- package/dist/report.d.ts +1 -1
- package/dist/report.js +71 -48
- package/dist/store/convert.js +1 -1
- package/dist/store/store.d.ts +16 -5
- package/dist/store/store.js +376 -72
- package/dist/utils/environment.d.ts +24 -0
- package/dist/utils/environment.js +160 -0
- package/dist/utils/event.d.ts +1 -1
- package/dist/utils/safeDumpPath.d.ts +4 -0
- package/dist/utils/safeDumpPath.js +22 -0
- package/dist/utils/safeOutputPath.d.ts +5 -0
- package/dist/utils/safeOutputPath.js +31 -0
- package/dist/utils/windows.d.ts +2 -0
- package/dist/utils/windows.js +51 -0
- package/package.json +30 -42
package/dist/store/store.js
CHANGED
|
@@ -9,10 +9,11 @@ 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_attachments, _DefaultAllureStore_attachmentContents, _DefaultAllureStore_testCases, _DefaultAllureStore_metadata, _DefaultAllureStore_history, _DefaultAllureStore_known, _DefaultAllureStore_fixtures, _DefaultAllureStore_defaultLabels, _DefaultAllureStore_environment, _DefaultAllureStore_environmentsConfig, _DefaultAllureStore_reportVariables, _DefaultAllureStore_realtimeDispatcher, _DefaultAllureStore_realtimeSubscriber, _DefaultAllureStore_globalAttachmentIds, _DefaultAllureStore_globalErrors, _DefaultAllureStore_globalExitCode, _DefaultAllureStore_qualityGateResults, _DefaultAllureStore_historyPoints, _DefaultAllureStore_environments, _DefaultAllureStore_addEnvironments;
|
|
13
|
-
import { DEFAULT_ENVIRONMENT, compareBy, getWorstStatus, htrsByTr, matchEnvironment, nullsLast, ordinal, reverse, } from "@allurereport/core-api";
|
|
14
|
-
import { md5, } from "@allurereport/plugin-api";
|
|
12
|
+
var _DefaultAllureStore_instances, _DefaultAllureStore_testResults, _DefaultAllureStore_environmentDisplayNames, _DefaultAllureStore_environmentNameToId, _DefaultAllureStore_attachments, _DefaultAllureStore_attachmentContents, _DefaultAllureStore_testCases, _DefaultAllureStore_metadata, _DefaultAllureStore_history, _DefaultAllureStore_known, _DefaultAllureStore_fixtures, _DefaultAllureStore_defaultLabels, _DefaultAllureStore_environment, _DefaultAllureStore_environmentsConfig, _DefaultAllureStore_reportVariables, _DefaultAllureStore_realtimeDispatcher, _DefaultAllureStore_realtimeSubscriber, _DefaultAllureStore_globalAttachmentIds, _DefaultAllureStore_globalErrors, _DefaultAllureStore_globalExitCode, _DefaultAllureStore_qualityGateResults, _DefaultAllureStore_historyPoints, _DefaultAllureStore_environments, _DefaultAllureStore_mergeEnvironmentIdentity, _DefaultAllureStore_environmentIdForLookup, _DefaultAllureStore_addEnvironments, _DefaultAllureStore_environmentIdByName, _DefaultAllureStore_setTestResultEnvironmentId, _DefaultAllureStore_environmentIdByTestResult;
|
|
15
13
|
import { extname } from "node:path";
|
|
14
|
+
import { DEFAULT_ENVIRONMENT, DEFAULT_ENVIRONMENT_IDENTITY, compareBy, createDictionary, getHistoryIdCandidates, getWorstStatus, nullsLast, ordinal, reverse, selectHistoryTestResults, validateEnvironmentId, validateEnvironmentName, } from "@allurereport/core-api";
|
|
15
|
+
import { md5, } from "@allurereport/plugin-api";
|
|
16
|
+
import { environmentIdentityById, normalizeEnvironmentDescriptorMap, resolveEnvironmentIdentity, resolveStoredEnvironmentIdentity, } from "../utils/environment.js";
|
|
16
17
|
import { isFlaky } from "../utils/flaky.js";
|
|
17
18
|
import { getStatusTransition } from "../utils/new.js";
|
|
18
19
|
import { testFixtureResultRawToState, testResultRawToState } from "./convert.js";
|
|
@@ -26,14 +27,14 @@ const index = (indexMap, key, ...items) => {
|
|
|
26
27
|
}
|
|
27
28
|
};
|
|
28
29
|
const wasStartedEarlier = (first, second) => first.start === undefined || second.start === undefined || first.start < second.start;
|
|
29
|
-
const
|
|
30
|
-
const {
|
|
31
|
-
if (
|
|
32
|
-
if (!state.has(
|
|
33
|
-
state.set(
|
|
30
|
+
const hidePreviousAttemptByEnvironment = (state, testResult, environmentId) => {
|
|
31
|
+
const { historyId } = testResult;
|
|
32
|
+
if (environmentId) {
|
|
33
|
+
if (!state.has(environmentId)) {
|
|
34
|
+
state.set(environmentId, new Map());
|
|
34
35
|
}
|
|
35
36
|
if (historyId) {
|
|
36
|
-
const historyIdToLastAttemptResult = state.get(
|
|
37
|
+
const historyIdToLastAttemptResult = state.get(environmentId);
|
|
37
38
|
const currentLastAttemptResult = historyIdToLastAttemptResult.get(historyId);
|
|
38
39
|
if (currentLastAttemptResult) {
|
|
39
40
|
if (wasStartedEarlier(currentLastAttemptResult, testResult)) {
|
|
@@ -67,6 +68,8 @@ export class DefaultAllureStore {
|
|
|
67
68
|
constructor(params) {
|
|
68
69
|
_DefaultAllureStore_instances.add(this);
|
|
69
70
|
_DefaultAllureStore_testResults.set(this, void 0);
|
|
71
|
+
_DefaultAllureStore_environmentDisplayNames.set(this, void 0);
|
|
72
|
+
_DefaultAllureStore_environmentNameToId.set(this, void 0);
|
|
70
73
|
_DefaultAllureStore_attachments.set(this, void 0);
|
|
71
74
|
_DefaultAllureStore_attachmentContents.set(this, void 0);
|
|
72
75
|
_DefaultAllureStore_testCases.set(this, void 0);
|
|
@@ -81,6 +84,7 @@ export class DefaultAllureStore {
|
|
|
81
84
|
_DefaultAllureStore_realtimeDispatcher.set(this, void 0);
|
|
82
85
|
_DefaultAllureStore_realtimeSubscriber.set(this, void 0);
|
|
83
86
|
this.indexTestResultByTestCase = new Map();
|
|
87
|
+
this.indexTestResultByEnvironmentId = new Map();
|
|
84
88
|
this.indexLatestEnvTestResultByHistoryId = new Map();
|
|
85
89
|
this.indexTestResultByHistoryId = new Map();
|
|
86
90
|
this.indexAttachmentByTestResult = new Map();
|
|
@@ -94,10 +98,24 @@ export class DefaultAllureStore {
|
|
|
94
98
|
_DefaultAllureStore_historyPoints.set(this, []);
|
|
95
99
|
_DefaultAllureStore_environments.set(this, []);
|
|
96
100
|
const { history, known = [], realtimeDispatcher, realtimeSubscriber, defaultLabels = {}, environment, environmentsConfig = {}, reportVariables = {}, } = params ?? {};
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
101
|
+
const errors = [];
|
|
102
|
+
const { normalized: normalizedEnvironmentsConfig, identities, errors: configErrors, } = normalizeEnvironmentDescriptorMap(environmentsConfig, "environmentsConfig");
|
|
103
|
+
errors.push(...configErrors);
|
|
104
|
+
const forcedEnvironment = resolveEnvironmentIdentity({
|
|
105
|
+
environment,
|
|
106
|
+
}, normalizedEnvironmentsConfig, "store constructor");
|
|
107
|
+
errors.push(...forcedEnvironment.errors);
|
|
108
|
+
const resolvedEnvironment = forcedEnvironment.identity;
|
|
109
|
+
if (errors.length > 0) {
|
|
110
|
+
throw new Error(errors.join("; "));
|
|
111
|
+
}
|
|
112
|
+
const environments = [...identities];
|
|
113
|
+
if (resolvedEnvironment) {
|
|
114
|
+
environments.push(resolvedEnvironment);
|
|
115
|
+
}
|
|
100
116
|
__classPrivateFieldSet(this, _DefaultAllureStore_testResults, new Map(), "f");
|
|
117
|
+
__classPrivateFieldSet(this, _DefaultAllureStore_environmentDisplayNames, new Map(), "f");
|
|
118
|
+
__classPrivateFieldSet(this, _DefaultAllureStore_environmentNameToId, new Map(), "f");
|
|
101
119
|
__classPrivateFieldSet(this, _DefaultAllureStore_attachments, new Map(), "f");
|
|
102
120
|
__classPrivateFieldSet(this, _DefaultAllureStore_attachmentContents, new Map(), "f");
|
|
103
121
|
__classPrivateFieldSet(this, _DefaultAllureStore_testCases, new Map(), "f");
|
|
@@ -109,12 +127,30 @@ export class DefaultAllureStore {
|
|
|
109
127
|
__classPrivateFieldSet(this, _DefaultAllureStore_realtimeDispatcher, realtimeDispatcher, "f");
|
|
110
128
|
__classPrivateFieldSet(this, _DefaultAllureStore_realtimeSubscriber, realtimeSubscriber, "f");
|
|
111
129
|
__classPrivateFieldSet(this, _DefaultAllureStore_defaultLabels, defaultLabels, "f");
|
|
112
|
-
__classPrivateFieldSet(this, _DefaultAllureStore_environmentsConfig,
|
|
113
|
-
__classPrivateFieldSet(this, _DefaultAllureStore_environment,
|
|
130
|
+
__classPrivateFieldSet(this, _DefaultAllureStore_environmentsConfig, normalizedEnvironmentsConfig, "f");
|
|
131
|
+
__classPrivateFieldSet(this, _DefaultAllureStore_environment, resolvedEnvironment, "f");
|
|
114
132
|
__classPrivateFieldSet(this, _DefaultAllureStore_reportVariables, reportVariables, "f");
|
|
115
133
|
__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_addEnvironments).call(this, environments);
|
|
116
134
|
__classPrivateFieldGet(this, _DefaultAllureStore_realtimeSubscriber, "f")?.onQualityGateResults(async (results) => {
|
|
117
135
|
__classPrivateFieldGet(this, _DefaultAllureStore_qualityGateResults, "f").push(...results);
|
|
136
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_addEnvironments).call(this, results
|
|
137
|
+
.map((result) => {
|
|
138
|
+
const aliasedEnvironmentId = typeof result.environment === "string" ? __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_environmentIdByName).call(this, result.environment) : undefined;
|
|
139
|
+
if (aliasedEnvironmentId) {
|
|
140
|
+
const aliasedEnvironment = __classPrivateFieldGet(this, _DefaultAllureStore_environments, "f").find(({ id }) => id === aliasedEnvironmentId)?.name ?? aliasedEnvironmentId;
|
|
141
|
+
return {
|
|
142
|
+
id: aliasedEnvironmentId,
|
|
143
|
+
name: aliasedEnvironment,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
return resolveStoredEnvironmentIdentity({
|
|
147
|
+
environmentName: result.environment,
|
|
148
|
+
labels: [],
|
|
149
|
+
}, __classPrivateFieldGet(this, _DefaultAllureStore_environmentsConfig, "f"), {
|
|
150
|
+
forcedEnvironment: __classPrivateFieldGet(this, _DefaultAllureStore_environment, "f"),
|
|
151
|
+
});
|
|
152
|
+
})
|
|
153
|
+
.filter(Boolean));
|
|
118
154
|
});
|
|
119
155
|
__classPrivateFieldGet(this, _DefaultAllureStore_realtimeSubscriber, "f")?.onGlobalExitCode(async (exitCode) => {
|
|
120
156
|
__classPrivateFieldSet(this, _DefaultAllureStore_globalExitCode, exitCode, "f");
|
|
@@ -155,18 +191,41 @@ export class DefaultAllureStore {
|
|
|
155
191
|
await __classPrivateFieldGet(this, _DefaultAllureStore_history, "f").appendHistory(history);
|
|
156
192
|
}
|
|
157
193
|
async qualityGateResults() {
|
|
158
|
-
return __classPrivateFieldGet(this, _DefaultAllureStore_qualityGateResults, "f");
|
|
194
|
+
return [...__classPrivateFieldGet(this, _DefaultAllureStore_qualityGateResults, "f")];
|
|
159
195
|
}
|
|
160
196
|
async qualityGateResultsByEnv() {
|
|
161
|
-
const
|
|
197
|
+
const resultsById = await this.qualityGateResultsByEnvironmentId();
|
|
198
|
+
const resultsByEnv = createDictionary();
|
|
199
|
+
Object.entries(resultsById).forEach(([environmentId, results]) => {
|
|
200
|
+
const environmentName = __classPrivateFieldGet(this, _DefaultAllureStore_environments, "f").find(({ id }) => id === environmentId)?.name ?? environmentId;
|
|
201
|
+
resultsByEnv[environmentName] = results;
|
|
202
|
+
});
|
|
203
|
+
return resultsByEnv;
|
|
204
|
+
}
|
|
205
|
+
async qualityGateResultsByEnvironmentId() {
|
|
206
|
+
const resultsById = createDictionary();
|
|
162
207
|
for (const result of __classPrivateFieldGet(this, _DefaultAllureStore_qualityGateResults, "f")) {
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
208
|
+
const aliasedEnvironmentId = typeof result.environment === "string" ? __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_environmentIdByName).call(this, result.environment) : undefined;
|
|
209
|
+
const envIdentity = aliasedEnvironmentId !== undefined
|
|
210
|
+
? {
|
|
211
|
+
id: aliasedEnvironmentId,
|
|
212
|
+
name: __classPrivateFieldGet(this, _DefaultAllureStore_environments, "f").find(({ id }) => id === aliasedEnvironmentId)?.name ?? aliasedEnvironmentId,
|
|
213
|
+
}
|
|
214
|
+
: resolveStoredEnvironmentIdentity({
|
|
215
|
+
environmentName: result.environment,
|
|
216
|
+
labels: [],
|
|
217
|
+
}, __classPrivateFieldGet(this, _DefaultAllureStore_environmentsConfig, "f"), {
|
|
218
|
+
forcedEnvironment: __classPrivateFieldGet(this, _DefaultAllureStore_environment, "f"),
|
|
219
|
+
});
|
|
220
|
+
if (!envIdentity) {
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
if (!resultsById[envIdentity.id]) {
|
|
224
|
+
resultsById[envIdentity.id] = [];
|
|
166
225
|
}
|
|
167
|
-
|
|
226
|
+
resultsById[envIdentity.id].push(result);
|
|
168
227
|
}
|
|
169
|
-
return
|
|
228
|
+
return resultsById;
|
|
170
229
|
}
|
|
171
230
|
async globalExitCode() {
|
|
172
231
|
return __classPrivateFieldGet(this, _DefaultAllureStore_globalExitCode, "f");
|
|
@@ -205,14 +264,25 @@ export class DefaultAllureStore {
|
|
|
205
264
|
}
|
|
206
265
|
});
|
|
207
266
|
}
|
|
208
|
-
|
|
267
|
+
const environmentIdentity = __classPrivateFieldGet(this, _DefaultAllureStore_environment, "f") ??
|
|
268
|
+
(() => {
|
|
269
|
+
const match = Object.entries(__classPrivateFieldGet(this, _DefaultAllureStore_environmentsConfig, "f")).find(([, { matcher }]) => matcher({ labels: testResult.labels }));
|
|
270
|
+
if (!match) {
|
|
271
|
+
return DEFAULT_ENVIRONMENT_IDENTITY;
|
|
272
|
+
}
|
|
273
|
+
const [id, descriptor] = match;
|
|
274
|
+
return { id, name: descriptor.name ?? id };
|
|
275
|
+
})();
|
|
276
|
+
testResult.environment = environmentIdentity.name;
|
|
277
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_addEnvironments).call(this, [environmentIdentity]);
|
|
209
278
|
const trHistory = await this.historyByTr(testResult);
|
|
210
279
|
if (trHistory !== undefined) {
|
|
211
280
|
testResult.transition = getStatusTransition(testResult, trHistory);
|
|
212
281
|
testResult.flaky = isFlaky(testResult, trHistory);
|
|
213
282
|
}
|
|
214
283
|
__classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f").set(testResult.id, testResult);
|
|
215
|
-
|
|
284
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_setTestResultEnvironmentId).call(this, testResult, environmentIdentity.id);
|
|
285
|
+
hidePreviousAttemptByEnvironment(this.indexLatestEnvTestResultByHistoryId, testResult, environmentIdentity.id);
|
|
216
286
|
index(this.indexTestResultByTestCase, testResult.testCase?.id, testResult);
|
|
217
287
|
index(this.indexTestResultByHistoryId, testResult.historyId, testResult);
|
|
218
288
|
index(this.indexAttachmentByTestResult, testResult.id, ...attachmentLinks);
|
|
@@ -323,13 +393,35 @@ export class DefaultAllureStore {
|
|
|
323
393
|
return __classPrivateFieldGet(this, _DefaultAllureStore_historyPoints, "f");
|
|
324
394
|
}
|
|
325
395
|
async allHistoryDataPointsByEnvironment(environment) {
|
|
396
|
+
const environmentNameValidation = validateEnvironmentName(environment);
|
|
397
|
+
if (!environmentNameValidation.valid) {
|
|
398
|
+
return [];
|
|
399
|
+
}
|
|
400
|
+
const environmentId = __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_environmentIdByName).call(this, environmentNameValidation.normalized);
|
|
401
|
+
if (!environmentId) {
|
|
402
|
+
return [];
|
|
403
|
+
}
|
|
404
|
+
return this.allHistoryDataPointsByEnvironmentId(environmentId);
|
|
405
|
+
}
|
|
406
|
+
async allHistoryDataPointsByEnvironmentId(environmentId) {
|
|
407
|
+
const normalizedEnvironmentId = __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_environmentIdForLookup).call(this, environmentId);
|
|
408
|
+
if (!normalizedEnvironmentId) {
|
|
409
|
+
const validation = validateEnvironmentId(environmentId);
|
|
410
|
+
const reason = validation.valid ? "unknown environment id" : validation.reason;
|
|
411
|
+
throw new Error(`Invalid environmentId ${JSON.stringify(environmentId)}: ${reason}`);
|
|
412
|
+
}
|
|
326
413
|
return __classPrivateFieldGet(this, _DefaultAllureStore_historyPoints, "f").reduce((result, dp) => {
|
|
327
414
|
const filteredTestResults = [];
|
|
328
415
|
for (const tr of Object.values(dp.testResults)) {
|
|
329
|
-
const
|
|
330
|
-
const
|
|
331
|
-
(
|
|
332
|
-
|
|
416
|
+
const storedEnvironmentKey = typeof tr.environment === "string" ? tr.environment : undefined;
|
|
417
|
+
const trEnvId = (storedEnvironmentKey ? __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_environmentIdByName).call(this, storedEnvironmentKey) : undefined) ??
|
|
418
|
+
resolveStoredEnvironmentIdentity({
|
|
419
|
+
environment: tr.environment,
|
|
420
|
+
labels: tr.labels ?? [],
|
|
421
|
+
}, __classPrivateFieldGet(this, _DefaultAllureStore_environmentsConfig, "f"), {
|
|
422
|
+
forcedEnvironment: __classPrivateFieldGet(this, _DefaultAllureStore_environment, "f"),
|
|
423
|
+
})?.id;
|
|
424
|
+
if (trEnvId === normalizedEnvironmentId) {
|
|
333
425
|
filteredTestResults.push(tr);
|
|
334
426
|
}
|
|
335
427
|
}
|
|
@@ -350,12 +442,16 @@ export class DefaultAllureStore {
|
|
|
350
442
|
async allKnownIssues() {
|
|
351
443
|
return __classPrivateFieldGet(this, _DefaultAllureStore_known, "f");
|
|
352
444
|
}
|
|
353
|
-
async allNewTestResults(filter) {
|
|
354
|
-
if (!__classPrivateFieldGet(this, _DefaultAllureStore_history, "f")) {
|
|
445
|
+
async allNewTestResults(filter, history) {
|
|
446
|
+
if (!__classPrivateFieldGet(this, _DefaultAllureStore_history, "f") && !history) {
|
|
355
447
|
return [];
|
|
356
448
|
}
|
|
449
|
+
const allHistoryDps = history ?? (await this.allHistoryDataPoints());
|
|
450
|
+
if (allHistoryDps.length === 0) {
|
|
451
|
+
return Array.from(__classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f").values());
|
|
452
|
+
}
|
|
453
|
+
const historicalIds = new Set(allHistoryDps.flatMap((dp) => Object.keys(dp.testResults)));
|
|
357
454
|
const newTrs = [];
|
|
358
|
-
const allHistoryDps = await this.allHistoryDataPoints();
|
|
359
455
|
for (const [, tr] of __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f")) {
|
|
360
456
|
if (tr.hidden) {
|
|
361
457
|
continue;
|
|
@@ -363,11 +459,8 @@ export class DefaultAllureStore {
|
|
|
363
459
|
if (typeof filter === "function" && !filter(tr)) {
|
|
364
460
|
continue;
|
|
365
461
|
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
continue;
|
|
369
|
-
}
|
|
370
|
-
if (!allHistoryDps.some((dp) => dp.testResults[tr.historyId])) {
|
|
462
|
+
const historyIdCandidates = getHistoryIdCandidates(tr);
|
|
463
|
+
if (historyIdCandidates.length === 0 || historyIdCandidates.every((historyId) => !historicalIds.has(historyId))) {
|
|
371
464
|
newTrs.push(tr);
|
|
372
465
|
}
|
|
373
466
|
}
|
|
@@ -391,26 +484,43 @@ export class DefaultAllureStore {
|
|
|
391
484
|
async testResultsByTcId(tcId) {
|
|
392
485
|
return this.indexTestResultByTestCase.get(tcId) ?? [];
|
|
393
486
|
}
|
|
487
|
+
async environmentIdByTrId(trId) {
|
|
488
|
+
const testResult = __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f").get(trId);
|
|
489
|
+
return testResult ? __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_environmentIdByTestResult).call(this, testResult) : undefined;
|
|
490
|
+
}
|
|
394
491
|
async attachmentsByTrId(trId) {
|
|
395
492
|
return this.indexAttachmentByTestResult.get(trId) ?? [];
|
|
396
493
|
}
|
|
397
494
|
async retriesByTr(tr) {
|
|
495
|
+
const retries = [];
|
|
398
496
|
if (!tr || tr.hidden || !tr.historyId) {
|
|
399
|
-
return
|
|
497
|
+
return retries;
|
|
498
|
+
}
|
|
499
|
+
const trByHistoryId = this.indexTestResultByHistoryId.get(tr.historyId);
|
|
500
|
+
if (!trByHistoryId) {
|
|
501
|
+
return retries;
|
|
502
|
+
}
|
|
503
|
+
for (const r of trByHistoryId) {
|
|
504
|
+
if (!r.hidden || tr.environment !== r.environment) {
|
|
505
|
+
continue;
|
|
506
|
+
}
|
|
507
|
+
retries.push(r);
|
|
400
508
|
}
|
|
401
|
-
return
|
|
402
|
-
.filter((r) => r.hidden)
|
|
403
|
-
.sort(nullsLast(compareBy("start", reverse(ordinal()))));
|
|
509
|
+
return retries.sort(nullsLast(compareBy("start", reverse(ordinal()))));
|
|
404
510
|
}
|
|
405
511
|
async retriesByTrId(trId) {
|
|
406
512
|
const tr = await this.testResultById(trId);
|
|
407
|
-
return
|
|
513
|
+
return this.retriesByTr(tr);
|
|
408
514
|
}
|
|
409
515
|
async historyByTr(tr) {
|
|
410
516
|
if (!__classPrivateFieldGet(this, _DefaultAllureStore_history, "f")) {
|
|
411
517
|
return undefined;
|
|
412
518
|
}
|
|
413
|
-
|
|
519
|
+
const historyIdCandidates = getHistoryIdCandidates(tr);
|
|
520
|
+
if (historyIdCandidates.length === 0) {
|
|
521
|
+
return [];
|
|
522
|
+
}
|
|
523
|
+
return selectHistoryTestResults(__classPrivateFieldGet(this, _DefaultAllureStore_historyPoints, "f"), historyIdCandidates);
|
|
414
524
|
}
|
|
415
525
|
async historyByTrId(trId) {
|
|
416
526
|
const tr = await this.testResultById(trId);
|
|
@@ -439,13 +549,15 @@ export class DefaultAllureStore {
|
|
|
439
549
|
if (!__classPrivateFieldGet(this, _DefaultAllureStore_known, "f")?.length) {
|
|
440
550
|
return failedTestResults;
|
|
441
551
|
}
|
|
442
|
-
const knownHistoryIds = __classPrivateFieldGet(this, _DefaultAllureStore_known, "f").map((ktf) => ktf.historyId);
|
|
443
|
-
return failedTestResults.filter((
|
|
552
|
+
const knownHistoryIds = new Set(__classPrivateFieldGet(this, _DefaultAllureStore_known, "f").map((ktf) => ktf.historyId));
|
|
553
|
+
return failedTestResults.filter((tr) => {
|
|
554
|
+
const historyIdCandidates = getHistoryIdCandidates(tr);
|
|
555
|
+
return (historyIdCandidates.length > 0 && historyIdCandidates.every((historyId) => !knownHistoryIds.has(historyId)));
|
|
556
|
+
});
|
|
444
557
|
}
|
|
445
558
|
async testResultsByLabel(labelName) {
|
|
446
|
-
const results =
|
|
447
|
-
|
|
448
|
-
};
|
|
559
|
+
const results = createDictionary();
|
|
560
|
+
results._ = [];
|
|
449
561
|
for (const [, test] of __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f")) {
|
|
450
562
|
if (test.hidden) {
|
|
451
563
|
continue;
|
|
@@ -492,19 +604,31 @@ export class DefaultAllureStore {
|
|
|
492
604
|
return statistic;
|
|
493
605
|
}
|
|
494
606
|
async allEnvironments() {
|
|
607
|
+
return __classPrivateFieldGet(this, _DefaultAllureStore_environments, "f").map(({ name }) => name);
|
|
608
|
+
}
|
|
609
|
+
async allEnvironmentIdentities() {
|
|
495
610
|
return __classPrivateFieldGet(this, _DefaultAllureStore_environments, "f");
|
|
496
611
|
}
|
|
497
612
|
async testResultsByEnvironment(env, options = { includeHidden: false }) {
|
|
498
|
-
const
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
}
|
|
613
|
+
const environmentNameValidation = validateEnvironmentName(env);
|
|
614
|
+
if (!environmentNameValidation.valid) {
|
|
615
|
+
return [];
|
|
616
|
+
}
|
|
617
|
+
const environmentId = __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_environmentIdByName).call(this, environmentNameValidation.normalized);
|
|
618
|
+
if (!environmentId) {
|
|
619
|
+
return [];
|
|
506
620
|
}
|
|
507
|
-
return
|
|
621
|
+
return this.testResultsByEnvironmentId(environmentId, options);
|
|
622
|
+
}
|
|
623
|
+
async testResultsByEnvironmentId(envId, options = { includeHidden: false }) {
|
|
624
|
+
const normalizedEnvId = __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_environmentIdForLookup).call(this, envId);
|
|
625
|
+
if (!normalizedEnvId) {
|
|
626
|
+
const validation = validateEnvironmentId(envId);
|
|
627
|
+
const reason = validation.valid ? "unknown environment id" : validation.reason;
|
|
628
|
+
throw new Error(`Invalid environmentId ${JSON.stringify(envId)}: ${reason}`);
|
|
629
|
+
}
|
|
630
|
+
const trs = this.indexTestResultByEnvironmentId.get(normalizedEnvId) ?? [];
|
|
631
|
+
return options.includeHidden ? [...trs] : trs.filter((tr) => !tr.hidden);
|
|
508
632
|
}
|
|
509
633
|
async allTestEnvGroups() {
|
|
510
634
|
const trByTestCaseId = {};
|
|
@@ -533,7 +657,7 @@ export class DefaultAllureStore {
|
|
|
533
657
|
testResultsByEnv: {},
|
|
534
658
|
};
|
|
535
659
|
trs.forEach((tr) => {
|
|
536
|
-
const env =
|
|
660
|
+
const env = __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_environmentIdByTestResult).call(this, tr) ?? DEFAULT_ENVIRONMENT;
|
|
537
661
|
envGroup.testResultsByEnv[env] = tr.id;
|
|
538
662
|
});
|
|
539
663
|
acc.push(envGroup);
|
|
@@ -544,9 +668,33 @@ export class DefaultAllureStore {
|
|
|
544
668
|
return __classPrivateFieldGet(this, _DefaultAllureStore_reportVariables, "f");
|
|
545
669
|
}
|
|
546
670
|
async envVariables(env) {
|
|
671
|
+
const environmentNameValidation = validateEnvironmentName(env);
|
|
672
|
+
if (!environmentNameValidation.valid) {
|
|
673
|
+
return {
|
|
674
|
+
...__classPrivateFieldGet(this, _DefaultAllureStore_reportVariables, "f"),
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
const environmentId = __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_environmentIdByName).call(this, environmentNameValidation.normalized);
|
|
678
|
+
if (!environmentId) {
|
|
679
|
+
return {
|
|
680
|
+
...__classPrivateFieldGet(this, _DefaultAllureStore_reportVariables, "f"),
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
return this.envVariablesByEnvironmentId(environmentId);
|
|
684
|
+
}
|
|
685
|
+
async envVariablesByEnvironmentId(envId) {
|
|
686
|
+
const normalizedEnvId = __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_environmentIdForLookup).call(this, envId);
|
|
687
|
+
if (!normalizedEnvId) {
|
|
688
|
+
const validation = validateEnvironmentId(envId);
|
|
689
|
+
const reason = validation.valid ? "unknown environment id" : validation.reason;
|
|
690
|
+
throw new Error(`Invalid environmentId ${JSON.stringify(envId)}: ${reason}`);
|
|
691
|
+
}
|
|
692
|
+
const envDescriptor = Object.prototype.hasOwnProperty.call(__classPrivateFieldGet(this, _DefaultAllureStore_environmentsConfig, "f"), normalizedEnvId)
|
|
693
|
+
? __classPrivateFieldGet(this, _DefaultAllureStore_environmentsConfig, "f")[normalizedEnvId]
|
|
694
|
+
: undefined;
|
|
547
695
|
return {
|
|
548
696
|
...__classPrivateFieldGet(this, _DefaultAllureStore_reportVariables, "f"),
|
|
549
|
-
...(
|
|
697
|
+
...(envDescriptor?.variables ?? {}),
|
|
550
698
|
};
|
|
551
699
|
}
|
|
552
700
|
dumpState() {
|
|
@@ -568,9 +716,12 @@ export class DefaultAllureStore {
|
|
|
568
716
|
indexKnownByHistoryId: {},
|
|
569
717
|
qualityGateResults: __classPrivateFieldGet(this, _DefaultAllureStore_qualityGateResults, "f"),
|
|
570
718
|
};
|
|
571
|
-
this.indexLatestEnvTestResultByHistoryId.forEach((envMap) => {
|
|
719
|
+
this.indexLatestEnvTestResultByHistoryId.forEach((envMap, environmentId) => {
|
|
720
|
+
if (!storeDump.indexLatestEnvTestResultByHistoryId[environmentId]) {
|
|
721
|
+
storeDump.indexLatestEnvTestResultByHistoryId[environmentId] = {};
|
|
722
|
+
}
|
|
572
723
|
envMap.forEach((tr, historyId) => {
|
|
573
|
-
storeDump.indexLatestEnvTestResultByHistoryId[historyId] = tr.id;
|
|
724
|
+
storeDump.indexLatestEnvTestResultByHistoryId[environmentId][historyId] = tr.id;
|
|
574
725
|
});
|
|
575
726
|
});
|
|
576
727
|
this.indexAttachmentByFixture.forEach((link, fxId) => {
|
|
@@ -595,12 +746,56 @@ export class DefaultAllureStore {
|
|
|
595
746
|
}
|
|
596
747
|
async restoreState(stateDump, attachmentsContents = {}) {
|
|
597
748
|
const { testResults, attachments, testCases, fixtures, reportVariables, environments, globalAttachmentIds = [], globalErrors = [], indexAttachmentByTestResult = {}, indexTestResultByHistoryId = {}, indexTestResultByTestCase = {}, indexLatestEnvTestResultByHistoryId = {}, indexAttachmentByFixture = {}, indexFixturesByTestResult = {}, indexKnownByHistoryId = {}, qualityGateResults = [], } = stateDump;
|
|
598
|
-
|
|
749
|
+
const storedEnvironmentAliases = environments.flatMap((environmentValue) => {
|
|
750
|
+
if (typeof environmentValue === "string") {
|
|
751
|
+
return [{ id: environmentValue, name: environmentValue }];
|
|
752
|
+
}
|
|
753
|
+
const idValidation = validateEnvironmentId(environmentValue.id);
|
|
754
|
+
if (!idValidation.valid) {
|
|
755
|
+
return [];
|
|
756
|
+
}
|
|
757
|
+
return [
|
|
758
|
+
{
|
|
759
|
+
id: idValidation.normalized,
|
|
760
|
+
name: environmentValue.name ?? idValidation.normalized,
|
|
761
|
+
},
|
|
762
|
+
];
|
|
763
|
+
});
|
|
764
|
+
const normalizedEnvironments = environments
|
|
765
|
+
.map((environmentValue) => {
|
|
766
|
+
if (typeof environmentValue === "string") {
|
|
767
|
+
return resolveStoredEnvironmentIdentity({
|
|
768
|
+
environmentName: environmentValue,
|
|
769
|
+
}, __classPrivateFieldGet(this, _DefaultAllureStore_environmentsConfig, "f"), {
|
|
770
|
+
forcedEnvironment: __classPrivateFieldGet(this, _DefaultAllureStore_environment, "f"),
|
|
771
|
+
fallbackToMatch: false,
|
|
772
|
+
});
|
|
773
|
+
}
|
|
774
|
+
return resolveStoredEnvironmentIdentity({
|
|
775
|
+
environment: environmentValue.id,
|
|
776
|
+
environmentName: environmentValue.name,
|
|
777
|
+
}, __classPrivateFieldGet(this, _DefaultAllureStore_environmentsConfig, "f"), {
|
|
778
|
+
forcedEnvironment: __classPrivateFieldGet(this, _DefaultAllureStore_environment, "f"),
|
|
779
|
+
fallbackToMatch: false,
|
|
780
|
+
});
|
|
781
|
+
})
|
|
782
|
+
.filter(Boolean);
|
|
783
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_addEnvironments).call(this, [...storedEnvironmentAliases, ...normalizedEnvironments]);
|
|
784
|
+
const envNameToId = new Map();
|
|
785
|
+
for (const { id, name } of __classPrivateFieldGet(this, _DefaultAllureStore_environments, "f")) {
|
|
786
|
+
envNameToId.set(name, id);
|
|
787
|
+
envNameToId.set(id, id);
|
|
788
|
+
}
|
|
789
|
+
Object.values(testResults).forEach((testResult) => {
|
|
790
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f").set(testResult.id, testResult);
|
|
791
|
+
const storedEnvKey = typeof testResult.environment === "string" ? testResult.environment : undefined;
|
|
792
|
+
const envId = (storedEnvKey ? envNameToId.get(storedEnvKey) : undefined) ?? __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_environmentIdByTestResult).call(this, testResult);
|
|
793
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_setTestResultEnvironmentId).call(this, testResult, envId);
|
|
794
|
+
});
|
|
599
795
|
updateMapWithRecord(__classPrivateFieldGet(this, _DefaultAllureStore_attachments, "f"), attachments);
|
|
600
796
|
updateMapWithRecord(__classPrivateFieldGet(this, _DefaultAllureStore_testCases, "f"), testCases);
|
|
601
797
|
updateMapWithRecord(__classPrivateFieldGet(this, _DefaultAllureStore_fixtures, "f"), fixtures);
|
|
602
798
|
updateMapWithRecord(__classPrivateFieldGet(this, _DefaultAllureStore_attachmentContents, "f"), attachmentsContents);
|
|
603
|
-
__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_addEnvironments).call(this, environments);
|
|
604
799
|
__classPrivateFieldGet(this, _DefaultAllureStore_globalAttachmentIds, "f").push(...globalAttachmentIds);
|
|
605
800
|
__classPrivateFieldGet(this, _DefaultAllureStore_globalErrors, "f").push(...globalErrors);
|
|
606
801
|
Object.assign(__classPrivateFieldGet(this, _DefaultAllureStore_reportVariables, "f"), reportVariables);
|
|
@@ -672,24 +867,133 @@ export class DefaultAllureStore {
|
|
|
672
867
|
}
|
|
673
868
|
existingKnown.push(...knownFailures);
|
|
674
869
|
});
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
return;
|
|
870
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_environments, "f").forEach(({ id }) => {
|
|
871
|
+
if (!this.indexLatestEnvTestResultByHistoryId.has(id)) {
|
|
872
|
+
this.indexLatestEnvTestResultByHistoryId.set(id, new Map());
|
|
679
873
|
}
|
|
680
|
-
hidePreviousAttempt(this.indexLatestEnvTestResultByHistoryId, tr);
|
|
681
874
|
});
|
|
875
|
+
const latestAttemptsEntries = Object.entries(indexLatestEnvTestResultByHistoryId);
|
|
876
|
+
const hasNestedLatestAttempts = latestAttemptsEntries.some(([, value]) => typeof value === "object" && value !== null);
|
|
877
|
+
if (hasNestedLatestAttempts) {
|
|
878
|
+
latestAttemptsEntries.forEach(([environmentId, historyIds]) => {
|
|
879
|
+
const environmentIdValidation = validateEnvironmentId(environmentId);
|
|
880
|
+
if (!environmentIdValidation.valid || typeof historyIds !== "object" || historyIds === null) {
|
|
881
|
+
return;
|
|
882
|
+
}
|
|
883
|
+
const normalizedEnvironmentId = environmentIdValidation.normalized;
|
|
884
|
+
Object.values(historyIds).forEach((trId) => {
|
|
885
|
+
const tr = __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f").get(trId);
|
|
886
|
+
if (!tr) {
|
|
887
|
+
return;
|
|
888
|
+
}
|
|
889
|
+
hidePreviousAttemptByEnvironment(this.indexLatestEnvTestResultByHistoryId, tr, normalizedEnvironmentId);
|
|
890
|
+
});
|
|
891
|
+
});
|
|
892
|
+
}
|
|
893
|
+
else {
|
|
894
|
+
Object.entries(indexLatestEnvTestResultByHistoryId).forEach(([historyId, latestTrId]) => {
|
|
895
|
+
const trIdsForHistory = indexTestResultByHistoryId[historyId] ?? [];
|
|
896
|
+
const storedLatestTr = __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f").get(latestTrId);
|
|
897
|
+
const storedLatestEnvironmentId = storedLatestTr
|
|
898
|
+
? (__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_environmentIdByTestResult).call(this, storedLatestTr) ?? DEFAULT_ENVIRONMENT)
|
|
899
|
+
: undefined;
|
|
900
|
+
if (storedLatestTr && storedLatestEnvironmentId) {
|
|
901
|
+
hidePreviousAttemptByEnvironment(this.indexLatestEnvTestResultByHistoryId, storedLatestTr, storedLatestEnvironmentId);
|
|
902
|
+
}
|
|
903
|
+
for (const trId of trIdsForHistory) {
|
|
904
|
+
if (trId === latestTrId) {
|
|
905
|
+
continue;
|
|
906
|
+
}
|
|
907
|
+
const tr = __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f").get(trId);
|
|
908
|
+
if (!tr) {
|
|
909
|
+
continue;
|
|
910
|
+
}
|
|
911
|
+
const environmentId = __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_environmentIdByTestResult).call(this, tr) ?? DEFAULT_ENVIRONMENT;
|
|
912
|
+
if (storedLatestEnvironmentId && environmentId === storedLatestEnvironmentId) {
|
|
913
|
+
continue;
|
|
914
|
+
}
|
|
915
|
+
hidePreviousAttemptByEnvironment(this.indexLatestEnvTestResultByHistoryId, tr, environmentId);
|
|
916
|
+
}
|
|
917
|
+
});
|
|
918
|
+
}
|
|
682
919
|
__classPrivateFieldGet(this, _DefaultAllureStore_qualityGateResults, "f").push(...qualityGateResults);
|
|
683
920
|
}
|
|
684
921
|
}
|
|
685
|
-
_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_known = 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_globalAttachmentIds = new WeakMap(), _DefaultAllureStore_globalErrors = new WeakMap(), _DefaultAllureStore_globalExitCode = new WeakMap(), _DefaultAllureStore_qualityGateResults = new WeakMap(), _DefaultAllureStore_historyPoints = new WeakMap(), _DefaultAllureStore_environments = new WeakMap(), _DefaultAllureStore_instances = new WeakSet(),
|
|
922
|
+
_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_known = 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_globalAttachmentIds = new WeakMap(), _DefaultAllureStore_globalErrors = new WeakMap(), _DefaultAllureStore_globalExitCode = new WeakMap(), _DefaultAllureStore_qualityGateResults = new WeakMap(), _DefaultAllureStore_historyPoints = new WeakMap(), _DefaultAllureStore_environments = new WeakMap(), _DefaultAllureStore_instances = new WeakSet(), _DefaultAllureStore_mergeEnvironmentIdentity = function _DefaultAllureStore_mergeEnvironmentIdentity(existingEnvironment, incomingEnvironment) {
|
|
923
|
+
const configuredEnvironment = environmentIdentityById(__classPrivateFieldGet(this, _DefaultAllureStore_environmentsConfig, "f"), incomingEnvironment.id);
|
|
924
|
+
if (configuredEnvironment) {
|
|
925
|
+
return configuredEnvironment;
|
|
926
|
+
}
|
|
927
|
+
if (existingEnvironment) {
|
|
928
|
+
const existingNameValidation = validateEnvironmentName(existingEnvironment.name);
|
|
929
|
+
if (existingNameValidation.valid) {
|
|
930
|
+
return {
|
|
931
|
+
id: existingEnvironment.id,
|
|
932
|
+
name: existingNameValidation.normalized,
|
|
933
|
+
};
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
const incomingNameValidation = validateEnvironmentName(incomingEnvironment.name);
|
|
937
|
+
if (incomingNameValidation.valid) {
|
|
938
|
+
return {
|
|
939
|
+
id: incomingEnvironment.id,
|
|
940
|
+
name: incomingNameValidation.normalized,
|
|
941
|
+
};
|
|
942
|
+
}
|
|
943
|
+
return {
|
|
944
|
+
id: incomingEnvironment.id,
|
|
945
|
+
name: incomingEnvironment.id,
|
|
946
|
+
};
|
|
947
|
+
}, _DefaultAllureStore_environmentIdForLookup = function _DefaultAllureStore_environmentIdForLookup(environmentKey) {
|
|
948
|
+
const aliasedEnvironmentId = __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_environmentIdByName).call(this, environmentKey);
|
|
949
|
+
if (aliasedEnvironmentId) {
|
|
950
|
+
return aliasedEnvironmentId;
|
|
951
|
+
}
|
|
952
|
+
const environmentIdValidation = validateEnvironmentId(environmentKey);
|
|
953
|
+
return environmentIdValidation.valid ? environmentIdValidation.normalized : undefined;
|
|
954
|
+
}, _DefaultAllureStore_addEnvironments = function _DefaultAllureStore_addEnvironments(envs) {
|
|
686
955
|
if (__classPrivateFieldGet(this, _DefaultAllureStore_environments, "f").length === 0) {
|
|
687
|
-
__classPrivateFieldGet(this, _DefaultAllureStore_environments, "f").push(
|
|
956
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_environments, "f").push(DEFAULT_ENVIRONMENT_IDENTITY);
|
|
688
957
|
}
|
|
689
|
-
|
|
690
|
-
envs.forEach((
|
|
691
|
-
|
|
692
|
-
|
|
958
|
+
const nextById = new Map(__classPrivateFieldGet(this, _DefaultAllureStore_environments, "f").map((environment) => [environment.id, environment]));
|
|
959
|
+
envs.forEach((environment) => {
|
|
960
|
+
nextById.set(environment.id, __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_mergeEnvironmentIdentity).call(this, nextById.get(environment.id), environment));
|
|
961
|
+
});
|
|
962
|
+
__classPrivateFieldSet(this, _DefaultAllureStore_environments, Array.from(nextById.values()), "f");
|
|
963
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_environmentNameToId, "f").clear();
|
|
964
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_environments, "f").forEach(({ id, name }) => {
|
|
965
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_environmentNameToId, "f").set(name, id);
|
|
966
|
+
});
|
|
967
|
+
envs.forEach(({ id, name }) => {
|
|
968
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_environmentDisplayNames, "f").set(name, id);
|
|
969
|
+
});
|
|
970
|
+
envs.forEach(({ id }) => {
|
|
971
|
+
if (!this.indexLatestEnvTestResultByHistoryId.has(id)) {
|
|
972
|
+
this.indexLatestEnvTestResultByHistoryId.set(id, new Map());
|
|
693
973
|
}
|
|
694
974
|
});
|
|
975
|
+
}, _DefaultAllureStore_environmentIdByName = function _DefaultAllureStore_environmentIdByName(environmentName) {
|
|
976
|
+
const canonicalId = __classPrivateFieldGet(this, _DefaultAllureStore_environmentNameToId, "f").get(environmentName);
|
|
977
|
+
if (canonicalId) {
|
|
978
|
+
return canonicalId;
|
|
979
|
+
}
|
|
980
|
+
return __classPrivateFieldGet(this, _DefaultAllureStore_environmentDisplayNames, "f").get(environmentName);
|
|
981
|
+
}, _DefaultAllureStore_setTestResultEnvironmentId = function _DefaultAllureStore_setTestResultEnvironmentId(testResult, environmentId) {
|
|
982
|
+
if (!environmentId) {
|
|
983
|
+
return;
|
|
984
|
+
}
|
|
985
|
+
const existing = this.indexTestResultByEnvironmentId.get(environmentId);
|
|
986
|
+
if (existing?.some((tr) => tr.id === testResult.id)) {
|
|
987
|
+
return;
|
|
988
|
+
}
|
|
989
|
+
index(this.indexTestResultByEnvironmentId, environmentId, testResult);
|
|
990
|
+
}, _DefaultAllureStore_environmentIdByTestResult = function _DefaultAllureStore_environmentIdByTestResult(testResult) {
|
|
991
|
+
const storedEnvironmentKey = typeof testResult.environment === "string" ? testResult.environment : undefined;
|
|
992
|
+
return ((storedEnvironmentKey ? __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_environmentIdByName).call(this, storedEnvironmentKey) : undefined) ??
|
|
993
|
+
resolveStoredEnvironmentIdentity({
|
|
994
|
+
environment: testResult.environment,
|
|
995
|
+
labels: testResult.labels,
|
|
996
|
+
}, __classPrivateFieldGet(this, _DefaultAllureStore_environmentsConfig, "f"), {
|
|
997
|
+
forcedEnvironment: __classPrivateFieldGet(this, _DefaultAllureStore_environment, "f"),
|
|
998
|
+
})?.id);
|
|
695
999
|
};
|