teamReleases.spec.tsx 2.8 KB

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