teamStability.spec.tsx 1.6 KB

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