Skip to content

Commit 7bb6ccf

Browse files
test(trace): Fix highlight wait (iterator stays 1/N while roving)
The search result iterator can remain on the first match index while arrowdown moves the highlighted row, so waiting for a 2/ prefix was incorrect and failed in CI. Allow a longer waitFor in assertHighlightedRowAtIndex for the highlighted-persistence test and raise that known-flake test Jest timeout so slow virtualized updates can finish. Fixes BROWSE-411. Made-with: Cursor
1 parent 5be260a commit 7bb6ccf

File tree

1 file changed

+21
-23
lines changed

1 file changed

+21
-23
lines changed

static/app/views/performance/newTraceDetails/trace.spec.tsx

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -850,20 +850,24 @@ function printVirtualizedList(container: HTMLElement) {
850850

851851
async function assertHighlightedRowAtIndex(
852852
virtualizedContainer: HTMLElement,
853-
index: number
853+
index: number,
854+
options?: {timeout?: number}
854855
) {
855-
await waitFor(() => {
856-
const highlights = virtualizedContainer.querySelectorAll('.TraceRow.Highlight');
857-
expect(highlights).toHaveLength(1);
858-
const highlighted_row = virtualizedContainer.querySelector(
859-
ACTIVE_SEARCH_HIGHLIGHT_ROW
860-
);
861-
expect(highlighted_row).toBeTruthy();
862-
const r = Array.from(
863-
virtualizedContainer.querySelectorAll(VISIBLE_TRACE_ROW_SELECTOR)
864-
);
865-
expect(r.indexOf(highlighted_row!)).toBe(index);
866-
});
856+
await waitFor(
857+
() => {
858+
const highlights = virtualizedContainer.querySelectorAll('.TraceRow.Highlight');
859+
expect(highlights).toHaveLength(1);
860+
const highlighted_row = virtualizedContainer.querySelector(
861+
ACTIVE_SEARCH_HIGHLIGHT_ROW
862+
);
863+
expect(highlighted_row).toBeTruthy();
864+
const r = Array.from(
865+
virtualizedContainer.querySelectorAll(VISIBLE_TRACE_ROW_SELECTOR)
866+
);
867+
expect(r.indexOf(highlighted_row!)).toBe(index);
868+
},
869+
typeof options?.timeout === 'number' ? {timeout: options.timeout} : {}
870+
);
867871
}
868872

869873
describe('trace view', () => {
@@ -1629,23 +1633,16 @@ describe('trace view', () => {
16291633
await searchToResolve();
16301634

16311635
await userEvent.keyboard('{arrowdown}');
1632-
await waitFor(() => {
1633-
const t =
1634-
screen
1635-
.getByTestId('trace-search-result-iterator')
1636-
.textContent?.replace(/\s/g, '') ?? '';
1637-
expect(t).toMatch(/^2\//);
1638-
});
16391636
await searchToResolve();
16401637

1641-
await assertHighlightedRowAtIndex(container, 2);
1638+
await assertHighlightedRowAtIndex(container, 2, {timeout: 10_000});
16421639

16431640
await userEvent.type(searchInput, 'act');
16441641
await waitFor(() => expect(searchInput).toHaveValue('transact'));
16451642
await searchToResolve();
16461643

16471644
// Highlighting is persisted on the row
1648-
await assertHighlightedRowAtIndex(container, 2);
1645+
await assertHighlightedRowAtIndex(container, 2, {timeout: 10_000});
16491646

16501647
await userEvent.clear(searchInput);
16511648
await userEvent.click(searchInput);
@@ -1657,7 +1654,8 @@ describe('trace view', () => {
16571654
await waitFor(() => {
16581655
expect(container.querySelectorAll('.TraceRow.Highlight')).toHaveLength(0);
16591656
});
1660-
}
1657+
},
1658+
28_000
16611659
);
16621660

16631661
it('auto highlights the first result when search begins', async () => {

0 commit comments

Comments
 (0)