import {EventFixture} from 'sentry-fixture/event'; import {ProjectFixture} from 'sentry-fixture/project'; import {RouterContextFixture} from 'sentry-fixture/routerContextFixture'; import {render, screen, userEvent, within} from 'sentry-test/reactTestingLibrary'; import {QueryError} from 'sentry/utils/discover/genericDiscoverQuery'; import { QuickTraceQueryChildrenProps, TraceMeta, } from 'sentry/utils/performance/quickTrace/types'; import QuickTraceMeta from 'sentry/views/performance/transactionDetails/quickTraceMeta'; describe('QuickTraceMeta', function () { const routerContext = RouterContextFixture(); const location = routerContext.context.location; const project = ProjectFixture({platform: 'javascript'}); const event = EventFixture({contexts: {trace: {trace_id: 'a'.repeat(32)}}}); const emptyQuickTrace: QuickTraceQueryChildrenProps = { isLoading: false, error: null, trace: [], type: 'empty', currentEvent: null, }; const emptyTraceMeta: TraceMeta = { projects: 0, transactions: 0, errors: 0, performance_issues: 0, }; it('renders basic UI', function () { render( ); expect(screen.getByRole('heading', {name: 'Trace Navigator'})).toBeInTheDocument(); expect(screen.getByTestId('quick-trace-body')).toBeInTheDocument(); }); it('renders placeholder while loading', function () { render( ); expect(screen.getByRole('heading', {name: 'Trace Navigator'})).toBeInTheDocument(); const qtBody = screen.getByTestId('quick-trace-body'); expect(within(qtBody).getByTestId('loading-placeholder')).toBeInTheDocument(); }); it('renders errors', function () { render( ); expect(screen.getByRole('heading', {name: 'Trace Navigator'})).toBeInTheDocument(); expect(screen.getByTestId('quick-trace-body')).toHaveTextContent('\u2014'); }); it('renders footer', function () { render( ); expect(screen.getByRole('heading', {name: 'Trace Navigator'})).toBeInTheDocument(); expect(screen.getByTestId('quick-trace-body')).toBeInTheDocument(); expect(screen.getByTestId('quick-trace-footer')).toHaveTextContent( `View Full Trace: ${'a'.repeat(8)} (1 event)` ); }); it('renders missing trace when trace id is not present', function () { const newEvent = EventFixture(); render( ); expect(screen.getByRole('heading', {name: 'Trace Navigator'})).toBeInTheDocument(); expect(screen.getByTestId('quick-trace-body')).toHaveTextContent('Missing Trace'); expect(screen.getByTestId('quick-trace-footer')).toHaveTextContent('Read the docs'); }); it('renders missing trace with hover card when feature disabled', async function () { const newEvent = EventFixture(); render( , {context: routerContext} ); expect(screen.getByRole('heading', {name: 'Trace Navigator'})).toBeInTheDocument(); expect(screen.getByTestId('quick-trace-body')).toHaveTextContent('Missing Trace'); const qtFooter = screen.getByTestId('quick-trace-footer'); expect(qtFooter).toHaveTextContent('Read the docs'); const child = qtFooter.firstChild; if (!child) { throw new Error('child is null'); } await userEvent.hover(child as HTMLElement); expect( await screen.findByText('Requires performance monitoring.') ).toBeInTheDocument(); }); it('does not render when platform does not support tracing', function () { const newProject = ProjectFixture(); const newEvent = EventFixture(); const result = render( ); expect(result.container).toBeEmptyDOMElement(); }); });