details.spec.tsx 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import {CheckinProcessingErrorFixture} from 'sentry-fixture/checkinProcessingError';
  2. import {MonitorFixture} from 'sentry-fixture/monitor';
  3. import {initializeOrg} from 'sentry-test/initializeOrg';
  4. import {render, screen} from 'sentry-test/reactTestingLibrary';
  5. import MonitorDetails from 'sentry/views/monitors/details';
  6. describe('Monitor Details', () => {
  7. const monitor = MonitorFixture();
  8. const {organization, project, routerProps} = initializeOrg({
  9. router: {params: {monitorSlug: monitor.slug, projectId: monitor.project.slug}},
  10. });
  11. beforeEach(() => {
  12. MockApiClient.clearMockResponses();
  13. MockApiClient.addMockResponse({
  14. url: `/projects/${organization.slug}/${project.slug}/monitors/${monitor.slug}/`,
  15. body: {...monitor},
  16. });
  17. MockApiClient.addMockResponse({
  18. url: `/organizations/${organization.slug}/users/`,
  19. body: [],
  20. });
  21. MockApiClient.addMockResponse({
  22. url: `/organizations/${organization.slug}/issues/?limit=20&project=${project.id}&query=monitor.slug%3A${monitor.slug}%20environment%3A%5Bproduction%5D%20is%3Aunresolved&statsPeriod=14d`,
  23. body: [],
  24. });
  25. MockApiClient.addMockResponse({
  26. url: `/projects/${organization.slug}/${project.slug}/monitors/${monitor.slug}/stats/`,
  27. body: [],
  28. });
  29. MockApiClient.addMockResponse({
  30. url: `/projects/${organization.slug}/${project.slug}/monitors/${monitor.slug}/checkins/`,
  31. body: [],
  32. });
  33. MockApiClient.addMockResponse({
  34. url: `/projects/${organization.slug}/${project.slug}/monitors/${monitor.slug}/processing-errors/`,
  35. body: [],
  36. });
  37. });
  38. it('renders', async function () {
  39. render(<MonitorDetails {...routerProps} />);
  40. expect(await screen.findByText(monitor.slug, {exact: false})).toBeInTheDocument();
  41. // Doesn't show processing errors
  42. expect(
  43. screen.queryByText(
  44. 'Errors were encountered while ingesting check-ins for this monitor'
  45. )
  46. ).not.toBeInTheDocument();
  47. });
  48. it('renders error when monitor is not found', async function () {
  49. MockApiClient.addMockResponse({
  50. url: `/projects/${organization.slug}/${project.slug}/monitors/${monitor.slug}/`,
  51. statusCode: 404,
  52. });
  53. render(<MonitorDetails {...routerProps} />);
  54. expect(
  55. await screen.findByText('The monitor you were looking for was not found.')
  56. ).toBeInTheDocument();
  57. });
  58. it('shows processing errors when they exist', async function () {
  59. MockApiClient.addMockResponse({
  60. url: `/projects/${organization.slug}/${project.slug}/monitors/${monitor.slug}/processing-errors/`,
  61. body: [CheckinProcessingErrorFixture()],
  62. });
  63. render(<MonitorDetails {...routerProps} />);
  64. expect(
  65. await screen.findByText(
  66. 'Errors were encountered while ingesting check-ins for this monitor'
  67. )
  68. ).toBeInTheDocument();
  69. });
  70. });