index.spec.jsx 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import {cleanup, render, screen} from 'sentry-test/reactTestingLibrary';
  2. import ProjectsStore from 'sentry/stores/projectsStore';
  3. import {OrganizationContext} from 'sentry/views/organizationContext';
  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. afterEach(cleanup);
  9. it('renders alert for sample transaction', () => {
  10. const project = TestStubs.Project();
  11. ProjectsStore.loadInitialData([project]);
  12. const organization = TestStubs.Organization({
  13. features: ['performance-view'],
  14. projects: [project],
  15. });
  16. const event = TestStubs.Event();
  17. event.tags.push({key: 'sample_event', value: 'yes'});
  18. const routerContext = TestStubs.routerContext([]);
  19. MockApiClient.addMockResponse({
  20. url: `/organizations/${organization.slug}/events/latest/`,
  21. statusCode: 200,
  22. body: {
  23. ...event,
  24. },
  25. });
  26. render(
  27. <OrganizationContext.Provider value={organization}>
  28. <EventDetails
  29. organization={organization}
  30. params={{orgId: organization.slug, eventSlug: 'latest'}}
  31. location={routerContext.context.location}
  32. />
  33. </OrganizationContext.Provider>
  34. );
  35. expect(screen.getByText(alertText)).toBeInTheDocument();
  36. });
  37. it('does not reender alert if already received transaction', () => {
  38. const project = TestStubs.Project();
  39. ProjectsStore.loadInitialData([project]);
  40. const organization = TestStubs.Organization({
  41. features: ['performance-view'],
  42. projects: [project],
  43. });
  44. const event = TestStubs.Event();
  45. const routerContext = TestStubs.routerContext([]);
  46. MockApiClient.addMockResponse({
  47. url: `/organizations/${organization.slug}/events/latest/`,
  48. statusCode: 200,
  49. body: {
  50. ...event,
  51. },
  52. });
  53. render(
  54. <OrganizationContext.Provider value={organization}>
  55. <EventDetails
  56. organization={organization}
  57. params={{orgId: organization.slug, eventSlug: 'latest'}}
  58. location={routerContext.context.location}
  59. />
  60. </OrganizationContext.Provider>
  61. );
  62. expect(screen.queryByText(alertText)).not.toBeInTheDocument();
  63. });
  64. });