teamReleases.spec.tsx 2.7 KB

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