@allurereport/plugin-api
Advanced tools
@@ -5,2 +5,4 @@ import { type Comparator, type DefaultTreeGroup, type DefaultTreeLeaf, type TestResult, type TreeData, type TreeGroup, type TreeLeaf } from "@allurereport/core-api"; | ||
| 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>; | ||
| 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>; | ||
| export declare const byCategories: (item: TestResult) => string[][]; | ||
| export declare const preciseTreeLabels: <T = TestResult>(labelNames: string[], trs: T[], labelNamesAccessor?: (tr: T) => string[]) => string[]; | ||
@@ -7,0 +9,0 @@ export declare const filterTree: <L, G>(tree: TreeData<L, G>, predicate: (leaf: TreeLeaf<L>) => boolean) => TreeData<L, G>; |
+22
-0
@@ -90,2 +90,24 @@ import { findByLabelName, } from "@allurereport/core-api"; | ||
| }; | ||
| export const createTreeByCategories = (data, leafFactory, groupFactory, addLeafToGroup = () => { }) => { | ||
| const leafFactoryFn = leafFactory ?? | ||
| ((tr) => { | ||
| const { id, name, status, duration } = tr; | ||
| return { | ||
| nodeId: id, | ||
| name, | ||
| status, | ||
| duration, | ||
| }; | ||
| }); | ||
| const groupFactoryFn = groupFactory ?? | ||
| ((parentId, groupClassifier) => ({ | ||
| nodeId: md5((parentId ? `${parentId}.` : "") + groupClassifier), | ||
| name: groupClassifier, | ||
| statistic: emptyStatistic(), | ||
| })); | ||
| return createTree(data, (item) => byCategories(item), leafFactoryFn, groupFactoryFn, addLeafToGroup); | ||
| }; | ||
| export const byCategories = (item) => { | ||
| return [item.categories?.map((category) => category.name)]; | ||
| }; | ||
| export const preciseTreeLabels = (labelNames, trs, labelNamesAccessor = (tr) => tr.labels.map(({ name }) => name)) => { | ||
@@ -92,0 +114,0 @@ const result = new Set(); |
+2
-2
| { | ||
| "name": "@allurereport/plugin-api", | ||
| "version": "3.0.0-beta.8", | ||
| "version": "3.0.0-beta.9", | ||
| "description": "Allure Plugin API", | ||
@@ -29,3 +29,3 @@ "keywords": [ | ||
| "dependencies": { | ||
| "@allurereport/core-api": "3.0.0-beta.8" | ||
| "@allurereport/core-api": "3.0.0-beta.9" | ||
| }, | ||
@@ -32,0 +32,0 @@ "devDependencies": { |
17456
7.63%364
7.37%+ Added
- Removed