index.spec.tsx 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import {act, render, screen} from 'sentry-test/reactTestingLibrary';
  2. import ProjectsStore from 'sentry/stores/projectsStore';
  3. import EventDetails from 'sentry/views/performance/transactionDetails';
  4. const alertText =
  5. 'You are viewing a sample transaction. Configure performance to start viewing real transactions.';
  6. describe('EventDetails', () => {
  7. const project = TestStubs.Project();
  8. const organization = TestStubs.Organization({
  9. features: ['performance-view'],
  10. projects: [project],
  11. });
  12. beforeEach(() => {
  13. ProjectsStore.loadInitialData([project]);
  14. MockApiClient.addMockResponse({
  15. url: `/organizations/${organization.slug}/projects/`,
  16. statusCode: 200,
  17. body: [],
  18. });
  19. MockApiClient.addMockResponse({
  20. url: `/projects/${organization.slug}/latest/events/1/grouping-info/`,
  21. statusCode: 200,
  22. body: {},
  23. });
  24. MockApiClient.addMockResponse({
  25. url: `/projects/${organization.slug}/latest/events/1/committers/`,
  26. statusCode: 200,
  27. body: [],
  28. });
  29. });
  30. afterEach(() => {
  31. ProjectsStore.reset();
  32. MockApiClient.clearMockResponses();
  33. });
  34. it('renders alert for sample transaction', async () => {
  35. const event = TestStubs.Event();
  36. event.tags.push({key: 'sample_event', value: 'yes'});
  37. MockApiClient.addMockResponse({
  38. url: `/organizations/${organization.slug}/events/latest/`,
  39. statusCode: 200,
  40. body: {
  41. ...event,
  42. },
  43. });
  44. render(
  45. <EventDetails
  46. {...TestStubs.routeComponentProps({params: {eventSlug: 'latest'}})}
  47. />,
  48. {organization}
  49. );
  50. expect(screen.getByText(alertText)).toBeInTheDocument();
  51. // Expect stores to be updated
  52. await act(tick);
  53. });
  54. it('does not reender alert if already received transaction', async () => {
  55. const event = TestStubs.Event();
  56. MockApiClient.addMockResponse({
  57. url: `/organizations/${organization.slug}/events/latest/`,
  58. statusCode: 200,
  59. body: {
  60. ...event,
  61. },
  62. });
  63. render(
  64. <EventDetails
  65. {...TestStubs.routeComponentProps({params: {eventSlug: 'latest'}})}
  66. />,
  67. {organization}
  68. );
  69. expect(screen.queryByText(alertText)).not.toBeInTheDocument();
  70. // Expect stores to be updated
  71. await act(tick);
  72. });
  73. });