@allurereport/plugin-api 3.14.0 → 3.14.1
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/utils/tree.d.ts +1 -0
- package/dist/utils/tree.js +33 -0
- package/package.json +2 -2
package/dist/utils/tree.d.ts
CHANGED
|
@@ -13,5 +13,6 @@ export declare const processTree: <L, G>(tree: TreeData<L, G>, options: {
|
|
|
13
13
|
export declare const filterTree: <L, G>(tree: TreeData<L, G>, predicate: (leaf: TreeLeaf<L>) => boolean) => TreeData<L, G>;
|
|
14
14
|
export declare const sortTree: <L, G>(tree: TreeData<L, G>, comparator: Comparator<TreeLeaf<L>>) => TreeData<L, G>;
|
|
15
15
|
export declare const transformTree: <L, G>(tree: TreeData<L, G>, transformer: (leaf: TreeLeaf<L>, idx: number) => TreeLeaf<L>) => TreeData<L, G>;
|
|
16
|
+
export declare const collapseTreeGroups: <L, G extends DefaultTreeGroup>(tree: TreeData<L, G>, separator?: string) => TreeData<L, G>;
|
|
16
17
|
export declare const createTreeByTitlePath: <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>;
|
|
17
18
|
export declare const createTreeByLabelsAndTitlePath: <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>;
|
package/dist/utils/tree.js
CHANGED
|
@@ -229,6 +229,39 @@ export const sortTree = (tree, comparator) => {
|
|
|
229
229
|
export const transformTree = (tree, transformer) => {
|
|
230
230
|
return processTree(tree, { transform: transformer });
|
|
231
231
|
};
|
|
232
|
+
const DEFAULT_GROUP_PATH_SEPARATOR = " > ";
|
|
233
|
+
export const collapseTreeGroups = (tree, separator = DEFAULT_GROUP_PATH_SEPARATOR) => {
|
|
234
|
+
const { root } = tree;
|
|
235
|
+
const groupsById = tree.groupsById;
|
|
236
|
+
const visited = new Set();
|
|
237
|
+
const collapseChildren = (node) => {
|
|
238
|
+
node.groups?.forEach((groupId) => {
|
|
239
|
+
if (visited.has(groupId)) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
visited.add(groupId);
|
|
243
|
+
const group = groupsById[groupId];
|
|
244
|
+
if (!group) {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
while (!group.leaves?.length && group.groups?.length === 1) {
|
|
248
|
+
const child = groupsById[group.groups[0]];
|
|
249
|
+
if (!child) {
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
group.name = `${group.name}${separator}${child.name}`;
|
|
253
|
+
group.groups = child.groups;
|
|
254
|
+
group.leaves = child.leaves;
|
|
255
|
+
group.statistic = child.statistic;
|
|
256
|
+
delete groupsById[child.nodeId];
|
|
257
|
+
visited.delete(child.nodeId);
|
|
258
|
+
}
|
|
259
|
+
collapseChildren(group);
|
|
260
|
+
});
|
|
261
|
+
};
|
|
262
|
+
collapseChildren(root);
|
|
263
|
+
return tree;
|
|
264
|
+
};
|
|
232
265
|
export const createTreeByTitlePath = (data, leafFactory, groupFactory, addLeafToGroup = () => { }) => {
|
|
233
266
|
const leafFactoryFn = leafFactory ??
|
|
234
267
|
((tr) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allurereport/plugin-api",
|
|
3
|
-
"version": "3.14.
|
|
3
|
+
"version": "3.14.1",
|
|
4
4
|
"description": "Allure Plugin API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"allure"
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"lint:fix": "oxlint --import-plugin --fix src test features stories"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@allurereport/core-api": "3.14.
|
|
29
|
+
"@allurereport/core-api": "3.14.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/node": "^20",
|