@allurereport/plugin-api 3.0.0-beta.7 → 3.0.0-beta.9

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,5 +1,6 @@
1
1
  import type { PluginDescriptor } from "./plugin.js";
2
2
  import type { QualityGateConfig } from "./qualityGate.js";
3
+ export type DefaultLabelsConfig = Record<string, string | string[]>;
3
4
  export interface Config {
4
5
  name?: string;
5
6
  output?: string;
@@ -7,5 +8,6 @@ export interface Config {
7
8
  knownIssuesPath?: string;
8
9
  qualityGate?: QualityGateConfig;
9
10
  plugins?: Record<string, PluginDescriptor>;
11
+ defaultLabels?: DefaultLabelsConfig;
10
12
  }
11
13
  export declare const defineConfig: (allureConfig: Config) => Config;
@@ -2,6 +2,9 @@ import { type Comparator, type DefaultTreeGroup, type DefaultTreeLeaf, type Test
2
2
  export declare const byLabels: (item: TestResult, labelNames: string[]) => string[][];
3
3
  export declare const filterTreeLabels: (data: TestResult[], labelNames: string[]) => string[];
4
4
  export declare const createTreeByLabels: <T = TestResult, L = DefaultTreeLeaf, G = DefaultTreeGroup>(data: T[], labelNames: string[], leafFactory?: (item: T) => TreeLeaf<L>, groupFactory?: (parentGroup: string | undefined, groupClassifier: string) => TreeGroup<G>, addLeafToGroup?: (group: TreeGroup<G>, leaf: TreeLeaf<L>) => void) => TreeData<L, G>;
5
+ export declare const createTreeByCategories: <T = TestResult, L = DefaultTreeLeaf, G = DefaultTreeGroup>(data: T[], leafFactory?: (item: T) => TreeLeaf<L>, groupFactory?: (parentGroup: string | undefined, groupClassifier: string) => TreeGroup<G>, addLeafToGroup?: (group: TreeGroup<G>, leaf: TreeLeaf<L>) => void) => TreeData<L, G>;
6
+ export declare const byCategories: (item: TestResult) => string[][];
7
+ export declare const preciseTreeLabels: <T = TestResult>(labelNames: string[], trs: T[], labelNamesAccessor?: (tr: T) => string[]) => string[];
5
8
  export declare const filterTree: <L, G>(tree: TreeData<L, G>, predicate: (leaf: TreeLeaf<L>) => boolean) => TreeData<L, G>;
6
9
  export declare const sortTree: <L, G>(tree: TreeData<L, G>, comparator: Comparator<TreeLeaf<L>>) => TreeData<L, G>;
7
10
  export declare const transformTree: <L, G>(tree: TreeData<L, G>, transformer: (leaf: TreeLeaf<L>, idx: number) => TreeLeaf<L>) => TreeData<L, G>;
@@ -87,6 +87,37 @@ export const createTreeByLabels = (data, labelNames, leafFactory, groupFactory,
87
87
  }));
88
88
  return createTree(data, (item) => byLabels(item, labelNames), leafFactoryFn, groupFactoryFn, addLeafToGroup);
89
89
  };
90
+ export const createTreeByCategories = (data, leafFactory, groupFactory, addLeafToGroup = () => { }) => {
91
+ const leafFactoryFn = leafFactory ??
92
+ ((tr) => {
93
+ const { id, name, status, duration } = tr;
94
+ return {
95
+ nodeId: id,
96
+ name,
97
+ status,
98
+ duration,
99
+ };
100
+ });
101
+ const groupFactoryFn = groupFactory ??
102
+ ((parentId, groupClassifier) => ({
103
+ nodeId: md5((parentId ? `${parentId}.` : "") + groupClassifier),
104
+ name: groupClassifier,
105
+ statistic: emptyStatistic(),
106
+ }));
107
+ return createTree(data, (item) => byCategories(item), leafFactoryFn, groupFactoryFn, addLeafToGroup);
108
+ };
109
+ export const byCategories = (item) => {
110
+ return [item.categories?.map((category) => category.name)];
111
+ };
112
+ export const preciseTreeLabels = (labelNames, trs, labelNamesAccessor = (tr) => tr.labels.map(({ name }) => name)) => {
113
+ const result = new Set();
114
+ for (const labelName of labelNames) {
115
+ if (trs.some((tr) => labelNamesAccessor(tr).includes(labelName))) {
116
+ result.add(labelName);
117
+ }
118
+ }
119
+ return Array.from(result);
120
+ };
90
121
  export const filterTree = (tree, predicate) => {
91
122
  const visitedGroups = new Set();
92
123
  const { root, leavesById, groupsById } = tree;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allurereport/plugin-api",
3
- "version": "3.0.0-beta.7",
3
+ "version": "3.0.0-beta.9",
4
4
  "description": "Allure Plugin API",
5
5
  "keywords": [
6
6
  "allure"
@@ -26,7 +26,7 @@
26
26
  "test": "rimraf ./out && vitest run"
27
27
  },
28
28
  "dependencies": {
29
- "@allurereport/core-api": "3.0.0-beta.7"
29
+ "@allurereport/core-api": "3.0.0-beta.9"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@stylistic/eslint-plugin": "^2.6.1",
@@ -36,7 +36,7 @@
36
36
  "@typescript-eslint/parser": "^8.0.0",
37
37
  "@vitest/runner": "^2.1.8",
38
38
  "@vitest/snapshot": "^2.1.8",
39
- "allure-vitest": "^3.0.7",
39
+ "allure-vitest": "^3.0.9",
40
40
  "eslint": "^8.57.0",
41
41
  "eslint-config-prettier": "^9.1.0",
42
42
  "eslint-plugin-import": "^2.29.1",