teamStability.spec.tsx 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import {SessionStatusCountByProjectInPeriod} from 'sentry-fixture/sessions';
  2. import {render, screen} from 'sentry-test/reactTestingLibrary';
  3. import TeamStability from 'sentry/views/organizationStats/teamInsights/teamStability';
  4. describe('TeamStability', () => {
  5. let sessionsApi: jest.Mock;
  6. beforeEach(() => {
  7. MockApiClient.clearMockResponses();
  8. sessionsApi = MockApiClient.addMockResponse({
  9. url: `/organizations/org-slug/sessions/`,
  10. body: SessionStatusCountByProjectInPeriod(),
  11. });
  12. });
  13. it('should compare selected past crash rate with current week', async () => {
  14. const project = TestStubs.Project({hasSessions: true, id: 123});
  15. render(
  16. <TeamStability
  17. projects={[project]}
  18. organization={TestStubs.Organization()}
  19. period="2w"
  20. />
  21. );
  22. expect(screen.getByText('project-slug')).toBeInTheDocument();
  23. expect(await screen.findAllByText('90%')).toHaveLength(2);
  24. expect(await screen.findByText('0%')).toBeInTheDocument();
  25. expect(sessionsApi).toHaveBeenCalledTimes(2);
  26. });
  27. it('should render no sessions', async () => {
  28. const noSessionProject = TestStubs.Project({hasSessions: false, id: 321});
  29. render(
  30. <TeamStability
  31. projects={[noSessionProject]}
  32. organization={TestStubs.Organization()}
  33. period="7d"
  34. />
  35. );
  36. expect(await screen.findAllByText('\u2014')).toHaveLength(3);
  37. });
  38. it('should render no projects', () => {
  39. render(
  40. <TeamStability projects={[]} organization={TestStubs.Organization()} period="7d" />
  41. );
  42. expect(
  43. screen.getByText('No projects with release health enabled')
  44. ).toBeInTheDocument();
  45. });
  46. });