index.spec.tsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import {render, screen} from 'sentry-test/reactTestingLibrary';
  2. import {QuickTraceContext} from 'sentry/utils/performance/quickTrace/quickTraceContext';
  3. import QuickTrace from 'sentry/views/issueDetails/quickTrace';
  4. describe('IssueQuickTrace', () => {
  5. const defaultProps = {
  6. organization: TestStubs.Organization({features: ['performance-view']}),
  7. event: TestStubs.Event({contexts: {trace: {trace_id: 100}}}),
  8. group: TestStubs.Group(),
  9. location: TestStubs.location(),
  10. };
  11. it('renders nothing without performance-view flag', () => {
  12. const {container} = render(
  13. <QuickTrace {...defaultProps} organization={TestStubs.Organization()} />
  14. );
  15. expect(container).toBeEmptyDOMElement();
  16. });
  17. it('renders nothing if event does not have a trace context', () => {
  18. const {container} = render(
  19. <QuickTrace {...defaultProps} event={TestStubs.Event({contexts: {}})} />
  20. );
  21. expect(container).toBeEmptyDOMElement();
  22. });
  23. it('renders a placeholder if event has a trace context but finds nothing', () => {
  24. MockApiClient.addMockResponse({});
  25. render(
  26. <QuickTraceContext.Provider value={undefined}>
  27. <QuickTrace {...defaultProps} />
  28. </QuickTraceContext.Provider>
  29. );
  30. expect(screen.getByTestId('missing-trace-placeholder')).toBeInTheDocument();
  31. });
  32. });