teamStability.spec.tsx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import {Organization} from 'sentry-fixture/organization';
  2. import {Project as ProjectFixture} from 'sentry-fixture/project';
  3. import {SessionStatusCountByProjectInPeriod} 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: SessionStatusCountByProjectInPeriod(),
  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 projects={[project]} organization={Organization()} period="2w" />
  19. );
  20. expect(screen.getByText('project-slug')).toBeInTheDocument();
  21. expect(await screen.findAllByText('90%')).toHaveLength(2);
  22. expect(await screen.findByText('0%')).toBeInTheDocument();
  23. expect(sessionsApi).toHaveBeenCalledTimes(2);
  24. });
  25. it('should render no sessions', async () => {
  26. const noSessionProject = ProjectFixture({hasSessions: false, id: '321'});
  27. render(
  28. <TeamStability
  29. projects={[noSessionProject]}
  30. organization={Organization()}
  31. period="7d"
  32. />
  33. );
  34. expect(await screen.findAllByText('\u2014')).toHaveLength(3);
  35. });
  36. it('should render no projects', () => {
  37. render(<TeamStability projects={[]} organization={Organization()} period="7d" />);
  38. expect(
  39. screen.getByText('No projects with release health enabled')
  40. ).toBeInTheDocument();
  41. });
  42. });