@allurereport/plugin-api 3.0.0-beta.8 → 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.
@@ -2,6 +2,8 @@ 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[][];
5
7
  export declare const preciseTreeLabels: <T = TestResult>(labelNames: string[], trs: T[], labelNamesAccessor?: (tr: T) => string[]) => string[];
6
8
  export declare const filterTree: <L, G>(tree: TreeData<L, G>, predicate: (leaf: TreeLeaf<L>) => boolean) => TreeData<L, G>;
7
9
  export declare const sortTree: <L, G>(tree: TreeData<L, G>, comparator: Comparator<TreeLeaf<L>>) => TreeData<L, G>;
@@ -87,6 +87,28 @@ 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
+ };
90
112
  export const preciseTreeLabels = (labelNames, trs, labelNamesAccessor = (tr) => tr.labels.map(({ name }) => name)) => {
91
113
  const result = new Set();
92
114
  for (const labelName of labelNames) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allurereport/plugin-api",
3
- "version": "3.0.0-beta.8",
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.8"
29
+ "@allurereport/core-api": "3.0.0-beta.9"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@stylistic/eslint-plugin": "^2.6.1",