traceTimeline.spec.tsx 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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, userEvent} from 'sentry-test/reactTestingLibrary';
  6. import ConfigStore from 'sentry/stores/configStore';
  7. import ProjectsStore from 'sentry/stores/projectsStore';
  8. import {TraceTimeline} from './traceTimeline';
  9. import type {TraceEventResponse} from './useTraceTimelineEvents';
  10. describe('TraceTimeline', () => {
  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 items and highlights the current event', 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(<TraceTimeline event={event} />, {organization});
  73. expect(await screen.findByLabelText('Current Event')).toBeInTheDocument();
  74. await userEvent.hover(screen.getByLabelText('Current Event'));
  75. expect(await screen.findByText('You are here')).toBeInTheDocument();
  76. });
  77. });