teamReleases.spec.tsx 2.9 KB

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