Skip to content

Commit 6f0604e

Browse files
committed
test: Fix slow test
1 parent 653fa94 commit 6f0604e

3 files changed

Lines changed: 21 additions & 14 deletions

File tree

‎packages/app/src/components/DBTraceWaterfallChart.tsx‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ import {
5353
TimelineMinimap,
5454
type TimelineViewportController,
5555
} from '@/components/TimelineChart';
56+
import {
57+
TRACE_WATERFALL_FETCH_LIMIT,
58+
TRACE_WATERFALL_ROW_LIMIT,
59+
} from '@/components/traceWaterfallLimits';
5660
import useOffsetPaginatedQuery from '@/hooks/useOffsetPaginatedQuery';
5761
import useRowWhere, { WithClause } from '@/hooks/useRowWhere';
5862
import useWaterfallSearchState from '@/hooks/useWaterfallSearchState';
@@ -147,12 +151,6 @@ const SERVICE_COLORS = COLORS.filter(
147151
CATEGORICAL_PALETTE_TOKENS[i] !== 'chart-red',
148152
);
149153

150-
// Per-window (before/after focus date) row cap applied in `getConfig` below.
151-
export const TRACE_WATERFALL_ROW_LIMIT = 50000;
152-
// Fetch one extra row so a window that contains *exactly* the cap is not
153-
// mistaken for truncation. A full page of LIMIT is ambiguous; LIMIT+1 is not.
154-
const TRACE_WATERFALL_FETCH_LIMIT = TRACE_WATERFALL_ROW_LIMIT + 1;
155-
156154
// Stable empty fallback. `data ?? []` would allocate a new array every render
157155
// and invalidate every memo downstream of the waterfall rows.
158156
const EMPTY_ROWS: Record<string, any>[] = [];

‎packages/app/src/components/__tests__/DBTraceWaterfallChart.test.tsx‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,19 @@ import {
1717
DBTraceWaterfallChartContainer,
1818
getDescendantIds,
1919
SpanRow,
20-
TRACE_WATERFALL_ROW_LIMIT,
2120
TraceTotalDurationStat,
2221
useEventsAroundFocus,
2322
} from '@/components/DBTraceWaterfallChart';
2423
import { TimelineChart } from '@/components/TimelineChart';
24+
import { TRACE_WATERFALL_ROW_LIMIT } from '@/components/traceWaterfallLimits';
2525
import useOffsetPaginatedQuery from '@/hooks/useOffsetPaginatedQuery';
2626
import useRowWhere from '@/hooks/useRowWhere';
2727

2828
// Mock setup
29+
jest.mock('@/components/traceWaterfallLimits', () => ({
30+
TRACE_WATERFALL_ROW_LIMIT: 3,
31+
TRACE_WATERFALL_FETCH_LIMIT: 4,
32+
}));
2933
jest.mock('@/components/TimelineChart', () => {
3034
const flattenText = (value: React.ReactNode): string => {
3135
if (value == null || typeof value === 'boolean') {
@@ -52,13 +56,11 @@ jest.mock('@/components/TimelineChart', () => {
5256
return (
5357
<div data-testid="timeline-chart">
5458
TimelineChart
55-
{props.rows
56-
?.slice(0, 20)
57-
.map((row: any) => (
58-
<div key={row.id}>
59-
{row.events?.map((event: any) => flattenText(event.body))}
60-
</div>
61-
))}
59+
{props.rows?.map((row: any) => (
60+
<div key={row.id}>
61+
{row.events?.map((event: any) => flattenText(event.body))}
62+
</div>
63+
))}
6264
</div>
6365
);
6466
};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Per-window (before/after focus date) row cap for the trace waterfall query.
2+
// Kept in its own module so tests can mock it down to a few rows instead of
3+
// rendering 50k spans.
4+
export const TRACE_WATERFALL_ROW_LIMIT = 50000;
5+
// Fetch one extra row so a window that contains *exactly* the cap is not
6+
// mistaken for truncation. A full page of LIMIT is ambiguous; LIMIT+1 is not.
7+
export const TRACE_WATERFALL_FETCH_LIMIT = TRACE_WATERFALL_ROW_LIMIT + 1;

0 commit comments

Comments
 (0)