teamStability.spec.tsx 1.8 KB

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