Skip to content

Commit 202a045

Browse files
test(trace): Anchor highlight persistence to the selected transaction op
Visible row index 2 is not always the second search hit, and DOM node identity does not survive re-renders. Click the second .SearchResult row, record the highlighted row TraceOperation text, then assert that text is unchanged after narrowing the query. Fixes BROWSE-411. Made-with: Cursor
1 parent 17a9c54 commit 202a045

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

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

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,7 @@ const DRAWER_TABS_TEST_ID = 'trace-drawer-tab';
779779
const DRAWER_TABS_PIN_BUTTON_TEST_ID = 'trace-drawer-tab-pin-button';
780780
const VISIBLE_TRACE_ROW_SELECTOR = '.TraceRow:not(.Hidden)';
781781
const ACTIVE_SEARCH_HIGHLIGHT_ROW = '.TraceRow.SearchResult.Highlight:not(.Hidden)';
782+
const VISIBLE_SEARCH_RESULT_ROW_SELECTOR = `${VISIBLE_TRACE_ROW_SELECTOR}.SearchResult`;
782783

783784
const searchToResolve = async (): Promise<void> => {
784785
await screen.findByTestId('trace-search-success', undefined, {timeout: 10_000});
@@ -1633,19 +1634,37 @@ describe('trace view', () => {
16331634
await searchToResolve();
16341635

16351636
await waitFor(() => {
1636-
expect(getVirtualizedRows(virtualizedContainer)[2]).toBeTruthy();
1637+
expect(
1638+
virtualizedContainer.querySelectorAll(VISIBLE_SEARCH_RESULT_ROW_SELECTOR)
1639+
.length
1640+
).toBeGreaterThanOrEqual(2);
16371641
});
1638-
await userEvent.click(getVirtualizedRows(virtualizedContainer)[2]!);
1642+
await userEvent.click(
1643+
virtualizedContainer.querySelectorAll(VISIBLE_SEARCH_RESULT_ROW_SELECTOR)[1]!
1644+
);
16391645
await searchToResolve();
16401646

1641-
await assertHighlightedRowAtIndex(virtualizedContainer, 2, {timeout: 10_000});
1647+
let persistedTransactionOp = '';
1648+
await waitFor(() => {
1649+
const active = virtualizedContainer.querySelector(ACTIVE_SEARCH_HIGHLIGHT_ROW);
1650+
expect(active).toBeTruthy();
1651+
persistedTransactionOp = (
1652+
active!.querySelector('.TraceOperation') as HTMLElement
1653+
).textContent!.trim();
1654+
});
16421655

16431656
await userEvent.type(searchInput, 'act');
16441657
await waitFor(() => expect(searchInput).toHaveValue('transact'));
16451658
await searchToResolve();
16461659

16471660
// Highlighting is persisted on the row
1648-
await assertHighlightedRowAtIndex(virtualizedContainer, 2, {timeout: 10_000});
1661+
await waitFor(() => {
1662+
const active = virtualizedContainer.querySelector(ACTIVE_SEARCH_HIGHLIGHT_ROW);
1663+
expect(active).toBeTruthy();
1664+
expect(
1665+
(active!.querySelector('.TraceOperation') as HTMLElement).textContent!.trim()
1666+
).toBe(persistedTransactionOp);
1667+
});
16491668

16501669
await userEvent.clear(searchInput);
16511670
await userEvent.click(searchInput);

0 commit comments

Comments
 (0)