traceLink.spec.tsx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import {EventFixture} from 'sentry-fixture/event';
  2. import {OrganizationFixture} from 'sentry-fixture/organization';
  3. import {ProjectFixture} from 'sentry-fixture/project';
  4. import {UserFixture} from 'sentry-fixture/user';
  5. import {render, screen} from 'sentry-test/reactTestingLibrary';
  6. import ConfigStore from 'sentry/stores/configStore';
  7. import ProjectsStore from 'sentry/stores/projectsStore';
  8. import {TraceLink} from './traceLink';
  9. import type {TraceEventResponse} from './useTraceTimelineEvents';
  10. describe('TraceLink', () => {
  11. const organization = OrganizationFixture({features: ['issues-trace-timeline']});
  12. const event = EventFixture({
  13. contexts: {
  14. trace: {
  15. trace_id: '123',
  16. },
  17. },
  18. });
  19. const project = ProjectFixture();
  20. const issuePlatformBody: TraceEventResponse = {
  21. data: [
  22. {
  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. issue: 'SENTRY-ABC1',
  30. },
  31. ],
  32. meta: {fields: {}, units: {}},
  33. };
  34. const discoverBody: TraceEventResponse = {
  35. data: [
  36. {
  37. timestamp: '2024-01-23T22:11:42+00:00',
  38. 'issue.id': 4909507143,
  39. project: project.slug,
  40. 'project.name': project.name,
  41. title: 'AttributeError: Something Failed',
  42. id: event.id,
  43. issue: 'SENTRY-2EYS',
  44. },
  45. ],
  46. meta: {fields: {}, units: {}},
  47. };
  48. beforeEach(() => {
  49. // Can be removed with issueDetailsNewExperienceQ42023
  50. ProjectsStore.loadInitialData([project]);
  51. ConfigStore.set(
  52. 'user',
  53. UserFixture({
  54. options: {
  55. ...UserFixture().options,
  56. issueDetailsNewExperienceQ42023: true,
  57. },
  58. })
  59. );
  60. });
  61. it('renders the number of issues', async () => {
  62. MockApiClient.addMockResponse({
  63. url: `/organizations/${organization.slug}/events/`,
  64. body: issuePlatformBody,
  65. match: [MockApiClient.matchQuery({dataset: 'issuePlatform'})],
  66. });
  67. MockApiClient.addMockResponse({
  68. url: `/organizations/${organization.slug}/events/`,
  69. body: discoverBody,
  70. match: [MockApiClient.matchQuery({dataset: 'discover'})],
  71. });
  72. render(<TraceLink event={event} />, {organization});
  73. expect(
  74. await screen.findByRole('link', {name: 'View Full Trace (2 issues)'})
  75. ).toBeInTheDocument();
  76. });
  77. });