releaseStats.spec.tsx 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import {Organization} from 'sentry-fixture/organization';
  2. import {render, screen} from 'sentry-test/reactTestingLibrary';
  3. import GroupReleaseStats from 'sentry/components/group/releaseStats';
  4. describe('GroupReleaseStats', function () {
  5. const organization = Organization();
  6. const project = TestStubs.Project();
  7. const group = TestStubs.Group();
  8. beforeEach(() => {
  9. MockApiClient.addMockResponse({
  10. url: `/organizations/${organization.slug}/issues/${group.id}/first-last-release/`,
  11. body: {firstRelease: group.firstRelease, lastRelease: group.lastRelease},
  12. });
  13. });
  14. const createWrapper = (
  15. props: Partial<React.ComponentProps<typeof GroupReleaseStats>>
  16. ) =>
  17. render(
  18. <GroupReleaseStats
  19. group={group}
  20. project={project}
  21. organization={organization}
  22. allEnvironments={TestStubs.Group()}
  23. environments={[]}
  24. {...props}
  25. />
  26. );
  27. it('renders all environments', function () {
  28. createWrapper({});
  29. expect(screen.getByText('Last 24 Hours')).toBeInTheDocument();
  30. expect(screen.getByText('Last 30 Days')).toBeInTheDocument();
  31. expect(screen.getByText('Last Seen')).toBeInTheDocument();
  32. expect(screen.getByText('First Seen')).toBeInTheDocument();
  33. // Displays counts
  34. expect(screen.getByText('3')).toBeInTheDocument();
  35. expect(screen.getByText('123')).toBeInTheDocument();
  36. });
  37. it('renders specific environments', function () {
  38. createWrapper({environments: TestStubs.Environments()});
  39. expect(screen.getByText('Last 24 Hours')).toBeInTheDocument();
  40. expect(screen.getByText('Last 30 Days')).toBeInTheDocument();
  41. expect(screen.getByText('Last Seen')).toBeInTheDocument();
  42. expect(screen.getByText('First Seen')).toBeInTheDocument();
  43. // Displays counts
  44. expect(screen.getByText('3')).toBeInTheDocument();
  45. expect(screen.getByText('123')).toBeInTheDocument();
  46. });
  47. });