index.spec.tsx 2.3 KB

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