@allurereport/core 3.0.0-beta.18 → 3.0.0-beta.19

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 CHANGED
@@ -13,6 +13,8 @@ export interface FullConfig {
13
13
  historyPath: string;
14
14
  knownIssuesPath: string;
15
15
  defaultLabels?: DefaultLabelsConfig;
16
+ stage?: string;
17
+ environment?: string;
16
18
  environments?: EnvironmentsConfig;
17
19
  variables?: ReportVariables;
18
20
  reportFiles: ReportFiles;
package/dist/history.js CHANGED
@@ -16,15 +16,13 @@ const createHistoryItems = (testResults) => {
16
16
  stop,
17
17
  duration,
18
18
  labels,
19
+ url: "",
19
20
  historyId: historyId,
20
21
  reportLinks: [],
21
22
  };
22
23
  })
23
24
  .reduce((acc, item) => {
24
- acc[item.historyId] = {
25
- ...item,
26
- url: "",
27
- };
25
+ acc[item.historyId] = item;
28
26
  return acc;
29
27
  }, {});
30
28
  };
package/dist/report.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { KnownTestFailure, TestResult } from "@allurereport/core-api";
2
- import type { ResultFile } from "@allurereport/plugin-api";
2
+ import { type ResultFile } from "@allurereport/plugin-api";
3
3
  import type { FullConfig } from "./api.js";
4
4
  import { type QualityGateState } from "./qualityGate/index.js";
5
5
  import { DefaultAllureStore } from "./store/store.js";
@@ -25,5 +25,7 @@ export declare class AllureReport {
25
25
  results: import("@allurereport/plugin-api").QualityGateValidationResult[];
26
26
  }>;
27
27
  start: () => Promise<void>;
28
+ dumpState: () => Promise<void>;
29
+ restoreState: (stages: string[]) => Promise<void>;
28
30
  done: () => Promise<void>;
29
31
  }
package/dist/report.js CHANGED
@@ -9,18 +9,23 @@ 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 _AllureReport_instances, _AllureReport_reportName, _AllureReport_ci, _AllureReport_store, _AllureReport_readers, _AllureReport_plugins, _AllureReport_reportFiles, _AllureReport_eventEmitter, _AllureReport_realtimeSubscriber, _AllureReport_realtimeDispatcher, _AllureReport_realTime, _AllureReport_output, _AllureReport_history, _AllureReport_allureServiceClient, _AllureReport_qualityGate, _AllureReport_state, _AllureReport_stage, _AllureReport_publish_get, _AllureReport_update, _AllureReport_eachPlugin, _AllureReport_getPluginState;
12
+ var _AllureReport_instances, _AllureReport_reportName, _AllureReport_reportVariables, _AllureReport_ci, _AllureReport_store, _AllureReport_readers, _AllureReport_plugins, _AllureReport_reportFiles, _AllureReport_eventEmitter, _AllureReport_realtimeSubscriber, _AllureReport_realtimeDispatcher, _AllureReport_realTime, _AllureReport_output, _AllureReport_history, _AllureReport_allureServiceClient, _AllureReport_qualityGate, _AllureReport_stage, _AllureReport_stageTempDirs, _AllureReport_state, _AllureReport_executionStage, _AllureReport_publish_get, _AllureReport_update, _AllureReport_eachPlugin, _AllureReport_getPluginState;
13
13
  import { detect } from "@allurereport/ci";
14
+ import { AllureStoreDumpFiles, } from "@allurereport/plugin-api";
14
15
  import { allure1, allure2, attachments, cucumberjson, junitXml, readXcResultBundle } from "@allurereport/reader";
15
16
  import { PathResultFile } from "@allurereport/reader-api";
16
17
  import { AllureRemoteHistory, AllureServiceClient, KnownError, UnknownError } from "@allurereport/service";
17
18
  import { generateSummary } from "@allurereport/summary";
19
+ import ZipReadStream from "node-stream-zip";
18
20
  import console from "node:console";
19
21
  import { randomUUID } from "node:crypto";
20
22
  import { EventEmitter } from "node:events";
21
- import { readFileSync } from "node:fs";
22
- import { lstat, opendir, readdir, realpath, rename, rm, writeFile } from "node:fs/promises";
23
- import { dirname, join, resolve } from "node:path";
23
+ import { createReadStream, createWriteStream, existsSync, readFileSync } from "node:fs";
24
+ import { lstat, mkdtemp, opendir, readdir, realpath, rename, rm, writeFile } from "node:fs/promises";
25
+ import { tmpdir } from "node:os";
26
+ import { basename, dirname, join, resolve } from "node:path";
27
+ import { promisify } from "node:util";
28
+ import ZipWriteStream from "zip-stream";
24
29
  import { AllureLocalHistory, createHistory } from "./history.js";
25
30
  import { DefaultPluginState, PluginFiles } from "./plugin.js";
26
31
  import { QualityGate } from "./qualityGate/index.js";
