Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ const byText = (text?: string): TreeFilter => {
return (
!normalizedText ||
String(child.name).toLowerCase().indexOf(normalizedText) > -1 ||
(typeof child.searchPath === "string" &&
child.searchPath.toLowerCase().indexOf(normalizedText) > -1) ||
Boolean(child.children?.some(byText(normalizedText)))
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,21 +149,25 @@ const createLeafOrderMap = (children: TreeNode[] = []) => {
return new Map(sortedLeaves.map((leaf, index) => [leaf, index + 1]));
};

const normalizeNodes = (children: TreeNode[] = []): TreeNode[] => {
const normalizeNodes = (children: TreeNode[] = [], parentPath = ""): TreeNode[] => {
const leafOrders = createLeafOrderMap(children);

return children.map((child) => {
const searchPath = [parentPath, child.name].filter(Boolean).join(".");

if (!child.children) {
return {
...child,
searchPath,
order: leafOrders.get(child),
};
}

const normalizedChildren = normalizeNodes(child.children);
const normalizedChildren = normalizeNodes(child.children, searchPath);

return {
...child,
searchPath,
children: normalizedChildren,
statistic: calculateStatistic(normalizedChildren),
time: calculateTime(normalizedChildren),
Expand Down
1 change: 1 addition & 0 deletions allure-generator/src/main/javascript/types/report.mts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export type TestResult = {

export type TreeNode = {
name?: string;
searchPath?: string;
uid?: string;
parentUid?: string;
status?: Status;
Expand Down
2 changes: 2 additions & 0 deletions allure-generator/tests/e2e/support/fixtures.mts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export const fixtures = {
packages: {
root: "io.qameta.allure",
className: "PullRequestsWebTest",
methodName: "shouldClosePullRequest",
pathQuery: "qameta.allure.PullRequestsWebTest.shouldClose",
},
widgets: {
behaviors: "Features by stories",
Expand Down
18 changes: 18 additions & 0 deletions allure-generator/tests/e2e/tree.shared.spec.mts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ for (const mode of reportModes) {
await searchInput.fill("tag:sm");
await expect(page.locator(".tree__empty")).toHaveText("There are no items");

await searchInput.fill("allure.PullRequestsWebTest");
await expect(
page.locator(".node__leaf", { hasText: uiDemo.cases.failedPullRequest }),
).toBeVisible();

await searchInput.fill(uiDemo.cases.failedPullRequest);
await expect(
page.locator(".node__leaf", { hasText: uiDemo.cases.failedPullRequest }),
Expand Down Expand Up @@ -133,6 +138,19 @@ for (const mode of reportModes) {
await groupLocator(page, uiDemo.packages.root).locator(":scope > .node__title").click();
await expect(groupLocator(page, uiDemo.packages.className)).toBeVisible();
await expect(page.locator(".tree__download")).toHaveCount(0);

const packagesSearchInput = page.locator(".search__input");
await packagesSearchInput.fill(uiDemo.packages.pathQuery);
await expect(groupLocator(page, uiDemo.packages.className)).toBeVisible();
await expect(
page.locator(".node__leaf", { hasText: uiDemo.packages.methodName }),
).toBeVisible();

await packagesSearchInput.fill(uiDemo.packages.root);
await expect(
page.locator(".node__leaf", { hasText: uiDemo.packages.methodName }),
).toBeVisible();
await packagesSearchInput.fill("");
});

test("collapsed groups stay collapsed when selecting leaves in other groups", async ({
Expand Down
Loading