Skip to content

Commit 008722b

Browse files
committed
cherry-pick(#33797): fix(trace): in indexTree check isVisible before adding to result (#33797)
1 parent 1dc8b3c commit 008722b

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

packages/web/src/components/treeView.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,9 @@ function indexTree<T extends TreeItem>(
319319
selectedItem: T | undefined,
320320
expandedItems: Map<string, boolean | undefined>,
321321
autoExpandDepth: number,
322-
isVisible?: (item: T) => boolean): Map<T, TreeItemData> {
322+
isVisible: (item: T) => boolean = () => true): Map<T, TreeItemData> {
323+
if (!isVisible(rootItem))
324+
return new Map();
323325

324326
const result = new Map<T, TreeItemData>();
325327
const temporaryExpanded = new Set<string>();
@@ -328,9 +330,9 @@ function indexTree<T extends TreeItem>(
328330
let lastItem: T | null = null;
329331

330332
const appendChildren = (parent: T, depth: number) => {
331-
if (isVisible && !isVisible(parent))
332-
return;
333333
for (const item of parent.children as T[]) {
334+
if (!isVisible(item))
335+
continue;
334336
const expandState = temporaryExpanded.has(item.id) || expandedItems.get(item.id);
335337
const autoExpandMatches = autoExpandDepth > depth && result.size < 25 && expandState !== false;
336338
const expanded = item.children.length ? expandState ?? autoExpandMatches : undefined;

tests/playwright-test/ui-mode-trace.spec.ts

+24
Original file line numberDiff line numberDiff line change
@@ -307,3 +307,27 @@ test('should show request source context id', async ({ runUITest, server }) => {
307307
await expect(page.getByText('page#2')).toBeVisible();
308308
await expect(page.getByText('api#1')).toBeVisible();
309309
});
310+
311+
test('should filter actions tab on double-click', async ({ runUITest, server }) => {
312+
const { page } = await runUITest({
313+
'a.spec.ts': `
314+
import { test, expect } from '@playwright/test';
315+
test('pass', async ({ page }) => {
316+
await page.goto('${server.EMPTY_PAGE}');
317+
});
318+
`,
319+
});
320+
321+
await page.getByText('pass').dblclick();
322+
323+
const actionsTree = page.getByTestId('actions-tree');
324+
await expect(actionsTree.getByRole('treeitem')).toHaveText([
325+
/Before Hooks/,
326+
/page.goto/,
327+
/After Hooks/,
328+
]);
329+
await actionsTree.getByRole('treeitem', { name: 'page.goto' }).dblclick();
330+
await expect(actionsTree.getByRole('treeitem')).toHaveText([
331+
/page.goto/,
332+
]);
333+
});

0 commit comments

Comments
 (0)