@allurereport/core-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.
@@ -13,4 +13,9 @@ export type Statistic = DiffStatistic & {
13
13
  total: number;
14
14
  retries?: number;
15
15
  flaky?: number;
16
+ resolutions?: {
17
+ issues?: number;
18
+ muted?: number;
19
+ accepted?: number;
20
+ };
16
21
  };
package/dist/config.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export type DefaultLabelsConfig = Record<string, string | string[]>;
2
+ export declare const parseIntegerConfigValue: (value: unknown, minValue?: number) => number | undefined;
2
3
  export type AllureServiceConfig = {
3
4
  accessToken?: string;
4
5
  private?: boolean;
@@ -6,4 +7,4 @@ export type AllureServiceConfig = {
6
7
  uploadMaxAttempts?: number;
7
8
  uploadMaxSimultaneousFailures?: number;
8
9
  };
9
- export type ResolvedAllureServiceConfig = AllureServiceConfig & Required<Pick<AllureServiceConfig, "uploadConcurrency" | "uploadMaxAttempts" | "uploadMaxSimultaneousFailures">>;
10
+ export type ResolvedAllureServiceConfig = AllureServiceConfig & Required<Pick<AllureServiceConfig, "uploadMaxAttempts" | "uploadMaxSimultaneousFailures">>;
package/dist/config.js CHANGED
@@ -1 +1,7 @@
1
- export {};
1
+ export const parseIntegerConfigValue = (value, minValue) => {
2
+ if (typeof value !== "number" || !Number.isFinite(value)) {
3
+ return undefined;
4
+ }
5
+ const normalized = Math.floor(value);
6
+ return minValue === undefined || normalized >= minValue ? normalized : undefined;
7
+ };
package/dist/history.d.ts CHANGED
@@ -24,10 +24,12 @@ export interface HistoryDataPoint {
24
24
  metrics: Record<string, number>;
25
25
  url: string;
26
26
  }
27
+ export type HistoryTestResultUrlResolver = (historyUrl: string, pluginId: string, historicalResultId: string) => string;
27
28
  export interface AllureHistory {
28
29
  readHistory(params?: {
29
30
  repo?: string;
30
31
  branch?: string;
31
32
  }): Promise<HistoryDataPoint[]>;
32
33
  appendHistory(history: HistoryDataPoint): Promise<void>;
34
+ resolveTestResultUrl?: HistoryTestResultUrlResolver;
33
35
  }
package/dist/index.d.ts CHANGED
@@ -6,10 +6,11 @@ export type * from "./environment.js";
6
6
  export type * from "./history.js";
7
7
  export type * from "./resolutions.js";
8
8
  export type * from "./metadata.js";
9
+ export * from "./metrics.js";
9
10
  export type * from "./model.js";
10
11
  export type * from "./testCase.js";
11
12
  export type * from "./testPlan.js";
12
- export type * from "./config.js";
13
+ export * from "./config.js";
13
14
  export * from "./static.js";
14
15
  export * from "./categories.js";
15
16
  export * from "./utils/step.js";
@@ -21,6 +22,7 @@ export * from "./utils/label.js";
21
22
  export * from "./utils/parameter.js";
22
23
  export * from "./utils/testplan.js";
23
24
  export * from "./utils/status.js";
25
+ export * from "./utils/successRate.js";
24
26
  export * from "./utils/environment.js";
25
27
  export * from "./utils/history.js";
26
28
  export * from "./utils/strings.js";
package/dist/index.js CHANGED
@@ -1,6 +1,8 @@
1
1
  export * from "./constants.js";
2
2
  export * from "./ci.js";
3
3
  export * from "./gitFlow.js";
4
+ export * from "./metrics.js";
5
+ export * from "./config.js";
4
6
  export * from "./static.js";
5
7
  export * from "./categories.js";
6
8
  export * from "./utils/step.js";
@@ -11,6 +13,7 @@ export * from "./utils/label.js";
11
13
  export * from "./utils/parameter.js";
12
14
  export * from "./utils/testplan.js";
13
15
  export * from "./utils/status.js";
16
+ export * from "./utils/successRate.js";
14
17
  export * from "./utils/environment.js";
15
18
  export * from "./utils/history.js";
16
19
  export * from "./utils/strings.js";
@@ -0,0 +1,32 @@
1
+ export type MetricBetter = "lower" | "higher" | "neutral";
2
+ export interface PerformanceGroupConfig {
3
+ title: string;
4
+ }
5
+ export interface PerformanceMetricConfig {
6
+ title: string;
7
+ unit: string;
8
+ better: Exclude<MetricBetter, "neutral">;
9
+ group?: string;
10
+ }
11
+ export interface PerformanceConfig {
12
+ groups?: Record<string, PerformanceGroupConfig>;
13
+ metrics?: Record<string, PerformanceMetricConfig>;
14
+ }
15
+ export interface AllurePerformanceResult {
16
+ id: string;
17
+ key: string;
18
+ value: any;
19
+ start: number;
20
+ stop: number;
21
+ }
22
+ export interface MetricSample extends AllurePerformanceResult {
23
+ value: number;
24
+ source?: string;
25
+ title?: string;
26
+ unit?: string;
27
+ group?: string;
28
+ groupTitle?: string;
29
+ better?: MetricBetter;
30
+ }
31
+ export type ResolvableMetric = AllurePerformanceResult & Partial<Pick<MetricSample, "source" | "title" | "unit" | "group" | "groupTitle" | "better">>;
32
+ export declare const resolveMetricSamples: (metrics: readonly ResolvableMetric[], performance?: PerformanceConfig) => MetricSample[];
@@ -0,0 +1,29 @@
1
+ const isValidMetricResult = (metric) => typeof metric.id === "string" &&
2
+ metric.id !== "" &&
3
+ typeof metric.key === "string" &&
4
+ metric.key !== "" &&
5
+ Number.isFinite(metric.start) &&
6
+ Number.isFinite(metric.stop);
7
+ export const resolveMetricSamples = (metrics, performance = {}) => {
8
+ const metricsConfig = performance.metrics ?? {};
9
+ const groupsConfig = performance.groups ?? {};
10
+ return metrics.reduce((acc, metric) => {
11
+ const value = Number.isFinite(metric.value) ? Number(metric.value) : undefined;
12
+ if (value === undefined || !isValidMetricResult(metric)) {
13
+ return acc;
14
+ }
15
+ const metricConfig = metricsConfig[metric.key];
16
+ const group = metricConfig?.group ?? metric.group;
17
+ const groupConfig = group ? groupsConfig[group] : undefined;
18
+ acc.push({
19
+ ...metric,
20
+ value,
21
+ ...(metricConfig?.title ? { title: metricConfig.title } : {}),
22
+ ...(metricConfig?.unit ? { unit: metricConfig.unit } : {}),
23
+ ...(group ? { group } : {}),
24
+ ...(groupConfig?.title ? { groupTitle: groupConfig.title } : {}),
25
+ ...(metricConfig?.better ? { better: metricConfig.better } : {}),
26
+ });
27
+ return acc;
28
+ }, []);
29
+ };
package/dist/model.d.ts CHANGED
@@ -48,7 +48,9 @@ export interface TestResult {
48
48
  duration?: number;
49
49
  flaky: boolean;
50
50
  muted: boolean;
51
+ known: boolean;
51
52
  resolution?: ResolutionCategory;
53
+ resolutionComment?: string;
52
54
  transition?: TestStatusTransition;
53
55
  retryHash?: string;
54
56
  isRetry: boolean;
@@ -9,6 +9,12 @@ const normalizeHistoryTestResults = (testResults) => {
9
9
  }
10
10
  return Object.fromEntries(Object.entries(testResults).filter(([, value]) => isRecord(value)));
11
11
  };
12
+ const normalizeHistoryMetrics = (metrics) => {
13
+ if (!isRecord(metrics)) {
14
+ return {};
15
+ }
16
+ return Object.fromEntries(Object.entries(metrics).filter(([, value]) => Number.isFinite(value)));
17
+ };
12
18
  const parametersCompare = (a, b) => {
13
19
  return (a.name ?? "").localeCompare(b.name ?? "") || (a.value ?? "").localeCompare(b.value ?? "");
14
20
  };
@@ -41,7 +47,7 @@ export const normalizeHistoryDataPoint = (historyDataPoint) => ({
41
47
  ...historyDataPoint,
42
48
  knownTestCaseIds: Array.isArray(historyDataPoint.knownTestCaseIds) ? historyDataPoint.knownTestCaseIds : [],
43
49
  testResults: normalizeHistoryTestResults(historyDataPoint.testResults),
44
- metrics: isRecord(historyDataPoint.metrics) ? historyDataPoint.metrics : {},
50
+ metrics: normalizeHistoryMetrics(historyDataPoint.metrics),
45
51
  url: historyDataPoint.url ?? "",
46
52
  });
47
53
  export const normalizeHistoryDataPointUrls = (historyDataPoint) => {
@@ -0,0 +1,3 @@
1
+ import type { Statistic } from "../aggregate.js";
2
+ export declare const getSuccessRateTotal: (statistic: Partial<Statistic>) => number;
3
+ export declare const getSuccessRate: (statistic: Partial<Statistic>) => number;
@@ -0,0 +1,6 @@
1
+ import { includedInSuccessRate } from "../constants.js";
2
+ export const getSuccessRateTotal = (statistic) => Array.from(includedInSuccessRate).reduce((total, status) => total + (statistic[status] ?? 0), 0);
3
+ export const getSuccessRate = (statistic) => {
4
+ const total = getSuccessRateTotal(statistic);
5
+ return total > 0 ? (statistic.passed ?? 0) / total : 0;
6
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allurereport/core-api",
3
- "version": "3.16.1",
3
+ "version": "3.18.0",
4
4
  "description": "Allure Core API",
5
5
  "keywords": [
6
6
  "allure"