@@ -32,6 +37,7 @@ export class AllureReport {
32
37
  constructor(opts) {
33
38
  _AllureReport_instances.add(this);
34
39
  _AllureReport_reportName.set(this, void 0);
40
+ _AllureReport_reportVariables.set(this, void 0);
35
41
  _AllureReport_ci.set(this, void 0);
36
42
  _AllureReport_store.set(this, void 0);
37
43
  _AllureReport_readers.set(this, void 0);
@@ -45,10 +51,12 @@ export class AllureReport {
45
51
  _AllureReport_history.set(this, void 0);
46
52
  _AllureReport_allureServiceClient.set(this, void 0);
47
53
  _AllureReport_qualityGate.set(this, void 0);
54
+ _AllureReport_stage.set(this, void 0);
55
+ _AllureReport_stageTempDirs.set(this, []);
48
56
  _AllureReport_state.set(this, void 0);
49
- _AllureReport_stage.set(this, "init");
57
+ _AllureReport_executionStage.set(this, "init");
50
58
  this.readDirectory = async (resultsDir) => {
51
- if (__classPrivateFieldGet(this, _AllureReport_stage, "f") !== "running") {
59
+ if (__classPrivateFieldGet(this, _AllureReport_executionStage, "f") !== "running") {
52
60
  throw new Error(initRequired);
53
61
  }
54
62
  const resultsDirPath = resolve(resultsDir);
@@ -69,13 +77,13 @@ export class AllureReport {
69
77
  }
70
78
  };
71
79
  this.readFile = async (resultsFile) => {
72
- if (__classPrivateFieldGet(this, _AllureReport_stage, "f") !== "running") {
80
+ if (__classPrivateFieldGet(this, _AllureReport_executionStage, "f") !== "running") {
73
81
  throw new Error(initRequired);
74
82
  }
75
83
  await this.readResult(new PathResultFile(resultsFile));
76
84
  };
77
85
  this.readResult = async (data) => {
78
- if (__classPrivateFieldGet(this, _AllureReport_stage, "f") !== "running") {
86
+ if (__classPrivateFieldGet(this, _AllureReport_executionStage, "f") !== "running") {
79
87
  throw new Error(initRequired);
80
88
  }
81
89
  for (const reader of __classPrivateFieldGet(this, _AllureReport_readers, "f")) {
@@ -98,13 +106,13 @@ export class AllureReport {
98
106
  };
99
107
  this.start = async () => {
100
108
  await __classPrivateFieldGet(this, _AllureReport_store, "f").readHistory();
101
- if (__classPrivateFieldGet(this, _AllureReport_stage, "f") === "running") {
109
+ if (__classPrivateFieldGet(this, _AllureReport_executionStage, "f") === "running") {
102
110
  throw new Error("the report is already started");
103
111
  }
104
- if (__classPrivateFieldGet(this, _AllureReport_stage, "f") === "done") {
112
+ if (__classPrivateFieldGet(this, _AllureReport_executionStage, "f") === "done") {
105
113
  throw new Error("the report is already stopped, the restart isn't supported at the moment");
106
114
  }
107
- __classPrivateFieldSet(this, _AllureReport_stage, "running", "f");
115
+ __classPrivateFieldSet(this, _AllureReport_executionStage, "running", "f");
108
116
  if (__classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f") && __classPrivateFieldGet(this, _AllureReport_instances, "a", _AllureReport_publish_get)) {
109
117
  const { url } = await __classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f").createReport({
110
118
  reportUuid: this.reportUuid,
@@ -123,21 +131,186 @@ export class AllureReport {
123
131
  }
124
132
  };
125
133
  _AllureReport_update.set(this, async () => {
126
- if (__classPrivateFieldGet(this, _AllureReport_stage, "f") !== "running") {
134
+ if (__classPrivateFieldGet(this, _AllureReport_executionStage, "f") !== "running") {
127
135
  return;
128
136
  }
129
137
  await __classPrivateFieldGet(this, _AllureReport_eachPlugin, "f").call(this, false, async (plugin, context) => {
130
138
  await plugin.update?.(context, __classPrivateFieldGet(this, _AllureReport_store, "f"));
131
139
  });
132
140
  });
141
+ this.dumpState = async () => {
142
+ const { testResults, testCases, fixtures, attachments: attachmentsLinks, environments, globalAttachments = [], globalErrors = [], indexAttachmentByTestResult = {}, indexTestResultByHistoryId = {}, indexTestResultByTestCase = {}, indexLatestEnvTestResultByHistoryId = {}, indexAttachmentByFixture = {}, indexFixturesByTestResult = {}, indexKnownByHistoryId = {}, } = __classPrivateFieldGet(this, _AllureReport_store, "f").dumpState();
143
+ const allAttachments = await __classPrivateFieldGet(this, _AllureReport_store, "f").allAttachments();
144
+ const dumpArchive = new ZipWriteStream({
145
+ zlib: { level: 5 },
146
+ });
147
+ const addEntry = promisify(dumpArchive.entry.bind(dumpArchive));
148
+ const dumpArchiveWriteStream = createWriteStream(`${__classPrivateFieldGet(this, _AllureReport_stage, "f")}.zip`);
149
+ const promise = new Promise((res, rej) => {
150
+ dumpArchive.on("error", (err) => rej(err));
151
+ dumpArchiveWriteStream.on("finish", () => res(void 0));
152
+ dumpArchiveWriteStream.on("error", (err) => rej(err));
153
+ });
154
+ dumpArchive.pipe(dumpArchiveWriteStream);
155
+ await addEntry(Buffer.from(JSON.stringify(testResults)), {
156
+ name: AllureStoreDumpFiles.TestResults,
157
+ });
158
+ await addEntry(Buffer.from(JSON.stringify(testCases)), {
159
+ name: AllureStoreDumpFiles.TestCases,
160
+ });
161
+ await addEntry(Buffer.from(JSON.stringify(fixtures)), {
162
+ name: AllureStoreDumpFiles.Fixtures,
163
+ });
164
+ await addEntry(Buffer.from(JSON.stringify(attachmentsLinks)), {
165
+ name: AllureStoreDumpFiles.Attachments,
166
+ });
167
+ await addEntry(Buffer.from(JSON.stringify(environments)), {
168
+ name: AllureStoreDumpFiles.Environments,
169
+ });
170
+ await addEntry(Buffer.from(JSON.stringify(__classPrivateFieldGet(this, _AllureReport_reportVariables, "f"))), {
171
+ name: AllureStoreDumpFiles.ReportVariables,
172
+ });
173
+ await addEntry(Buffer.from(JSON.stringify(globalAttachments)), {
174
+ name: AllureStoreDumpFiles.GlobalAttachments,
175
+ });
176
+ await addEntry(Buffer.from(JSON.stringify(globalErrors)), {
177
+ name: AllureStoreDumpFiles.GlobalErrors,
178
+ });
179
+ await addEntry(Buffer.from(JSON.stringify(indexAttachmentByTestResult)), {
180
+ name: AllureStoreDumpFiles.IndexAttachmentsByTestResults,
181
+ });
182
+ await addEntry(Buffer.from(JSON.stringify(indexTestResultByHistoryId)), {
183
+ name: AllureStoreDumpFiles.IndexTestResultsByHistoryId,
184
+ });
185
+ await addEntry(Buffer.from(JSON.stringify(indexTestResultByTestCase)), {
186
+ name: AllureStoreDumpFiles.IndexTestResultsByTestCase,
187
+ });
188
+ await addEntry(Buffer.from(JSON.stringify(indexLatestEnvTestResultByHistoryId)), {
189
+ name: AllureStoreDumpFiles.IndexLatestEnvTestResultsByHistoryId,
190
+ });
191
+ await addEntry(Buffer.from(JSON.stringify(indexAttachmentByFixture)), {
192
+ name: AllureStoreDumpFiles.IndexAttachmentsByFixture,
193
+ });
194
+ await addEntry(Buffer.from(JSON.stringify(indexFixturesByTestResult)), {
195
+ name: AllureStoreDumpFiles.IndexFixturesByTestResult,
196
+ });
197
+ await addEntry(Buffer.from(JSON.stringify(indexKnownByHistoryId)), {
198
+ name: AllureStoreDumpFiles.IndexKnownByHistoryId,
199
+ });
200
+ for (const attachment of allAttachments) {
201
+ const content = await __classPrivateFieldGet(this, _AllureReport_store, "f").attachmentContentById(attachment.id);
202
+ if (!content) {
203
+ continue;
204
+ }
205
+ if (content instanceof PathResultFile) {
206
+ await addEntry(createReadStream(content.path), {
207
+ name: attachment.id,
208
+ });
209
+ }
210
+ else {
211
+ await addEntry(await content.asBuffer(), {
212
+ name: attachment.id,
213
+ });
214
+ }
215
+ }
216
+ dumpArchive.finalize();
217
+ return promise;
218
+ };
219
+ this.restoreState = async (stages) => {
220
+ for (const stage of stages) {
221
+ if (!existsSync(stage)) {
222
+ continue;
223
+ }
224
+ const dump = new ZipReadStream.async({
225
+ file: stage,
226
+ });
227
+ const testResultsEntry = await dump.entryData(AllureStoreDumpFiles.TestResults);
228
+ const testCasesEntry = await dump.entryData(AllureStoreDumpFiles.TestCases);
229
+ const fixturesEntry = await dump.entryData(AllureStoreDumpFiles.Fixtures);
230
+ const attachmentsEntry = await dump.entryData(AllureStoreDumpFiles.Attachments);
231
+ const environmentsEntry = await dump.entryData(AllureStoreDumpFiles.Environments);
232
+ const reportVariablesEntry = await dump.entryData(AllureStoreDumpFiles.ReportVariables);
233
+ const globalAttachmentsEntry = await dump.entryData(AllureStoreDumpFiles.GlobalAttachments);
234
+ const globalErrorsEntry = await dump.entryData(AllureStoreDumpFiles.GlobalErrors);
235
+ const indexAttachmentsEntry = await dump.entryData(AllureStoreDumpFiles.IndexAttachmentsByTestResults);
236
+ const indexTestResultsByHistoryId = await dump.entryData(AllureStoreDumpFiles.IndexTestResultsByHistoryId);
237
+ const indexTestResultsByTestCaseEntry = await dump.entryData(AllureStoreDumpFiles.IndexTestResultsByTestCase);
238
+ const indexLatestEnvTestResultsByHistoryIdEntry = await dump.entryData(AllureStoreDumpFiles.IndexLatestEnvTestResultsByHistoryId);
239
+ const indexAttachmentsByFixtureEntry = await dump.entryData(AllureStoreDumpFiles.IndexAttachmentsByFixture);
240
+ const indexFixturesByTestResultEntry = await dump.entryData(AllureStoreDumpFiles.IndexFixturesByTestResult);
241
+ const indexKnownByHistoryIdEntry = await dump.entryData(AllureStoreDumpFiles.IndexKnownByHistoryId);
242
+ const attachmentsEntries = Object.entries(await dump.entries()).reduce((acc, [entryName, entry]) => {
243
+ switch (entryName) {
244
+ case AllureStoreDumpFiles.Attachments:
245
+ case AllureStoreDumpFiles.TestResults:
246
+ case AllureStoreDumpFiles.TestCases:
247
+ case AllureStoreDumpFiles.Fixtures:
248
+ case AllureStoreDumpFiles.Environments:
249
+ case AllureStoreDumpFiles.ReportVariables:
250
+ case AllureStoreDumpFiles.GlobalAttachments:
251
+ case AllureStoreDumpFiles.GlobalErrors:
252
+ case AllureStoreDumpFiles.IndexAttachmentsByTestResults:
253
+ case AllureStoreDumpFiles.IndexTestResultsByHistoryId:
254
+ case AllureStoreDumpFiles.IndexTestResultsByTestCase:
255
+ case AllureStoreDumpFiles.IndexLatestEnvTestResultsByHistoryId:
256
+ case AllureStoreDumpFiles.IndexAttachmentsByFixture:
257
+ case AllureStoreDumpFiles.IndexFixturesByTestResult:
258
+ case AllureStoreDumpFiles.IndexKnownByHistoryId:
259
+ return acc;
260
+ default:
261
+ return Object.assign(acc, {
262
+ [entryName]: entry,
263
+ });
264
+ }
265
+ }, {});
266
+ const dumpState = {
267
+ testResults: JSON.parse(testResultsEntry.toString("utf8")),
268
+ testCases: JSON.parse(testCasesEntry.toString("utf8")),
269
+ fixtures: JSON.parse(fixturesEntry.toString("utf8")),
270
+ attachments: JSON.parse(attachmentsEntry.toString("utf8")),
271
+ environments: JSON.parse(environmentsEntry.toString("utf8")),
272
+ reportVariables: JSON.parse(reportVariablesEntry.toString("utf8")),
273
+ globalAttachments: JSON.parse(globalAttachmentsEntry.toString("utf8")),
274
+ globalErrors: JSON.parse(globalErrorsEntry.toString("utf8")),
275
+ indexAttachmentByTestResult: JSON.parse(indexAttachmentsEntry.toString("utf8")),
276
+ indexTestResultByHistoryId: JSON.parse(indexTestResultsByHistoryId.toString("utf8")),
277
+ indexTestResultByTestCase: JSON.parse(indexTestResultsByTestCaseEntry.toString("utf8")),
278
+ indexLatestEnvTestResultByHistoryId: JSON.parse(indexLatestEnvTestResultsByHistoryIdEntry.toString("utf8")),
279
+ indexAttachmentByFixture: JSON.parse(indexAttachmentsByFixtureEntry.toString("utf8")),
280
+ indexFixturesByTestResult: JSON.parse(indexFixturesByTestResultEntry.toString("utf8")),
281
+ indexKnownByHistoryId: JSON.parse(indexKnownByHistoryIdEntry.toString("utf8")),
282
+ };
283
+ const stageTempDir = await mkdtemp(join(tmpdir(), basename(stage, ".zip")));
284
+ const resultsAttachments = {};
285
+ __classPrivateFieldGet(this, _AllureReport_stageTempDirs, "f").push(stageTempDir);
286
+ try {
287
+ for (const [attachmentId] of Object.entries(attachmentsEntries)) {
288
+ const attachmentContentEntry = await dump.entryData(attachmentId);
289
+ const attachmentFilePath = join(stageTempDir, attachmentId);
290
+ await writeFile(attachmentFilePath, attachmentContentEntry);
291
+ resultsAttachments[attachmentId] = new PathResultFile(attachmentFilePath, attachmentId);
292
+ }
293
+ }
294
+ catch (err) {
295
+ console.error(`Can't restore state from "${stage}", continuing without it`);
296
+ console.error(err);
297
+ }
298
+ await __classPrivateFieldGet(this, _AllureReport_store, "f").restoreState(dumpState, resultsAttachments);
299
+ console.info(`Successfully restored state from "${stage}"`);
300
+ }
301
+ };
133
302
  this.done = async () => {
134
303
  const summaries = [];
135
304
  const remoteHrefs = [];
136
- if (__classPrivateFieldGet(this, _AllureReport_stage, "f") !== "running") {
305
+ if (__classPrivateFieldGet(this, _AllureReport_executionStage, "f") !== "running") {
137
306
  throw new Error(initRequired);
138
307
  }
139
308
  __classPrivateFieldGet(this, _AllureReport_realtimeSubscriber, "f").offAll();
140
- __classPrivateFieldSet(this, _AllureReport_stage, "done", "f");
309
+ __classPrivateFieldSet(this, _AllureReport_executionStage, "done", "f");
310
+ if (__classPrivateFieldGet(this, _AllureReport_stage, "f")) {
311
+ await this.dumpState();
312
+ return;
313
+ }
141
314
  await __classPrivateFieldGet(this, _AllureReport_eachPlugin, "f").call(this, false, async (plugin, context) => {
142
315
  await plugin.done?.(context, __classPrivateFieldGet(this, _AllureReport_store, "f"));
143
316
  if (__classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f") && context.publish) {
@@ -200,6 +373,12 @@ export class AllureReport {
200
373
  }
201
374
  await rm(reportPath, { recursive: true });
202
375
  }
376
+ for (const dir of __classPrivateFieldGet(this, _AllureReport_stageTempDirs, "f")) {
377
+ try {
378
+ await rm(dir, { recursive: true });
379
+ }
380
+ catch (ignored) { }
381
+ }
203
382
  if (__classPrivateFieldGet(this, _AllureReport_history, "f")) {
204
383
  const testResults = await __classPrivateFieldGet(this, _AllureReport_store, "f").allTestResults();
205
384
  const testCases = await __classPrivateFieldGet(this, _AllureReport_store, "f").allTestCases();
@@ -279,16 +458,18 @@ export class AllureReport {
279
458
  }
280
459
  }
281
460
  });
282
- const { name, readers = [allure1, allure2, cucumberjson, junitXml, attachments], plugins = [], known, reportFiles, realTime, historyPath, defaultLabels = {}, variables = {}, environments, output, qualityGate, allureService: allureServiceConfig, } = opts;
461
+ const { name, readers = [allure1, allure2, cucumberjson, junitXml, attachments], plugins = [], known, reportFiles, realTime, historyPath, defaultLabels = {}, variables = {}, environment, environments, output, qualityGate, stage, allureService: allureServiceConfig, } = opts;
283
462
  __classPrivateFieldSet(this, _AllureReport_allureServiceClient, allureServiceConfig?.url ? new AllureServiceClient(allureServiceConfig) : undefined, "f");
284
463
  this.reportUuid = randomUUID();
285
464
  __classPrivateFieldSet(this, _AllureReport_ci, detect(), "f");
286
465
  const reportTitleSuffix = __classPrivateFieldGet(this, _AllureReport_ci, "f")?.pullRequestName ?? __classPrivateFieldGet(this, _AllureReport_ci, "f")?.jobRunName;
287
466
  __classPrivateFieldSet(this, _AllureReport_reportName, [name, reportTitleSuffix].filter(Boolean).join(" – "), "f");
467
+ __classPrivateFieldSet(this, _AllureReport_reportVariables, variables, "f");
288
468
  __classPrivateFieldSet(this, _AllureReport_eventEmitter, new EventEmitter(), "f");
289
469
  __classPrivateFieldSet(this, _AllureReport_realtimeDispatcher, new RealtimeEventsDispatcher(__classPrivateFieldGet(this, _AllureReport_eventEmitter, "f")), "f");
290
470
  __classPrivateFieldSet(this, _AllureReport_realtimeSubscriber, new RealtimeSubscriber(__classPrivateFieldGet(this, _AllureReport_eventEmitter, "f")), "f");
291
471
  __classPrivateFieldSet(this, _AllureReport_realTime, realTime, "f");
472
+ __classPrivateFieldSet(this, _AllureReport_stage, stage, "f");
292
473
  if (__classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f")) {
293
474
  __classPrivateFieldSet(this, _AllureReport_history, new AllureRemoteHistory(__classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f")), "f");
294
475
  }
@@ -306,6 +487,7 @@ export class AllureReport {
306
487
  history: __classPrivateFieldGet(this, _AllureReport_history, "f"),
307
488
  known,
308
489
  defaultLabels,
490
+ environment,
309
491
  }), "f");
310
492
  __classPrivateFieldSet(this, _AllureReport_readers, [...readers], "f");
311
493
  __classPrivateFieldSet(this, _AllureReport_plugins, [...plugins], "f");
@@ -328,7 +510,7 @@ export class AllureReport {
328
510
  return __classPrivateFieldGet(this, _AllureReport_realtimeDispatcher, "f");
329
511
  }
330
512
  }
331
- _AllureReport_reportName = new WeakMap(), _AllureReport_ci = new WeakMap(), _AllureReport_store = new WeakMap(), _AllureReport_readers = new WeakMap(), _AllureReport_plugins = new WeakMap(), _AllureReport_reportFiles = new WeakMap(), _AllureReport_eventEmitter = new WeakMap(), _AllureReport_realtimeSubscriber = new WeakMap(), _AllureReport_realtimeDispatcher = new WeakMap(), _AllureReport_realTime = new WeakMap(), _AllureReport_output = new WeakMap(), _AllureReport_history = new WeakMap(), _AllureReport_allureServiceClient = new WeakMap(), _AllureReport_qualityGate = new WeakMap(), _AllureReport_state = new WeakMap(), _AllureReport_stage = new WeakMap(), _AllureReport_update = new WeakMap(), _AllureReport_eachPlugin = new WeakMap(), _AllureReport_instances = new WeakSet(), _AllureReport_publish_get = function _AllureReport_publish_get() {
513
+ _AllureReport_reportName = new WeakMap(), _AllureReport_reportVariables = new WeakMap(), _AllureReport_ci = new WeakMap(), _AllureReport_store = new WeakMap(), _AllureReport_readers = new WeakMap(), _AllureReport_plugins = new WeakMap(), _AllureReport_reportFiles = new WeakMap(), _AllureReport_eventEmitter = new WeakMap(), _AllureReport_realtimeSubscriber = new WeakMap(), _AllureReport_realtimeDispatcher = new WeakMap(), _AllureReport_realTime = new WeakMap(), _AllureReport_output = new WeakMap(), _AllureReport_history = new WeakMap(), _AllureReport_allureServiceClient = new WeakMap(), _AllureReport_qualityGate = new WeakMap(), _AllureReport_stage = new WeakMap(), _AllureReport_stageTempDirs = new WeakMap(), _AllureReport_state = new WeakMap(), _AllureReport_executionStage = new WeakMap(), _AllureReport_update = new WeakMap(), _AllureReport_eachPlugin = new WeakMap(), _AllureReport_instances = new WeakSet(), _AllureReport_publish_get = function _AllureReport_publish_get() {
332
514
  return __classPrivateFieldGet(this, _AllureReport_plugins, "f").some(({ enabled, options }) => enabled && options.publish);
333
515
  }, _AllureReport_getPluginState = function _AllureReport_getPluginState(init, id) {
334
516
  return init ? new DefaultPluginState({}) : __classPrivateFieldGet(this, _AllureReport_state, "f")?.[id];
@@ -1,6 +1,8 @@
1
1
  import { type AllureHistory, type AttachmentLink, type DefaultLabelsConfig, type EnvironmentsConfig, type HistoryDataPoint, type HistoryTestResult, type KnownTestFailure, type RepoData, type ReportVariables, type TestCase, type TestEnvGroup, type TestError, type TestFixtureResult, type TestResult } from "@allurereport/core-api";
2
- import { type AllureStore, type ExitCode, type QualityGateValidationResult, type RealtimeEventsDispatcher, type RealtimeSubscriber, type ResultFile, type TestResultFilter } from "@allurereport/plugin-api";
2
+ import { type AllureStore, type AllureStoreDump, type ExitCode, type QualityGateValidationResult, type RealtimeEventsDispatcher, type RealtimeSubscriber, type ResultFile, type TestResultFilter } from "@allurereport/plugin-api";
3
3
  import type { RawFixtureResult, RawMetadata, RawTestResult, ReaderContext, ResultsVisitor } from "@allurereport/reader-api";
4
+ export declare const mapToObject: <K extends string | number | symbol, T = any>(map: Map<K, T>) => Record<K, T>;
5
+ export declare const mergeMapWithRecord: <K extends string | number | symbol, T = any>(map: Map<K, T>, record: Record<K, T>) => Map<K, T>;
4
6
  export declare class DefaultAllureStore implements AllureStore, ResultsVisitor {
5
7
  #private;
6
8
  readonly indexTestResultByTestCase: Map<string, TestResult[]>;
@@ -16,6 +18,7 @@ export declare class DefaultAllureStore implements AllureStore, ResultsVisitor {
16
18
  realtimeDispatcher?: RealtimeEventsDispatcher;
17
19
  realtimeSubscriber?: RealtimeSubscriber;
18
20
  defaultLabels?: DefaultLabelsConfig;
21
+ environment?: string;
19
22
  environmentsConfig?: EnvironmentsConfig;
20
23
  reportVariables?: ReportVariables;
21
24
  });
@@ -71,4 +74,6 @@ export declare class DefaultAllureStore implements AllureStore, ResultsVisitor {
71
74
  envVariables(env: string): Promise<{
72
75
  [x: string]: string;
73
76
  }>;
77
+ dumpState(): AllureStoreDump;
78
+ restoreState(stateDump: AllureStoreDump, attachmentsContents?: Record<string, ResultFile>): Promise<void>;
74
79
  }
@@ -9,8 +9,8 @@ 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_testResults, _DefaultAllureStore_attachments, _DefaultAllureStore_attachmentContents, _DefaultAllureStore_testCases, _DefaultAllureStore_metadata, _DefaultAllureStore_history, _DefaultAllureStore_known, _DefaultAllureStore_fixtures, _DefaultAllureStore_defaultLabels, _DefaultAllureStore_environmentsConfig, _DefaultAllureStore_reportVariables, _DefaultAllureStore_realtimeDispatcher, _DefaultAllureStore_realtimeSubscriber, _DefaultAllureStore_globalAttachments, _DefaultAllureStore_globalErrors, _DefaultAllureStore_globalExitCode, _DefaultAllureStore_qualityGateResultsByRules, _DefaultAllureStore_historyPoints, _DefaultAllureStore_repoData;
13
- import { compareBy, getWorstStatus, matchEnvironment, nullsLast, ordinal, reverse, } from "@allurereport/core-api";
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_globalAttachments, _DefaultAllureStore_globalErrors, _DefaultAllureStore_globalExitCode, _DefaultAllureStore_qualityGateResultsByRules, _DefaultAllureStore_historyPoints, _DefaultAllureStore_repoData, _DefaultAllureStore_environments, _DefaultAllureStore_addEnvironments;
13
+ import { DEFAULT_ENVIRONMENT, compareBy, getWorstStatus, htrsByTr, matchEnvironment, nullsLast, ordinal, reverse, } from "@allurereport/core-api";
14
14
  import { md5, } from "@allurereport/plugin-api";
15
15
  import { isFlaky } from "../utils/flaky.js";
16
16
  import { getGitBranch, getGitRepoName } from "../utils/git.js";
@@ -26,8 +26,66 @@ const index = (indexMap, key, ...items) => {
26
26
  current.push(...items);
27
27
  }
28
28
  };
29
+ const wasStartedEarlier = (first, second) => first.start === undefined || second.start === undefined || first.start < second.start;
30
+ const hidePreviousAttempt = (state, testResult) => {
31
+ const { environment, historyId } = testResult;
32
+ if (environment) {
33
+ if (!state.has(environment)) {
34
+ state.set(environment, new Map());
35
+ }
36
+ if (historyId) {
37
+ const historyIdToLastAttemptResult = state.get(environment);
38
+ const currentLastAttemptResult = historyIdToLastAttemptResult.get(historyId);
39
+ if (currentLastAttemptResult) {
40
+ if (wasStartedEarlier(currentLastAttemptResult, testResult)) {
41
+ historyIdToLastAttemptResult.set(historyId, testResult);
42
+ currentLastAttemptResult.hidden = true;
43
+ }
44
+ else {
45
+ testResult.hidden = true;
46
+ }
47
+ }
48
+ else {
49
+ historyIdToLastAttemptResult.set(historyId, testResult);
50
+ }
51
+ }
52
+ }
53
+ };
54
+ export const mapToObject = (map) => {
55
+ const result = {};
56
+ map.forEach((value, key) => {
57
+ result[key] = value;
58
+ });
59
+ return result;
60
+ };
61
+ export const mergeMapWithRecord = (map, record) => {
62
+ Object.entries(record).forEach(([key, value]) => {
63
+ const existingValue = map.get(key);
64
+ if (existingValue !== undefined) {
65
+ if (Array.isArray(existingValue) && Array.isArray(value)) {
66
+ map.set(key, [...existingValue, ...value]);
67
+ }
68
+ else if (typeof existingValue === "object" &&
69
+ existingValue !== null &&
70
+ typeof value === "object" &&
71
+ value !== null &&
72
+ !Array.isArray(existingValue) &&
73
+ !Array.isArray(value)) {
74
+ map.set(key, { ...existingValue, ...value });
75
+ }
76
+ else {
77
+ map.set(key, value);
78
+ }
79
+ }
80
+ else {
81
+ map.set(key, value);
82
+ }
83
+ });
84
+ return map;
85
+ };
29
86
  export class DefaultAllureStore {
30
87
  constructor(params) {
88
+ _DefaultAllureStore_instances.add(this);
31
89
  _DefaultAllureStore_testResults.set(this, void 0);
32
90
  _DefaultAllureStore_attachments.set(this, void 0);
33
91
  _DefaultAllureStore_attachmentContents.set(this, void 0);
@@ -37,11 +95,13 @@ export class DefaultAllureStore {
37
95
  _DefaultAllureStore_known.set(this, void 0);
38
96
  _DefaultAllureStore_fixtures.set(this, void 0);
39
97
  _DefaultAllureStore_defaultLabels.set(this, {});
98
+ _DefaultAllureStore_environment.set(this, void 0);
40
99
  _DefaultAllureStore_environmentsConfig.set(this, {});
41
100
  _DefaultAllureStore_reportVariables.set(this, {});
42
101
  _DefaultAllureStore_realtimeDispatcher.set(this, void 0);
43
102
  _DefaultAllureStore_realtimeSubscriber.set(this, void 0);
44
103
  this.indexTestResultByTestCase = new Map();
104
+ this.indexLatestEnvTestResultByHistoryId = new Map();
45
105
  this.indexTestResultByHistoryId = new Map();
46
106
  this.indexAttachmentByTestResult = new Map();
47
107
  this.indexAttachmentByFixture = new Map();
@@ -53,7 +113,11 @@ export class DefaultAllureStore {
53
113
  _DefaultAllureStore_qualityGateResultsByRules.set(this, {});
54
114
  _DefaultAllureStore_historyPoints.set(this, []);
55
115
  _DefaultAllureStore_repoData.set(this, void 0);
56
- const { history, known = [], realtimeDispatcher, realtimeSubscriber, defaultLabels = {}, environmentsConfig = {}, reportVariables = {}, } = params ?? {};
116
+ _DefaultAllureStore_environments.set(this, []);
117
+ const { history, known = [], realtimeDispatcher, realtimeSubscriber, defaultLabels = {}, environment, environmentsConfig = {}, reportVariables = {}, } = params ?? {};
118
+ const environments = Object.keys(environmentsConfig)
119
+ .concat(environment ?? "")
120
+ .filter(Boolean);
57
121
  __classPrivateFieldSet(this, _DefaultAllureStore_testResults, new Map(), "f");
58
122
  __classPrivateFieldSet(this, _DefaultAllureStore_attachments, new Map(), "f");
59
123
  __classPrivateFieldSet(this, _DefaultAllureStore_attachmentContents, new Map(), "f");
@@ -67,13 +131,9 @@ export class DefaultAllureStore {
67
131
  __classPrivateFieldSet(this, _DefaultAllureStore_realtimeSubscriber, realtimeSubscriber, "f");
68
132
  __classPrivateFieldSet(this, _DefaultAllureStore_defaultLabels, defaultLabels, "f");
69
133
  __classPrivateFieldSet(this, _DefaultAllureStore_environmentsConfig, environmentsConfig, "f");
134
+ __classPrivateFieldSet(this, _DefaultAllureStore_environment, environment, "f");
70
135
  __classPrivateFieldSet(this, _DefaultAllureStore_reportVariables, reportVariables, "f");
71
- this.indexLatestEnvTestResultByHistoryId = new Map();
72
- Object.keys(__classPrivateFieldGet(this, _DefaultAllureStore_environmentsConfig, "f"))
73
- .concat("default")
74
- .forEach((key) => {
75
- this.indexLatestEnvTestResultByHistoryId.set(key, new Map());
76
- });
136
+ __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_addEnvironments).call(this, environments);
77
137
  __classPrivateFieldGet(this, _DefaultAllureStore_realtimeSubscriber, "f")?.onQualityGateResults(async (results) => {
78
138
  results.forEach((result) => {
79
139
  __classPrivateFieldGet(this, _DefaultAllureStore_qualityGateResultsByRules, "f")[result.rule] = result;
@@ -164,28 +224,12 @@ export class DefaultAllureStore {
164
224
  }
165
225
  });
166
226
  }
167
- testResult.environment = matchEnvironment(__classPrivateFieldGet(this, _DefaultAllureStore_environmentsConfig, "f"), testResult);
227
+ testResult.environment = __classPrivateFieldGet(this, _DefaultAllureStore_environment, "f") || matchEnvironment(__classPrivateFieldGet(this, _DefaultAllureStore_environmentsConfig, "f"), testResult);
168
228
  const trHistory = await this.historyByTr(testResult);
169
229
  testResult.transition = getStatusTransition(testResult, trHistory);
170
230
  testResult.flaky = isFlaky(testResult, trHistory);
171
231
  __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f").set(testResult.id, testResult);
172
- if (testResult.historyId) {
173
- const maybeOther = this.indexLatestEnvTestResultByHistoryId
174
- .get(testResult.environment)
175
- .get(testResult.historyId);
176
- if (maybeOther) {
177
- if (maybeOther.start === undefined || testResult.start === undefined || maybeOther.start < testResult.start) {
178
- this.indexLatestEnvTestResultByHistoryId.get(testResult.environment).set(testResult.historyId, testResult);
179
- maybeOther.hidden = true;
180
- }
181
- else {
182
- testResult.hidden = true;
183
- }
184
- }
185
- else {
186
- this.indexLatestEnvTestResultByHistoryId.get(testResult.environment).set(testResult.historyId, testResult);
187
- }
188
- }
232
+ hidePreviousAttempt(this.indexLatestEnvTestResultByHistoryId, testResult);
189
233
  index(this.indexTestResultByTestCase, testResult.testCase?.id, testResult);
190
234
  index(this.indexTestResultByHistoryId, testResult.historyId, testResult);
191
235
  index(this.indexAttachmentByTestResult, testResult.id, ...attachmentLinks);
@@ -305,22 +349,7 @@ export class DefaultAllureStore {
305
349
  return tr ? this.retriesByTr(tr) : [];
306
350
  }
307
351
  async historyByTr(tr) {
308
- if (!tr?.historyId) {
309
- return [];
310
- }
311
- return [...__classPrivateFieldGet(this, _DefaultAllureStore_historyPoints, "f")]
312
- .filter((dp) => !!dp.testResults[tr.historyId])
313
- .map((dp) => {
314
- if (!dp.url) {
315
- return dp.testResults[tr.historyId];
316
- }
317
- const url = new URL(dp.url);
318
- url.hash = tr.id;
319
- return {
320
- ...dp.testResults[tr.historyId],
321
- url: url.toString(),
322
- };
323
- });
352
+ return htrsByTr(__classPrivateFieldGet(this, _DefaultAllureStore_historyPoints, "f"), tr);
324
353
  }
325
354
  async historyByTrId(trId) {
326
355
  const tr = await this.testResultById(trId);
@@ -373,7 +402,7 @@ export class DefaultAllureStore {
373
402
  return getTestResultsStats(allWithStats, filter);
374
403
  }
375
404
  async allEnvironments() {
376
- return Array.from(new Set(["default", ...Object.keys(__classPrivateFieldGet(this, _DefaultAllureStore_environmentsConfig, "f"))]));
405
+ return __classPrivateFieldGet(this, _DefaultAllureStore_environments, "f");
377
406
  }
378
407
  async testResultsByEnvironment(env, options = { includeHidden: false }) {
379
408
  const allTrs = await this.allTestResults(options);
@@ -407,7 +436,7 @@ export class DefaultAllureStore {
407
436
  testResultsByEnv: {},
408
437
  };
409
438
  trs.forEach((tr) => {
410
- const env = matchEnvironment(__classPrivateFieldGet(this, _DefaultAllureStore_environmentsConfig, "f"), tr);
439
+ const env = tr.environment || __classPrivateFieldGet(this, _DefaultAllureStore_environment, "f") || matchEnvironment(__classPrivateFieldGet(this, _DefaultAllureStore_environmentsConfig, "f"), tr);
411
440
  envGroup.testResultsByEnv[env] = tr.id;
412
441
  });
413
442
  acc.push(envGroup);
@@ -423,5 +452,145 @@ export class DefaultAllureStore {
423
452
  ...(__classPrivateFieldGet(this, _DefaultAllureStore_environmentsConfig, "f")?.[env]?.variables ?? {}),
424
453
  };
425
454
  }
455
+ dumpState() {
456
+ const storeDump = {
457
+ testResults: mapToObject(__classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f")),
458
+ attachments: mapToObject(__classPrivateFieldGet(this, _DefaultAllureStore_attachments, "f")),
459
+ testCases: mapToObject(__classPrivateFieldGet(this, _DefaultAllureStore_testCases, "f")),
460
+ fixtures: mapToObject(__classPrivateFieldGet(this, _DefaultAllureStore_fixtures, "f")),
461
+ environments: __classPrivateFieldGet(this, _DefaultAllureStore_environments, "f"),
462
+ reportVariables: __classPrivateFieldGet(this, _DefaultAllureStore_reportVariables, "f"),
463
+ globalAttachments: __classPrivateFieldGet(this, _DefaultAllureStore_globalAttachments, "f"),
464
+ globalErrors: __classPrivateFieldGet(this, _DefaultAllureStore_globalErrors, "f"),
465
+ indexLatestEnvTestResultByHistoryId: {},
466
+ indexAttachmentByTestResult: {},
467
+ indexTestResultByHistoryId: {},
468
+ indexTestResultByTestCase: {},
469
+ indexAttachmentByFixture: {},
470
+ indexFixturesByTestResult: {},
471
+ indexKnownByHistoryId: {},
472
+ };
473
+ this.indexLatestEnvTestResultByHistoryId.forEach((envMap) => {
474
+ envMap.forEach((tr, historyId) => {
475
+ storeDump.indexLatestEnvTestResultByHistoryId[historyId] = tr.id;
476
+ });
477
+ });
478
+ this.indexAttachmentByFixture.forEach((link, fxId) => {
479
+ storeDump.indexAttachmentByFixture[fxId] = link.map((l) => l.id);
480
+ });
481
+ this.indexAttachmentByTestResult.forEach((links, trId) => {
482
+ storeDump.indexAttachmentByTestResult[trId] = links.map((l) => l.id);
483
+ });
484
+ this.indexTestResultByHistoryId.forEach((trs, historyId) => {
485
+ storeDump.indexTestResultByHistoryId[historyId] = trs.map((tr) => tr.id);
486
+ });
487
+ this.indexTestResultByTestCase.forEach((trs, tcId) => {
488
+ storeDump.indexTestResultByTestCase[tcId] = trs.map((tr) => tr.id);
489
+ });
490
+ this.indexFixturesByTestResult.forEach((fixtures, trId) => {
491
+ storeDump.indexFixturesByTestResult[trId] = fixtures.map((f) => f.id);
492
+ });
493
+ this.indexKnownByHistoryId.forEach((known, historyId) => {
494
+ storeDump.indexKnownByHistoryId[historyId] = known;
495
+ });
496
+ return storeDump;
497
+ }
498
+ async restoreState(stateDump, attachmentsContents = {}) {
499
+ const { testResults, attachments, testCases, fixtures, reportVariables, environments, globalAttachments = [], globalErrors = [], indexAttachmentByTestResult = {}, indexTestResultByHistoryId = {}, indexTestResultByTestCase = {}, indexLatestEnvTestResultByHistoryId = {}, indexAttachmentByFixture = {}, indexFixturesByTestResult = {}, indexKnownByHistoryId = {}, } = stateDump;
500
+ mergeMapWithRecord(__classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f"), testResults);
501
+ mergeMapWithRecord(__classPrivateFieldGet(this, _DefaultAllureStore_attachments, "f"), attachments);
502
+ mergeMapWithRecord(__classPrivateFieldGet(this, _DefaultAllureStore_testCases, "f"), testCases);
503
+ mergeMapWithRecord(__classPrivateFieldGet(this, _DefaultAllureStore_fixtures, "f"), fixtures);
504
+ mergeMapWithRecord(__classPrivateFieldGet(this, _DefaultAllureStore_attachmentContents, "f"), attachmentsContents);
505
+ __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_addEnvironments).call(this, environments);
506
+ __classPrivateFieldGet(this, _DefaultAllureStore_globalAttachments, "f").push(...globalAttachments);
507
+ __classPrivateFieldGet(this, _DefaultAllureStore_globalErrors, "f").push(...globalErrors);
508
+ Object.assign(__classPrivateFieldGet(this, _DefaultAllureStore_reportVariables, "f"), reportVariables);
509
+ Object.entries(indexAttachmentByTestResult).forEach(([trId, links]) => {
510
+ const attachmentsLinks = links.map((id) => __classPrivateFieldGet(this, _DefaultAllureStore_attachments, "f").get(id)).filter(Boolean);
511
+ if (attachmentsLinks.length === 0) {
512
+ return;
513
+ }
514
+ const existingLinks = this.indexAttachmentByTestResult.get(trId);
515
+ if (!existingLinks) {
516
+ this.indexAttachmentByTestResult.set(trId, attachmentsLinks);
517
+ return;
518
+ }
519
+ existingLinks.push(...attachmentsLinks);
520
+ });
521
+ Object.entries(indexTestResultByHistoryId).forEach(([historyId, trIds]) => {
522
+ const trs = trIds.map((id) => __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f").get(id)).filter(Boolean);
523
+ if (trs.length === 0) {
524
+ return;
525
+ }
526
+ const existingTrs = this.indexTestResultByHistoryId.get(historyId);
527
+ if (!existingTrs) {
528
+ this.indexTestResultByHistoryId.set(historyId, trs);
529
+ return;
530
+ }
531
+ existingTrs.push(...trs);
532
+ });
533
+ Object.entries(indexTestResultByTestCase).forEach(([tcId, trIds]) => {
534
+ const trs = trIds.map((id) => __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f").get(id)).filter(Boolean);
535
+ if (trs.length === 0) {
536
+ return;
537
+ }
538
+ const existingTrs = this.indexTestResultByTestCase.get(tcId);
539
+ if (!existingTrs) {
540
+ this.indexTestResultByTestCase.set(tcId, trs);
541
+ return;
542
+ }
543
+ existingTrs.push(...trs);
544
+ });
545
+ Object.entries(indexAttachmentByFixture).forEach(([fxId, attachmentIds]) => {
546
+ const attachmentsLinks = attachmentIds.map((id) => __classPrivateFieldGet(this, _DefaultAllureStore_attachments, "f").get(id)).filter(Boolean);
547
+ if (attachmentsLinks.length === 0) {
548
+ return;
549
+ }
550
+ const existingLinks = this.indexAttachmentByFixture.get(fxId);
551
+ if (!existingLinks) {
552
+ this.indexAttachmentByFixture.set(fxId, attachmentsLinks);
553
+ return;
554
+ }
555
+ existingLinks.push(...attachmentsLinks);
556
+ });
557
+ Object.entries(indexFixturesByTestResult).forEach(([trId, fixtureIds]) => {
558
+ const fxs = fixtureIds.map((id) => __classPrivateFieldGet(this, _DefaultAllureStore_fixtures, "f").get(id)).filter(Boolean);
559
+ if (fxs.length === 0) {
560
+ return;
561
+ }
562
+ const existingFixtures = this.indexFixturesByTestResult.get(trId);
563
+ if (!existingFixtures) {
564
+ this.indexFixturesByTestResult.set(trId, fxs);
565
+ return;
566
+ }
567
+ existingFixtures.push(...fxs);
568
+ });
569
+ Object.entries(indexKnownByHistoryId).forEach(([historyId, knownFailures]) => {
570
+ const existingKnown = this.indexKnownByHistoryId.get(historyId);
571
+ if (!existingKnown) {
572
+ this.indexKnownByHistoryId.set(historyId, knownFailures);
573
+ return;
574
+ }
575
+ existingKnown.push(...knownFailures);
576
+ });
577
+ Object.values(indexLatestEnvTestResultByHistoryId).forEach((trId) => {
578
+ const tr = __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f").get(trId);
579
+ if (!tr) {
580
+ return;
581
+ }
582
+ hidePreviousAttempt(this.indexLatestEnvTestResultByHistoryId, tr);
583
+ });
584
+ }
426
585
  }
427
- _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_environmentsConfig = new WeakMap(), _DefaultAllureStore_reportVariables = new WeakMap(), _DefaultAllureStore_realtimeDispatcher = new WeakMap(), _DefaultAllureStore_realtimeSubscriber = new WeakMap(), _DefaultAllureStore_globalAttachments = new WeakMap(), _DefaultAllureStore_globalErrors = new WeakMap(), _DefaultAllureStore_globalExitCode = new WeakMap(), _DefaultAllureStore_qualityGateResultsByRules = new WeakMap(), _DefaultAllureStore_historyPoints = new WeakMap(), _DefaultAllureStore_repoData = new WeakMap();
586
+ _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_globalAttachments = new WeakMap(), _DefaultAllureStore_globalErrors = new WeakMap(), _DefaultAllureStore_globalExitCode = new WeakMap(), _DefaultAllureStore_qualityGateResultsByRules = new WeakMap(), _DefaultAllureStore_historyPoints = new WeakMap(), _DefaultAllureStore_repoData = new WeakMap(), _DefaultAllureStore_environments = new WeakMap(), _DefaultAllureStore_instances = new WeakSet(), _DefaultAllureStore_addEnvironments = function _DefaultAllureStore_addEnvironments(envs) {
587
+ if (__classPrivateFieldGet(this, _DefaultAllureStore_environments, "f").length === 0) {
588
+ __classPrivateFieldGet(this, _DefaultAllureStore_environments, "f").push(DEFAULT_ENVIRONMENT);
589
+ }
590
+ __classPrivateFieldSet(this, _DefaultAllureStore_environments, Array.from(new Set([...__classPrivateFieldGet(this, _DefaultAllureStore_environments, "f"), ...envs])), "f");
591
+ envs.forEach((key) => {
592
+ if (!this.indexLatestEnvTestResultByHistoryId.has(key)) {
593
+ this.indexLatestEnvTestResultByHistoryId.set(key, new Map());
594
+ }
595
+ });
596
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allurereport/core",
3
- "version": "3.0.0-beta.18",
3
+ "version": "3.0.0-beta.19",
4
4
  "description": "Collection of generic Allure utilities used across the entire project",
5
5
  "keywords": [
6
6
  "allure"
@@ -25,25 +25,27 @@
25
25
  "test": "vitest run"
26
26
  },
27
27
  "dependencies": {
28
- "@allurereport/ci": "3.0.0-beta.18",
29
- "@allurereport/core-api": "3.0.0-beta.18",
30
- "@allurereport/plugin-allure2": "3.0.0-beta.18",
31
- "@allurereport/plugin-api": "3.0.0-beta.18",
32
- "@allurereport/plugin-awesome": "3.0.0-beta.18",
33
- "@allurereport/plugin-classic": "3.0.0-beta.18",
34
- "@allurereport/plugin-csv": "3.0.0-beta.18",
35
- "@allurereport/plugin-dashboard": "3.0.0-beta.18",
36
- "@allurereport/plugin-log": "3.0.0-beta.18",
37
- "@allurereport/plugin-progress": "3.0.0-beta.18",
38
- "@allurereport/plugin-slack": "3.0.0-beta.18",
39
- "@allurereport/plugin-testplan": "3.0.0-beta.18",
40
- "@allurereport/reader": "3.0.0-beta.18",
41
- "@allurereport/reader-api": "3.0.0-beta.18",
42
- "@allurereport/service": "3.0.0-beta.18",
43
- "@allurereport/summary": "3.0.0-beta.18",
28
+ "@allurereport/ci": "3.0.0-beta.19",
29
+ "@allurereport/core-api": "3.0.0-beta.19",
30
+ "@allurereport/plugin-allure2": "3.0.0-beta.19",
31
+ "@allurereport/plugin-api": "3.0.0-beta.19",
32
+ "@allurereport/plugin-awesome": "3.0.0-beta.19",
33
+ "@allurereport/plugin-classic": "3.0.0-beta.19",
34
+ "@allurereport/plugin-csv": "3.0.0-beta.19",
35
+ "@allurereport/plugin-dashboard": "3.0.0-beta.19",
36
+ "@allurereport/plugin-log": "3.0.0-beta.19",
37
+ "@allurereport/plugin-progress": "3.0.0-beta.19",
38
+ "@allurereport/plugin-slack": "3.0.0-beta.19",
39
+ "@allurereport/plugin-testplan": "3.0.0-beta.19",
40
+ "@allurereport/reader": "3.0.0-beta.19",
41
+ "@allurereport/reader-api": "3.0.0-beta.19",
42
+ "@allurereport/service": "3.0.0-beta.19",
43
+ "@allurereport/summary": "3.0.0-beta.19",
44
44
  "handlebars": "^4.7.8",
45
45
  "markdown-it": "^14.1.0",
46
- "yoctocolors": "^2.1.1"
46
+ "node-stream-zip": "^1.15.0",
47
+ "yoctocolors": "^2.1.1",
48
+ "zip-stream": "^7.0.2"
47
49
  },
48
50
  "devDependencies": {
49
51
  "@stylistic/eslint-plugin": "^2.6.1",
@@ -51,6 +53,7 @@
51
53
  "@types/handlebars": "^4.1.0",
52
54
  "@types/markdown-it": "^14.1.2",
53
55
  "@types/node": "^20.17.9",
56
+ "@types/zip-stream": "^7.0.0",
54
57
  "@typescript-eslint/eslint-plugin": "^8.0.0",
55
58
  "@typescript-eslint/parser": "^8.0.0",
56
59
  "@vitest/runner": "^2.1.9",