replayCount.spec.tsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import {render, screen, waitFor} from 'sentry-test/reactTestingLibrary';
  2. import GroupReplayCount from 'sentry/components/group/replayCount';
  3. describe('GroupReplayCount', function () {
  4. const groupId = '3363325111';
  5. const organization = TestStubs.Organization();
  6. it('does not render when a group has no replays', async function () {
  7. MockApiClient.addMockResponse({
  8. url: '/organizations/org-slug/events/',
  9. body: {
  10. meta: {},
  11. data: [],
  12. },
  13. });
  14. const {container} = render(
  15. <GroupReplayCount groupId={groupId} orgId={organization.slug} />
  16. );
  17. expect(screen.getByTestId('loading-placeholder')).toBeInTheDocument();
  18. await waitFor(() => {
  19. expect(container).toBeEmptyDOMElement();
  20. });
  21. });
  22. it('renders the correct replay count', async function () {
  23. MockApiClient.addMockResponse({
  24. url: '/organizations/org-slug/events/',
  25. body: {
  26. meta: {},
  27. data: [
  28. {
  29. id: '123',
  30. 'count()': 1,
  31. },
  32. {
  33. id: '456',
  34. 'count()': 2,
  35. },
  36. ],
  37. },
  38. });
  39. const {container} = render(
  40. <GroupReplayCount groupId={groupId} orgId={organization.slug} />
  41. );
  42. expect(screen.getByTestId('loading-placeholder')).toBeInTheDocument();
  43. await waitFor(() => {
  44. expect(container).not.toBeEmptyDOMElement();
  45. const replayCount = screen.getByTestId('replay-count');
  46. expect(replayCount).toHaveTextContent('2');
  47. expect(replayCount).toHaveAttribute(
  48. 'href',
  49. `/organizations/${organization.slug}/issues/${groupId}/replays/`
  50. );
  51. });
  52. });
  53. });