details.spec.tsx 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import {MonitorFixture} from 'sentry-fixture/monitor';
  2. import {initializeOrg} from 'sentry-test/initializeOrg';
  3. import {render, screen} from 'sentry-test/reactTestingLibrary';
  4. import MonitorDetails from 'sentry/views/monitors/details';
  5. describe('Monitor Details', () => {
  6. const monitor = MonitorFixture();
  7. const {organization, project, routerProps} = initializeOrg({
  8. router: {params: {monitorSlug: monitor.slug, projectId: monitor.project.slug}},
  9. });
  10. beforeEach(() => {
  11. MockApiClient.clearMockResponses();
  12. MockApiClient.addMockResponse({
  13. url: `/projects/${organization.slug}/${project.slug}/monitors/${monitor.slug}/`,
  14. body: {...monitor},
  15. });
  16. MockApiClient.addMockResponse({
  17. url: `/organizations/${organization.slug}/users/`,
  18. body: [],
  19. });
  20. MockApiClient.addMockResponse({
  21. url: `/organizations/${organization.slug}/issues/?limit=20&project=${project.id}&query=monitor.slug%3A${monitor.slug}%20environment%3A%5Bproduction%5D%20is%3Aunresolved&statsPeriod=14d`,
  22. body: [],
  23. });
  24. MockApiClient.addMockResponse({
  25. url: `/projects/${organization.slug}/${project.slug}/monitors/${monitor.slug}/stats/`,
  26. body: [],
  27. });
  28. MockApiClient.addMockResponse({
  29. url: `/projects/${organization.slug}/${project.slug}/monitors/${monitor.slug}/checkins/`,
  30. body: [],
  31. });
  32. MockApiClient.addMockResponse({
  33. url: `/projects/${organization.slug}/${project.slug}/monitors/${monitor.slug}/processing-errors/`,
  34. body: [],
  35. });
  36. });
  37. it('renders', async function () {
  38. render(<MonitorDetails {...routerProps} />);
  39. expect(await screen.findByText(monitor.slug, {exact: false})).toBeInTheDocument();
  40. });
  41. it('renders error when monitor is not found', async function () {
  42. MockApiClient.addMockResponse({
  43. url: `/projects/${organization.slug}/${project.slug}/monitors/${monitor.slug}/`,
  44. statusCode: 404,
  45. });
  46. render(<MonitorDetails {...routerProps} />);
  47. expect(
  48. await screen.findByText('The monitor you were looking for was not found.')
  49. ).toBeInTheDocument();
  50. });
  51. });