teamReleases.spec.tsx 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import {render, screen} from 'sentry-test/reactTestingLibrary';
  2. import TeamReleases from './teamReleases';
  3. describe('TeamReleases', () => {
  4. it('should compare selected past release count with current week', async () => {
  5. const team = TestStubs.Team();
  6. const organization = TestStubs.Organization();
  7. const project = TestStubs.Project({id: 123});
  8. const releaseCountApi = MockApiClient.addMockResponse({
  9. url: `/teams/org-slug/team-slug/release-count/`,
  10. body: TestStubs.TeamReleaseCounts(),
  11. });
  12. render(
  13. <TeamReleases
  14. organization={organization}
  15. projects={[project]}
  16. teamSlug={team.slug}
  17. period="2w"
  18. />
  19. );
  20. expect(screen.getByText('project-slug')).toBeInTheDocument();
  21. expect(await screen.findByText('3')).toBeInTheDocument();
  22. expect(await screen.findByText('2')).toBeInTheDocument();
  23. expect(await screen.findByText('1')).toBeInTheDocument();
  24. expect(releaseCountApi).toHaveBeenCalledTimes(2);
  25. });
  26. it('should render no release counts', async () => {
  27. const team = TestStubs.Team();
  28. const organization = TestStubs.Organization();
  29. const noReleaseProject = TestStubs.Project({id: 321});
  30. render(
  31. <TeamReleases
  32. organization={organization}
  33. projects={[noReleaseProject]}
  34. teamSlug={team.slug}
  35. period="2w"
  36. />
  37. );
  38. expect(await screen.findAllByText('0')).toHaveLength(3);
  39. });
  40. it('should render multiple projects', async () => {
  41. const team = TestStubs.Team();
  42. const organization = TestStubs.Organization();
  43. const projectA = TestStubs.Project({id: 123});
  44. const projectB = TestStubs.Project({id: 234, slug: 'other-project-slug'});
  45. const releaseCountApi = MockApiClient.addMockResponse({
  46. url: `/teams/org-slug/team-slug/release-count/`,
  47. body: TestStubs.TeamReleaseCounts(),
  48. });
  49. render(
  50. <TeamReleases
  51. organization={organization}
  52. projects={[projectA, projectB]}
  53. teamSlug={team.slug}
  54. period="2w"
  55. />
  56. );
  57. expect(screen.getByText('project-slug')).toBeInTheDocument();
  58. expect(screen.getByText('other-project-slug')).toBeInTheDocument();
  59. expect(await screen.findByText('3')).toBeInTheDocument();
  60. expect(await screen.findByText('2')).toBeInTheDocument();
  61. expect(await screen.findByText('1')).toBeInTheDocument();
  62. expect(await screen.findAllByText('4')).toHaveLength(2);
  63. expect(await screen.findByText('0')).toBeInTheDocument();
  64. expect(releaseCountApi).toHaveBeenCalledTimes(2);
  65. });
  66. });