teamStability.spec.tsx 1.6 KB

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