@allurereport/core 3.0.0-beta.19 → 3.0.0-beta.20
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/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/store/store.d.ts +3 -3
- package/dist/store/store.js +95 -62
- package/package.json +17 -17
- package/dist/utils/stats.d.ts +0 -2
- package/dist/utils/stats.js +0 -22
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ export type * from "./api.js";
|
|
|
2
2
|
export * from "./utils/misc.js";
|
|
3
3
|
export * from "./utils/crypto.js";
|
|
4
4
|
export * from "./utils/path.js";
|
|
5
|
-
export * from "./utils/stats.js";
|
|
6
5
|
export * from "./utils/git.js";
|
|
7
6
|
export * from "./utils/new.js";
|
|
8
7
|
export * from "./utils/flaky.js";
|
package/dist/index.js
CHANGED
package/dist/store/store.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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";
|
|
1
|
+
import { type AllureHistory, type AttachmentLink, type DefaultLabelsConfig, type EnvironmentsConfig, type HistoryDataPoint, type HistoryTestResult, type KnownTestFailure, type RepoData, type ReportVariables, type Statistic, type TestCase, type TestEnvGroup, type TestError, type TestFixtureResult, type TestResult } from "@allurereport/core-api";
|
|
2
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
4
|
export declare const mapToObject: <K extends string | number | symbol, T = any>(map: Map<K, T>) => Record<K, T>;
|
|
5
|
-
export declare const
|
|
5
|
+
export declare const updateMapWithRecord: <K extends string | number | symbol, T = any>(map: Map<K, T>, record: Record<K, T>) => Map<K, T>;
|
|
6
6
|
export declare class DefaultAllureStore implements AllureStore, ResultsVisitor {
|
|
7
7
|
#private;
|
|
8
8
|
readonly indexTestResultByTestCase: Map<string, TestResult[]>;
|
|
@@ -64,7 +64,7 @@ export declare class DefaultAllureStore implements AllureStore, ResultsVisitor {
|
|
|
64
64
|
[x: string]: TestResult[];
|
|
65
65
|
_: TestResult[];
|
|
66
66
|
}>;
|
|
67
|
-
testsStatistic(filter?: TestResultFilter): Promise<
|
|
67
|
+
testsStatistic(filter?: TestResultFilter): Promise<Statistic>;
|
|
68
68
|
allEnvironments(): Promise<string[]>;
|
|
69
69
|
testResultsByEnvironment(env: string, options?: {
|
|
70
70
|
includeHidden: boolean;
|
package/dist/store/store.js
CHANGED
|
@@ -15,7 +15,6 @@ import { md5, } from "@allurereport/plugin-api";
|
|
|
15
15
|
import { isFlaky } from "../utils/flaky.js";
|
|
16
16
|
import { getGitBranch, getGitRepoName } from "../utils/git.js";
|
|
17
17
|
import { getStatusTransition } from "../utils/new.js";
|
|
18
|
-
import { getTestResultsStats } from "../utils/stats.js";
|
|
19
18
|
import { testFixtureResultRawToState, testResultRawToState } from "./convert.js";
|
|
20
19
|
const index = (indexMap, key, ...items) => {
|
|
21
20
|
if (key) {
|
|
@@ -58,28 +57,9 @@ export const mapToObject = (map) => {
|
|
|
58
57
|
});
|
|
59
58
|
return result;
|
|
60
59
|
};
|
|
61
|
-
export const
|
|
60
|
+
export const updateMapWithRecord = (map, record) => {
|
|
62
61
|
Object.entries(record).forEach(([key, value]) => {
|
|
63
|
-
|
|
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
|
-
}
|
|
62
|
+
map.set(key, value);
|
|
83
63
|
});
|
|
84
64
|
return map;
|
|
85
65
|
};
|
|
@@ -281,15 +261,28 @@ export class DefaultAllureStore {
|
|
|
281
261
|
}
|
|
282
262
|
async allTestResults(options = { includeHidden: false }) {
|
|
283
263
|
const { includeHidden } = options;
|
|
284
|
-
const result =
|
|
285
|
-
|
|
264
|
+
const result = [];
|
|
265
|
+
for (const [, tr] of __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f")) {
|
|
266
|
+
if (!includeHidden && tr.hidden) {
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
result.push(tr);
|
|
270
|
+
}
|
|
271
|
+
return result;
|
|
286
272
|
}
|
|
287
273
|
async allAttachments(options = {}) {
|
|
288
274
|
const { includeMissed = false, includeUnused = false } = options;
|
|
289
|
-
const
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
275
|
+
const filteredAttachments = [];
|
|
276
|
+
for (const [, attachment] of __classPrivateFieldGet(this, _DefaultAllureStore_attachments, "f")) {
|
|
277
|
+
if (!includeMissed && attachment.missed) {
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
if (!includeUnused && !attachment.used) {
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
filteredAttachments.push(attachment);
|
|
284
|
+
}
|
|
285
|
+
return filteredAttachments;
|
|
293
286
|
}
|
|
294
287
|
async allMetadata() {
|
|
295
288
|
const result = {};
|
|
@@ -306,14 +299,21 @@ export class DefaultAllureStore {
|
|
|
306
299
|
return __classPrivateFieldGet(this, _DefaultAllureStore_known, "f");
|
|
307
300
|
}
|
|
308
301
|
async allNewTestResults() {
|
|
309
|
-
const
|
|
302
|
+
const newTrs = [];
|
|
310
303
|
const allHistoryDps = await this.allHistoryDataPoints();
|
|
311
|
-
|
|
304
|
+
for (const [, tr] of __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f")) {
|
|
305
|
+
if (tr.hidden) {
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
312
308
|
if (!tr.historyId) {
|
|
313
|
-
|
|
309
|
+
newTrs.push(tr);
|
|
310
|
+
continue;
|
|
314
311
|
}
|
|
315
|
-
|
|
316
|
-
|
|
312
|
+
if (!allHistoryDps.some((dp) => dp.testResults[tr.historyId])) {
|
|
313
|
+
newTrs.push(tr);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return newTrs;
|
|
317
317
|
}
|
|
318
318
|
async testCaseById(tcId) {
|
|
319
319
|
return __classPrivateFieldGet(this, _DefaultAllureStore_testCases, "f").get(tcId);
|
|
@@ -359,8 +359,16 @@ export class DefaultAllureStore {
|
|
|
359
359
|
return this.indexFixturesByTestResult.get(trId) ?? [];
|
|
360
360
|
}
|
|
361
361
|
async failedTestResults() {
|
|
362
|
-
const
|
|
363
|
-
|
|
362
|
+
const failedTrs = [];
|
|
363
|
+
for (const [, tr] of __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f")) {
|
|
364
|
+
if (tr.hidden) {
|
|
365
|
+
continue;
|
|
366
|
+
}
|
|
367
|
+
if (tr.status === "failed" || tr.status === "broken") {
|
|
368
|
+
failedTrs.push(tr);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
return failedTrs;
|
|
364
372
|
}
|
|
365
373
|
async unknownFailedTestResults() {
|
|
366
374
|
const failedTestResults = await this.failedTestResults();
|
|
@@ -374,12 +382,14 @@ export class DefaultAllureStore {
|
|
|
374
382
|
const results = {
|
|
375
383
|
_: [],
|
|
376
384
|
};
|
|
377
|
-
const
|
|
378
|
-
|
|
385
|
+
for (const [, test] of __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f")) {
|
|
386
|
+
if (test.hidden) {
|
|
387
|
+
continue;
|
|
388
|
+
}
|
|
379
389
|
const targetLabels = (test.labels ?? []).filter((label) => label.name === labelName);
|
|
380
390
|
if (targetLabels.length === 0) {
|
|
381
391
|
results._.push(test);
|
|
382
|
-
|
|
392
|
+
continue;
|
|
383
393
|
}
|
|
384
394
|
targetLabels.forEach((label) => {
|
|
385
395
|
if (!results[label.value]) {
|
|
@@ -387,42 +397,65 @@ export class DefaultAllureStore {
|
|
|
387
397
|
}
|
|
388
398
|
results[label.value].push(test);
|
|
389
399
|
});
|
|
390
|
-
}
|
|
400
|
+
}
|
|
391
401
|
return results;
|
|
392
402
|
}
|
|
393
403
|
async testsStatistic(filter) {
|
|
394
|
-
const
|
|
395
|
-
const
|
|
404
|
+
const statistic = { total: 0 };
|
|
405
|
+
for (const [, tr] of __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f")) {
|
|
406
|
+
if (tr.hidden) {
|
|
407
|
+
continue;
|
|
408
|
+
}
|
|
409
|
+
if (filter && !filter(tr)) {
|
|
410
|
+
continue;
|
|
411
|
+
}
|
|
412
|
+
statistic.total++;
|
|
396
413
|
const retries = await this.retriesByTr(tr);
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
414
|
+
if (retries.length > 0) {
|
|
415
|
+
statistic.retries = (statistic.retries ?? 0) + 1;
|
|
416
|
+
}
|
|
417
|
+
if (tr.flaky) {
|
|
418
|
+
statistic.flaky = (statistic.flaky ?? 0) + 1;
|
|
419
|
+
}
|
|
420
|
+
if (tr.transition === "new") {
|
|
421
|
+
statistic.new = (statistic.new ?? 0) + 1;
|
|
422
|
+
}
|
|
423
|
+
if (!statistic[tr.status]) {
|
|
424
|
+
statistic[tr.status] = 0;
|
|
425
|
+
}
|
|
426
|
+
statistic[tr.status]++;
|
|
427
|
+
}
|
|
428
|
+
return statistic;
|
|
403
429
|
}
|
|
404
430
|
async allEnvironments() {
|
|
405
431
|
return __classPrivateFieldGet(this, _DefaultAllureStore_environments, "f");
|
|
406
432
|
}
|
|
407
433
|
async testResultsByEnvironment(env, options = { includeHidden: false }) {
|
|
408
|
-
const
|
|
409
|
-
|
|
434
|
+
const trs = [];
|
|
435
|
+
for (const [, tr] of __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f")) {
|
|
436
|
+
if (!options.includeHidden && tr.hidden) {
|
|
437
|
+
continue;
|
|
438
|
+
}
|
|
439
|
+
if (tr.environment === env) {
|
|
440
|
+
trs.push(tr);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
return trs;
|
|
410
444
|
}
|
|
411
445
|
async allTestEnvGroups() {
|
|
412
|
-
const
|
|
413
|
-
const
|
|
446
|
+
const trByTestCaseId = {};
|
|
447
|
+
for (const [, tr] of __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f")) {
|
|
414
448
|
const testCaseId = tr?.testCase?.id;
|
|
415
449
|
if (!testCaseId) {
|
|
416
|
-
|
|
450
|
+
continue;
|
|
417
451
|
}
|
|
418
|
-
if (
|
|
419
|
-
|
|
452
|
+
if (trByTestCaseId[testCaseId]) {
|
|
453
|
+
trByTestCaseId[testCaseId].push(tr);
|
|
420
454
|
}
|
|
421
455
|
else {
|
|
422
|
-
|
|
456
|
+
trByTestCaseId[testCaseId] = [tr];
|
|
423
457
|
}
|
|
424
|
-
|
|
425
|
-
}, {});
|
|
458
|
+
}
|
|
426
459
|
return Object.entries(trByTestCaseId).reduce((acc, [testCaseId, trs]) => {
|
|
427
460
|
if (trs.length === 0) {
|
|
428
461
|
return acc;
|
|
@@ -497,11 +530,11 @@ export class DefaultAllureStore {
|
|
|
497
530
|
}
|
|
498
531
|
async restoreState(stateDump, attachmentsContents = {}) {
|
|
499
532
|
const { testResults, attachments, testCases, fixtures, reportVariables, environments, globalAttachments = [], globalErrors = [], indexAttachmentByTestResult = {}, indexTestResultByHistoryId = {}, indexTestResultByTestCase = {}, indexLatestEnvTestResultByHistoryId = {}, indexAttachmentByFixture = {}, indexFixturesByTestResult = {}, indexKnownByHistoryId = {}, } = stateDump;
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
533
|
+
updateMapWithRecord(__classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f"), testResults);
|
|
534
|
+
updateMapWithRecord(__classPrivateFieldGet(this, _DefaultAllureStore_attachments, "f"), attachments);
|
|
535
|
+
updateMapWithRecord(__classPrivateFieldGet(this, _DefaultAllureStore_testCases, "f"), testCases);
|
|
536
|
+
updateMapWithRecord(__classPrivateFieldGet(this, _DefaultAllureStore_fixtures, "f"), fixtures);
|
|
537
|
+
updateMapWithRecord(__classPrivateFieldGet(this, _DefaultAllureStore_attachmentContents, "f"), attachmentsContents);
|
|
505
538
|
__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_addEnvironments).call(this, environments);
|
|
506
539
|
__classPrivateFieldGet(this, _DefaultAllureStore_globalAttachments, "f").push(...globalAttachments);
|
|
507
540
|
__classPrivateFieldGet(this, _DefaultAllureStore_globalErrors, "f").push(...globalErrors);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allurereport/core",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.20",
|
|
4
4
|
"description": "Collection of generic Allure utilities used across the entire project",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"allure"
|
|
@@ -25,22 +25,22 @@
|
|
|
25
25
|
"test": "vitest run"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@allurereport/ci": "3.0.0-beta.
|
|
29
|
-
"@allurereport/core-api": "3.0.0-beta.
|
|
30
|
-
"@allurereport/plugin-allure2": "3.0.0-beta.
|
|
31
|
-
"@allurereport/plugin-api": "3.0.0-beta.
|
|
32
|
-
"@allurereport/plugin-awesome": "3.0.0-beta.
|
|
33
|
-
"@allurereport/plugin-classic": "3.0.0-beta.
|
|
34
|
-
"@allurereport/plugin-csv": "3.0.0-beta.
|
|
35
|
-
"@allurereport/plugin-dashboard": "3.0.0-beta.
|
|
36
|
-
"@allurereport/plugin-log": "3.0.0-beta.
|
|
37
|
-
"@allurereport/plugin-progress": "3.0.0-beta.
|
|
38
|
-
"@allurereport/plugin-slack": "3.0.0-beta.
|
|
39
|
-
"@allurereport/plugin-testplan": "3.0.0-beta.
|
|
40
|
-
"@allurereport/reader": "3.0.0-beta.
|
|
41
|
-
"@allurereport/reader-api": "3.0.0-beta.
|
|
42
|
-
"@allurereport/service": "3.0.0-beta.
|
|
43
|
-
"@allurereport/summary": "3.0.0-beta.
|
|
28
|
+
"@allurereport/ci": "3.0.0-beta.20",
|
|
29
|
+
"@allurereport/core-api": "3.0.0-beta.20",
|
|
30
|
+
"@allurereport/plugin-allure2": "3.0.0-beta.20",
|
|
31
|
+
"@allurereport/plugin-api": "3.0.0-beta.20",
|
|
32
|
+
"@allurereport/plugin-awesome": "3.0.0-beta.20",
|
|
33
|
+
"@allurereport/plugin-classic": "3.0.0-beta.20",
|
|
34
|
+
"@allurereport/plugin-csv": "3.0.0-beta.20",
|
|
35
|
+
"@allurereport/plugin-dashboard": "3.0.0-beta.20",
|
|
36
|
+
"@allurereport/plugin-log": "3.0.0-beta.20",
|
|
37
|
+
"@allurereport/plugin-progress": "3.0.0-beta.20",
|
|
38
|
+
"@allurereport/plugin-slack": "3.0.0-beta.20",
|
|
39
|
+
"@allurereport/plugin-testplan": "3.0.0-beta.20",
|
|
40
|
+
"@allurereport/reader": "3.0.0-beta.20",
|
|
41
|
+
"@allurereport/reader-api": "3.0.0-beta.20",
|
|
42
|
+
"@allurereport/service": "3.0.0-beta.20",
|
|
43
|
+
"@allurereport/summary": "3.0.0-beta.20",
|
|
44
44
|
"handlebars": "^4.7.8",
|
|
45
45
|
"markdown-it": "^14.1.0",
|
|
46
46
|
"node-stream-zip": "^1.15.0",
|
package/dist/utils/stats.d.ts
DELETED
package/dist/utils/stats.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export const getTestResultsStats = (trs, filter = () => true) => {
|
|
2
|
-
const trsToProcess = trs.filter(filter);
|
|
3
|
-
return trsToProcess.reduce((acc, tr) => {
|
|
4
|
-
if (filter && !filter(tr)) {
|
|
5
|
-
return acc;
|
|
6
|
-
}
|
|
7
|
-
if (tr.retries && tr.retries?.length > 0) {
|
|
8
|
-
acc.retries = (acc.retries ?? 0) + 1;
|
|
9
|
-
}
|
|
10
|
-
if (tr.flaky) {
|
|
11
|
-
acc.flaky = (acc.flaky ?? 0) + 1;
|
|
12
|
-
}
|
|
13
|
-
if (tr.transition === "new") {
|
|
14
|
-
acc.new = (acc.new ?? 0) + 1;
|
|
15
|
-
}
|
|
16
|
-
if (!acc[tr.status]) {
|
|
17
|
-
acc[tr.status] = 0;
|
|
18
|
-
}
|
|
19
|
-
acc[tr.status]++;
|
|
20
|
-
return acc;
|
|
21
|
-
}, { total: trsToProcess.length });
|
|
22
|
-
};
|