teamIssuesAge.spec.tsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import {GroupFixture} from 'sentry-fixture/group';
  2. import {OrganizationFixture} from 'sentry-fixture/organization';
  3. import {TeamFixture} from 'sentry-fixture/team';
  4. import {render, screen} from 'sentry-test/reactTestingLibrary';
  5. import TeamIssuesAge from 'sentry/views/organizationStats/teamInsights/teamIssuesAge';
  6. describe('TeamIssuesAge', () => {
  7. it('should render graph with table of oldest issues', async () => {
  8. const team = TeamFixture();
  9. const organization = OrganizationFixture();
  10. const timeToResolutionApi = MockApiClient.addMockResponse({
  11. url: `/teams/${organization.slug}/${team.slug}/unresolved-issue-age/`,
  12. body: {
  13. '< 1 hour': 1,
  14. '< 4 hour': 5,
  15. '< 12 hour': 20,
  16. '< 1 day': 80,
  17. '< 1 week': 30,
  18. '< 4 week': 100,
  19. '< 24 week': 50,
  20. '< 1 year': 100,
  21. '> 1 year': 10,
  22. },
  23. });
  24. const issuesApi = MockApiClient.addMockResponse({
  25. url: `/teams/${organization.slug}/${team.slug}/issues/old/`,
  26. body: [GroupFixture()],
  27. });
  28. render(<TeamIssuesAge organization={organization} teamSlug={team.slug} />);
  29. // Title
  30. expect(await screen.findByText('RequestError')).toBeInTheDocument();
  31. // Event count
  32. expect(screen.getByText('327k')).toBeInTheDocument();
  33. // User count
  34. expect(screen.getByText('35k')).toBeInTheDocument();
  35. expect(timeToResolutionApi).toHaveBeenCalledTimes(1);
  36. expect(issuesApi).toHaveBeenCalledTimes(1);
  37. });
  38. });