@allurereport/plugin-api 3.16.1 → 3.18.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/config.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { AllureServiceConfig, CategoriesConfig, DefaultLabelsConfig, EnvironmentsConfig, ReportVariables, ResolutionsConfig } from "@allurereport/core-api";
1
+ import type { AllureServiceConfig, CategoriesConfig, DefaultLabelsConfig, EnvironmentsConfig, PerformanceConfig, ReportVariables, ResolutionsConfig } from "@allurereport/core-api";
2
2
  import type { PluginDescriptor } from "./plugin.js";
3
3
  import type { QualityGateConfig } from "./qualityGate.js";
4
4
  export interface Config {
@@ -8,6 +8,7 @@ export interface Config {
8
8
  port?: string;
9
9
  hideLabels?: (string | RegExp)[];
10
10
  historyPath?: string;
11
+ historyBaseUrl?: string;
11
12
  historyLimit?: number;
12
13
  resolutions?: ResolutionsConfig;
13
14
  defaultLabels?: DefaultLabelsConfig;
@@ -19,6 +20,7 @@ export interface Config {
19
20
  plugins?: Record<string, PluginDescriptor>;
20
21
  appendHistory?: boolean;
21
22
  qualityGate?: QualityGateConfig;
23
+ performance?: PerformanceConfig;
22
24
  allureService?: AllureServiceConfig;
23
25
  categories?: CategoriesConfig;
24
26
  globalAttachments?: string[];
package/dist/plugin.d.ts CHANGED
@@ -34,7 +34,7 @@ export interface PluginContext {
34
34
  categories?: CategoryDefinition[];
35
35
  history?: AllureHistory;
36
36
  }
37
- export type TestResultSummary = Pick<TestResult, "id" | "name" | "duration" | "status">;
37
+ export type TestResultSummary = Pick<TestResult, "id" | "name" | "duration" | "environment" | "status">;
38
38
  export interface TestResultRegistry {
39
39
  byId: Record<string, TestResultSummary>;
40
40
  }
@@ -56,6 +56,7 @@ export interface PluginSummary {
56
56
  retryTests?: string[];
57
57
  checks?: SummaryCheckResult[];
58
58
  createdAt?: number;
59
+ filtered?: boolean;
59
60
  meta?: Record<string, any>;
60
61
  }
61
62
  export interface PluginReportFile {
@@ -103,8 +104,15 @@ export interface RealtimeSubscriber {
103
104
  fileName?: string;
104
105
  environment?: string;
105
106
  }) => RealtimeListenerResult): () => void;
107
+ onProcessGlobalAttachment(listener: (payload: {
108
+ attachment: ResultFile;
109
+ fileName?: string;
110
+ environment?: string;
111
+ }) => RealtimeListenerResult): () => void;
106
112
  onGlobalExitCode(listener: (payload: ExitCode) => RealtimeListenerResult): () => void;
107
113
  onGlobalError(listener: (error: PluginGlobalError) => RealtimeListenerResult): () => void;
114
+ onProcessGlobalError(listener: (error: PluginGlobalError) => RealtimeListenerResult): () => void;
115
+ onProcessGlobalsReset(listener: () => RealtimeListenerResult): () => void;
108
116
  onQualityGateResults(listener: (payload: QualityGateValidationResult[]) => RealtimeListenerResult): () => void;
109
117
  onTestResults(listener: (trIds: string[]) => RealtimeListenerResult, options?: BatchOptions): () => void;
110
118
  onTestFixtureResults(listener: (tfrIds: string[]) => RealtimeListenerResult, options?: BatchOptions): () => void;
@@ -112,8 +120,11 @@ export interface RealtimeSubscriber {
112
120
  }
113
121
  export interface RealtimeEventsDispatcher {
114
122
  sendGlobalAttachment(attachment: ResultFile, fileName?: string, environment?: string): void;
123
+ sendProcessGlobalAttachment(attachment: ResultFile, fileName?: string, environment?: string): void;
115
124
  sendGlobalExitCode(payload: ExitCode): void;
116
125
  sendGlobalError(error: PluginGlobalError): void;
126
+ sendProcessGlobalError(error: PluginGlobalError): void;
127
+ sendProcessGlobalsReset(): void;
117
128
  sendQualityGateResults(payload: QualityGateValidationResult[]): void;
118
129
  sendTestResult(trId: string): void;
119
130
  sendTestFixtureResult(tfrId: string): void;
@@ -1,4 +1,4 @@
1
- import type { TestResult } from "@allurereport/core-api";
1
+ import type { MetricSample, TestResult } from "@allurereport/core-api";
2
2
  export type QualityGateValidationResult = {
3
3
  success: boolean;
4
4
  expected: any;
@@ -13,27 +13,38 @@ export type QualityGateRules = Record<string, any> & {
13
13
  fastFail?: boolean;
14
14
  filter?: (tr: TestResult) => boolean;
15
15
  };
16
- export type QualityGateRuleResult = {
16
+ export type QualityGateRuleResult<T = unknown> = {
17
17
  success: boolean;
18
- actual: any;
18
+ actual: T;
19
19
  testResults: string[];
20
20
  };
21
- export interface QualityGateRuleState<T> {
22
- getResult(): T | undefined;
23
- setResult(value: T, testResults: QualityGateRuleResult["testResults"]): void;
21
+ export interface QualityGateRuleState {
22
+ getResult(): unknown;
23
+ setResult(value: unknown, testResults: string[]): void;
24
24
  }
25
- export type QualityGateRule<T = any, K = T> = {
25
+ export type QualityGateMetricHistoryPoint = {
26
+ uuid?: string;
27
+ timestamp?: number;
28
+ metrics?: Record<string, number>;
29
+ };
30
+ export type QualityGateRule<T = unknown, K = T> = {
26
31
  rule: string;
27
32
  message: (payload: {
28
33
  expected: T;
29
- actual: T;
34
+ actual: K;
35
+ }) => string;
36
+ successMessage?: (payload: {
37
+ expected: T;
38
+ actual: K;
30
39
  }) => string;
31
40
  validate: (payload: {
32
41
  expected: T;
33
42
  trs: TestResult[];
34
- state: QualityGateRuleState<K>;
43
+ state: QualityGateRuleState;
44
+ metrics?: MetricSample[];
45
+ previousHistory?: QualityGateMetricHistoryPoint[];
35
46
  environment?: string;
36
- }) => Promise<QualityGateRuleResult>;
47
+ }) => Promise<QualityGateRuleResult<K>>;
37
48
  };
38
49
  export type QualityGateConfig = {
39
50
  rules?: QualityGateRules[];
package/dist/report.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { AttachmentTestStepResult, CiDescriptor, DefaultTreeGroup, HistoryTestResult, TestFixtureResult, TestResult, TestStatus, TestStepResult, TreeData, WithChildren } from "@allurereport/core-api";
1
+ import type { AttachmentTestStepResult, CiDescriptor, DefaultTreeGroup, HistoryTestResult, ResolutionCategory, ResolutionIssue, TestFixtureResult, TestResult, TestStatus, TestStepResult, TreeData, WithChildren } from "@allurereport/core-api";
2
2
  import type { QualityGateValidationResult } from "./qualityGate.js";
3
3
  export type Layout = "base" | "split";
4
4
  export type StepTreeExpansion = "collapsed" | "expand_failed_only" | "expanded";
@@ -34,6 +34,7 @@ export type ReportOptions = {
34
34
  ci?: CiDescriptor;
35
35
  executor?: ReportExecutorInfo;
36
36
  runSummary?: ReportRunSummary;
37
+ runSummaryByEnv?: Record<string, ReportRunSummary>;
37
38
  stepTreeExpansion?: StepTreeExpansion;
38
39
  defaultSortBy?: string;
39
40
  };
@@ -74,19 +75,21 @@ export type ReportTestResult = Omit<TestResult, "runSelector" | "sourceMetadata"
74
75
  retry: boolean;
75
76
  categories?: ReportCategory[];
76
77
  environment?: string | "default";
78
+ resolutionIssue?: ResolutionIssue;
77
79
  tooltips?: Record<string, string>;
78
80
  time?: Record<string, string[]>;
79
81
  extra?: {
80
82
  severity: string;
81
83
  };
82
84
  };
83
- export type ReportTreeLeaf = Pick<ReportTestResult, "duration" | "name" | "start" | "status" | "groupOrder" | "flaky" | "transition" | "retry" | "retriesCount"> & {
85
+ export type ReportTreeLeaf = Pick<ReportTestResult, "duration" | "name" | "start" | "status" | "groupOrder" | "flaky" | "transition" | "retry" | "retriesCount" | "resolution"> & {
84
86
  nodeId: string;
85
87
  id?: string;
86
88
  transitionTooltip?: string;
87
89
  tooltips?: Record<string, string>;
88
90
  tags?: string[];
89
91
  categories?: string[];
92
+ severity?: string;
90
93
  };
91
94
  export type ReportTreeGroup = WithChildren & DefaultTreeGroup & {
92
95
  nodeId: string;
@@ -110,6 +113,20 @@ export type ReportSearchDocument = {
110
113
  statusMessage?: string;
111
114
  links?: string;
112
115
  };
116
+ export type ReportResolutionTestResult = Pick<ReportTreeLeaf, "nodeId" | "id" | "name" | "status" | "duration" | "flaky" | "transition" | "retry" | "retriesCount" | "resolution" | "tooltips"> & {
117
+ groupOrder?: number;
118
+ };
119
+ export type ReportResolutionGroup = {
120
+ id: string;
121
+ resolution: ResolutionCategory;
122
+ name: string;
123
+ comment?: string;
124
+ issue?: ResolutionIssue;
125
+ testResults: ReportResolutionTestResult[];
126
+ };
127
+ export type ReportResolutionCategories = {
128
+ groups: ReportResolutionGroup[];
129
+ };
113
130
  export type ReportRecursiveTree = DefaultTreeGroup & {
114
131
  nodeId: string;
115
132
  leaves: ReportTreeLeaf[];
package/dist/store.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { AllureCheckResult, AttachmentLink, EnvironmentIdentity, GlobalAttachmentLink, HistoryDataPoint, HistoryTestResult, ResolutionIssue, ReportVariables, Statistic, TestCase, TestEnvGroup, TestError, TestFixtureResult, TestResult } from "@allurereport/core-api";
1
+ import type { AllureCheckResult, AttachmentLink, EnvironmentIdentity, GlobalAttachmentLink, HistoryDataPoint, HistoryTestResult, ResolutionIssue, MetricSample, ReportVariables, Statistic, TestCase, TestEnvGroup, TestError, TestFixtureResult, TestResult } from "@allurereport/core-api";
2
2
  import type { ExitCode, PluginGlobalError } from "./plugin.js";
3
3
  import type { QualityGateValidationResult } from "./qualityGate.js";
4
4
  import type { ResultFile } from "./resultFile.js";
@@ -24,6 +24,7 @@ export interface AllureStore {
24
24
  allResolutionIssues: () => Promise<ResolutionIssue[]>;
25
25
  resolutionIssueByTestResultId: (trId: string) => Promise<ResolutionIssue | undefined>;
26
26
  testResultsByResolutionIssueId: (resolutionIssueId: string) => Promise<TestResult[]>;
27
+ allMetrics: () => Promise<MetricSample[]>;
27
28
  allNewTestResults: (filter?: TestResultFilter, history?: HistoryDataPoint[]) => Promise<TestResult[]>;
28
29
  addCheckResult: (result: AllureCheckResult) => Promise<void>;
29
30
  allCheckResults: () => Promise<AllureCheckResult[]>;
@@ -81,6 +82,7 @@ export interface AllureStoreDump {
81
82
  reportVariables: ReportVariables;
82
83
  resolutionIssues: Record<string, ResolutionIssue>;
83
84
  qualityGateResults: QualityGateValidationResult[];
85
+ metrics?: MetricSample[];
84
86
  indexAttachmentByTestResult: Record<string, string[]>;
85
87
  indexTestResultByHistoryId: Record<string, string[]>;
86
88
  indexTestResultByTestCase: Record<string, string[]>;
@@ -107,5 +109,6 @@ export declare enum AllureStoreDumpFiles {
107
109
  IndexAttachmentsByFixture = "index-attachments-by-fixture.json",
108
110
  IndexFixturesByTestResult = "index-fixtures-by-test-result.json",
109
111
  QualityGateResults = "quality-gate-results.json",
110
- TestResultIngestOrder = "test-result-ingest-order.json"
112
+ TestResultIngestOrder = "test-result-ingest-order.json",
113
+ Metrics = "metrics.json"
111
114
  }
package/dist/store.js CHANGED
@@ -18,4 +18,5 @@ export var AllureStoreDumpFiles;
18
18
  AllureStoreDumpFiles["IndexFixturesByTestResult"] = "index-fixtures-by-test-result.json";
19
19
  AllureStoreDumpFiles["QualityGateResults"] = "quality-gate-results.json";
20
20
  AllureStoreDumpFiles["TestResultIngestOrder"] = "test-result-ingest-order.json";
21
+ AllureStoreDumpFiles["Metrics"] = "metrics.json";
21
22
  })(AllureStoreDumpFiles || (AllureStoreDumpFiles = {}));
@@ -4,6 +4,7 @@ import type { AllureStore } from "../store.js";
4
4
  export declare const convertToTestResultSummary: (tr: TestResult) => TestResultSummary;
5
5
  export declare const createTestResultRegistry: (testResults: TestResult[]) => TestResultRegistry;
6
6
  export declare const convertToSummaryCheckResult: (check: AllureCheckResult) => SummaryCheckResult;
7
+ export declare const calculateRunDuration: (testResults: Pick<TestResult, "start" | "stop" | "duration">[]) => number;
7
8
  export declare const createPluginSummary: (params: {
8
9
  filter?: (testResult: TestResult) => boolean;
9
10
  name: string;
@@ -4,6 +4,7 @@ export const convertToTestResultSummary = (tr) => ({
4
4
  name: tr.name,
5
5
  duration: tr.duration,
6
6
  status: tr.status,
7
+ ...(tr.environment ? { environment: tr.environment } : {}),
7
8
  });
8
9
  export const createTestResultRegistry = (testResults) => ({
9
10
  byId: Object.fromEntries(testResults.map((testResult) => [testResult.id, convertToTestResultSummary(testResult)])),
@@ -13,6 +14,23 @@ export const convertToSummaryCheckResult = (check) => ({
13
14
  name: check.name,
14
15
  status: check.status,
15
16
  });
17
+ export const calculateRunDuration = (testResults) => {
18
+ let start = Infinity;
19
+ let stop = -Infinity;
20
+ for (const { start: trStart, stop: trStop } of testResults) {
21
+ if (typeof trStart === "number" &&
22
+ Number.isFinite(trStart) &&
23
+ typeof trStop === "number" &&
24
+ Number.isFinite(trStop)) {
25
+ start = Math.min(start, trStart);
26
+ stop = Math.max(stop, trStop);
27
+ }
28
+ }
29
+ if (Number.isFinite(start) && Number.isFinite(stop)) {
30
+ return Math.max(0, stop - start);
31
+ }
32
+ return testResults.reduce((acc, { duration = 0 }) => acc + duration, 0);
33
+ };
16
34
  export const createPluginSummary = async (params) => {
17
35
  const { name, filter, plugin, store, history, meta } = params;
18
36
  const allChecks = await store.allCheckResults();
@@ -22,7 +40,7 @@ export const createPluginSummary = async (params) => {
22
40
  const retryFlags = await Promise.all(allTrs.map(async (tr) => (await store.retriesByTr(tr)).length > 0));
23
41
  const retryTrs = allTrs.filter((_, index) => retryFlags[index]);
24
42
  const flakyTrs = allTrs.filter((tr) => !!tr?.flaky);
25
- const duration = allTrs.reduce((acc, { duration: trDuration = 0 }) => acc + trDuration, 0);
43
+ const duration = calculateRunDuration(allTrs);
26
44
  const worstStatus = getWorstStatus(allTrs.map(({ status }) => status));
27
45
  const createdAt = allTrs.reduce((acc, { stop }) => Math.max(acc, stop || 0), 0);
28
46
  return {
@@ -35,6 +53,7 @@ export const createPluginSummary = async (params) => {
35
53
  name,
36
54
  duration,
37
55
  createdAt,
56
+ ...(filter ? { filtered: true } : {}),
38
57
  plugin,
39
58
  meta,
40
59
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allurereport/plugin-api",
3
- "version": "3.16.1",
3
+ "version": "3.18.0",
4
4
  "description": "Allure Plugin API",
5
5
  "keywords": [
6
6
  "allure"
@@ -29,7 +29,7 @@
29
29
  "lint:fix": "oxlint --import-plugin --fix src test features stories"
30
30
  },
31
31
  "dependencies": {
32
- "@allurereport/core-api": "3.16.1",
32
+ "@allurereport/core-api": "3.18.0",
33
33
  "tar-stream": "3.1.7"
34
34
  },
35
35
  "devDependencies": {