Skip to content

Commit e425d6c

Browse files
test: turns out there were zero items rendered
1 parent cc551ac commit e425d6c

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

static/app/views/explore/logs/content.spec.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {createLogFixtures, initializeLogsTest} from 'sentry-fixture/log';
22
import {ProjectKeysFixture} from 'sentry-fixture/projectKeys';
33
import {TeamFixture} from 'sentry-fixture/team';
44
import {TimeSeriesFixture} from 'sentry-fixture/timeSeries';
5+
import {mockGetBoundingClientRect} from 'sentry-fixture/virtualization';
56

67
import {
78
render,
@@ -21,6 +22,8 @@ import type {OurLogsResponseItem} from 'sentry/views/explore/logs/types';
2122

2223
import LogsPage from './content';
2324

25+
beforeEach(mockGetBoundingClientRect);
26+
2427
describe('LogsPage', () => {
2528
let organization: Organization;
2629
let project: Project;

static/app/views/explore/logs/logsTab.spec.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {initializeLogsTest} from 'sentry-fixture/log';
22
import {TimeSeriesFixture} from 'sentry-fixture/timeSeries';
3+
import {mockGetBoundingClientRect} from 'sentry-fixture/virtualization';
34

45
import {render, screen, userEvent, waitFor} from 'sentry-test/reactTestingLibrary';
56

@@ -28,6 +29,8 @@ const datePageFilterProps: DatePageFilterProps = {
2829
}),
2930
};
3031

32+
beforeEach(mockGetBoundingClientRect);
33+
3134
describe('LogsTabContent', () => {
3235
const {organization, project, setupPageFilters} = initializeLogsTest();
3336

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {OrganizationFixture} from 'sentry-fixture/organization';
2+
import {mockGetBoundingClientRect} from 'sentry-fixture/virtualization';
23

34
import {render, screen} from 'sentry-test/reactTestingLibrary';
45

@@ -18,6 +19,8 @@ function Component({traceSlug}: {traceSlug: string}) {
1819
);
1920
}
2021

22+
beforeEach(mockGetBoundingClientRect);
23+
2124
describe('TraceViewLogsSection', () => {
2225
it('renders empty logs', async () => {
2326
const organization = OrganizationFixture({features: ['ourlogs-enabled']});
@@ -61,7 +64,7 @@ describe('TraceViewLogsSection', () => {
6164

6265
expect(screen.getByTestId('loading-indicator')).toBeInTheDocument();
6366

64-
expect(await screen.findByText(/i am a log/)).toBeInTheDocument();
67+
await screen.findByText(/i am a log/);
6568
expect(mockRequest).toHaveBeenCalledTimes(1);
6669
});
6770
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* Tanstack Virtual renders zero items in the default zero-sized JSDom environment.
3+
* This forces all elements to have a non-zero size to render at least a few rows.
4+
* https://github.com/TanStack/virtual/issues/641
5+
*/
6+
export function mockGetBoundingClientRect() {
7+
Element.prototype.getBoundingClientRect = jest.fn(() => ({
8+
width: 500,
9+
height: 500,
10+
top: 0,
11+
left: 0,
12+
bottom: 0,
13+
right: 0,
14+
x: 0,
15+
y: 0,
16+
toJSON: () => {},
17+
}));
18+
}

0 commit comments

Comments
 (0)