fix(trace): in `indexTree` check `isVisible` before adding to result (#33797)
This commit is contained in:
parent
a84488edaa
commit
4fb6c4ed4c
|
@ -319,7 +319,9 @@ function indexTree<T extends TreeItem>(
|
||||||
selectedItem: T | undefined,
|
selectedItem: T | undefined,
|
||||||
expandedItems: Map<string, boolean | undefined>,
|
expandedItems: Map<string, boolean | undefined>,
|
||||||
autoExpandDepth: number,
|
autoExpandDepth: number,
|
||||||
isVisible?: (item: T) => boolean): Map<T, TreeItemData> {
|
isVisible: (item: T) => boolean = () => true): Map<T, TreeItemData> {
|
||||||
|
if (!isVisible(rootItem))
|
||||||
|
return new Map();
|
||||||
|
|
||||||
const result = new Map<T, TreeItemData>();
|
const result = new Map<T, TreeItemData>();
|
||||||
const temporaryExpanded = new Set<string>();
|
const temporaryExpanded = new Set<string>();
|
||||||
|
@ -328,9 +330,9 @@ function indexTree<T extends TreeItem>(
|
||||||
let lastItem: T | null = null;
|
let lastItem: T | null = null;
|
||||||
|
|
||||||
const appendChildren = (parent: T, depth: number) => {
|
const appendChildren = (parent: T, depth: number) => {
|
||||||
if (isVisible && !isVisible(parent))
|
|
||||||
return;
|
|
||||||
for (const item of parent.children as T[]) {
|
for (const item of parent.children as T[]) {
|
||||||
|
if (!isVisible(item))
|
||||||
|
continue;
|
||||||
const expandState = temporaryExpanded.has(item.id) || expandedItems.get(item.id);
|
const expandState = temporaryExpanded.has(item.id) || expandedItems.get(item.id);
|
||||||
const autoExpandMatches = autoExpandDepth > depth && result.size < 25 && expandState !== false;
|
const autoExpandMatches = autoExpandDepth > depth && result.size < 25 && expandState !== false;
|
||||||
const expanded = item.children.length ? expandState ?? autoExpandMatches : undefined;
|
const expanded = item.children.length ? expandState ?? autoExpandMatches : undefined;
|
||||||
|
|
|
@ -339,3 +339,27 @@ test('should show request source context id', async ({ runUITest, server }) => {
|
||||||
await expect(page.getByText('page#2')).toBeVisible();
|
await expect(page.getByText('page#2')).toBeVisible();
|
||||||
await expect(page.getByText('api#1')).toBeVisible();
|
await expect(page.getByText('api#1')).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should filter actions tab on double-click', async ({ runUITest, server }) => {
|
||||||
|
const { page } = await runUITest({
|
||||||
|
'a.spec.ts': `
|
||||||
|
import { test, expect } from '@playwright/test';
|
||||||
|
test('pass', async ({ page }) => {
|
||||||
|
await page.goto('${server.EMPTY_PAGE}');
|
||||||
|
});
|
||||||
|
`,
|
||||||
|
});
|
||||||
|
|
||||||
|
await page.getByText('pass').dblclick();
|
||||||
|
|
||||||
|
const actionsTree = page.getByTestId('actions-tree');
|
||||||
|
await expect(actionsTree.getByRole('treeitem')).toHaveText([
|
||||||
|
/Before Hooks/,
|
||||||
|
/page.goto/,
|
||||||
|
/After Hooks/,
|
||||||
|
]);
|
||||||
|
await actionsTree.getByRole('treeitem', { name: 'page.goto' }).dblclick();
|
||||||
|
await expect(actionsTree.getByRole('treeitem')).toHaveText([
|
||||||
|
/page.goto/,
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in New Issue