traceLink.spec.tsx 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import {EventFixture} from 'sentry-fixture/event';
  2. import {OrganizationFixture} from 'sentry-fixture/organization';
  3. import {ProjectFixture} from 'sentry-fixture/project';
  4. import {render, screen} from 'sentry-test/reactTestingLibrary';
  5. import ProjectsStore from 'sentry/stores/projectsStore';
  6. import {TraceLink} from './traceLink';
  7. import type {TraceEventResponse} from './useTraceTimelineEvents';
  8. describe('TraceLink', () => {
  9. const organization = OrganizationFixture();
  10. const event = EventFixture({
  11. contexts: {
  12. trace: {
  13. trace_id: '123',
  14. },
  15. },
  16. });
  17. const project = ProjectFixture();
  18. const issuePlatformBody: TraceEventResponse = {
  19. data: [
  20. {
  21. // In issuePlatform, we store the subtitle within the message
  22. message: '/api/slow/ Slow DB Query SELECT "sentry_monitorcheckin"."monitor_id"',
  23. timestamp: '2024-01-24T09:09:03+00:00',
  24. 'issue.id': 1000,
  25. project: project.slug,
  26. 'project.name': project.name,
  27. title: 'Slow DB Query',
  28. id: 'abc',
  29. transaction: '/api/slow/',
  30. culprit: 'foo',
  31. 'event.type': '',
  32. },
  33. ],
  34. meta: {fields: {}, units: {}},
  35. };
  36. const discoverBody: TraceEventResponse = {
  37. data: [
  38. {
  39. timestamp: '2024-01-23T22:11:42+00:00',
  40. 'issue.id': 4909507143,
  41. project: project.slug,
  42. 'project.name': project.name,
  43. title: 'AttributeError: Something Failed',
  44. id: event.id,
  45. transaction: 'important.task',
  46. 'event.type': 'error',
  47. culprit: 'foo',
  48. 'stack.function': [''],
  49. 'error.value': ['foo', 'bar'],
  50. },
  51. ],
  52. meta: {fields: {}, units: {}},
  53. };
  54. beforeEach(() => {
  55. ProjectsStore.loadInitialData([project]);
  56. });
  57. it('renders the number of issues', async () => {
  58. MockApiClient.addMockResponse({
  59. url: `/organizations/${organization.slug}/events/`,
  60. body: issuePlatformBody,
  61. match: [MockApiClient.matchQuery({dataset: 'issuePlatform'})],
  62. });
  63. MockApiClient.addMockResponse({
  64. url: `/organizations/${organization.slug}/events/`,
  65. body: discoverBody,
  66. match: [MockApiClient.matchQuery({dataset: 'discover'})],
  67. });
  68. render(<TraceLink event={event} />, {organization});
  69. expect(await screen.findByText('View Full Trace')).toBeInTheDocument();
  70. });
  71. it('renders no trace available', async () => {
  72. render(<TraceLink event={EventFixture()} />, {organization});
  73. expect(await screen.findByText('No Trace Available')).toBeInTheDocument();
  74. });
  75. });