inboxReason.spec.jsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  2. import InboxReason from 'sentry/components/group/inboxBadges/inboxReason';
  3. describe('InboxReason', () => {
  4. let inbox;
  5. beforeEach(() => {
  6. inbox = {
  7. reason: 0,
  8. date_added: new Date(),
  9. reason_details: null,
  10. };
  11. });
  12. it('displays new issue inbox reason', () => {
  13. render(<InboxReason inbox={inbox} />);
  14. expect(screen.getByText('New Issue')).toBeInTheDocument();
  15. });
  16. it('displays time added to inbox', () => {
  17. render(<InboxReason showDateAdded inbox={inbox} />);
  18. // Use a pattern so we can work around slowness between beforeEach and here.
  19. expect(screen.getByText(/\d+(s|ms|m)/i)).toBeInTheDocument();
  20. });
  21. it('has a tooltip', async () => {
  22. render(<InboxReason inbox={inbox} />);
  23. const tag = screen.getByText('New Issue');
  24. userEvent.hover(tag);
  25. expect(
  26. await screen.findByText('Mark Reviewed to remove this label')
  27. ).toBeInTheDocument();
  28. });
  29. it('has affected user count', async () => {
  30. render(
  31. <InboxReason
  32. inbox={{
  33. ...inbox,
  34. reason: 1,
  35. reason_details: {
  36. count: null,
  37. until: null,
  38. user_count: 10,
  39. user_window: null,
  40. window: null,
  41. },
  42. }}
  43. />
  44. );
  45. const tag = screen.getByText('Unignored');
  46. userEvent.hover(tag);
  47. // Text is split up because of translations
  48. expect(await screen.findByText('Affected')).toBeInTheDocument();
  49. expect(screen.getByText('10')).toBeInTheDocument();
  50. expect(screen.getByText('user(s)')).toBeInTheDocument();
  51. });
  52. });