teamReleases.spec.tsx 2.8 KB

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