utils.spec.tsx 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import {getTitle} from 'sentry/components/replays/breadcrumbs/utils';
  2. import {BreadcrumbLevelType, BreadcrumbType} from 'sentry/types/breadcrumbs';
  3. const crumbs = {
  4. replayInitCrumb: {
  5. type: BreadcrumbType.INIT,
  6. timestamp: new Date().toISOString(),
  7. level: BreadcrumbLevelType.INFO,
  8. message: 'https://example.com',
  9. data: {
  10. action: 'replay-init',
  11. label: 'Start recording',
  12. url: 'https://example.com',
  13. },
  14. },
  15. issueCrumb: {
  16. type: 'error',
  17. level: 'error',
  18. category: 'issue',
  19. message: 'NotFoundError: GET "/organizations/{orgSlug}/replays/1234/" 404',
  20. data: {
  21. label: 'ErrorNotFoundError',
  22. eventId: '0105d6f5a7844125b92824eb89ad1ae0',
  23. groupId: 3913420330,
  24. groupShortId: 'JAVASCRIPT-2DA7',
  25. project: 'javascript',
  26. },
  27. timestamp: '2023-05-01T20:44:20+00:00',
  28. id: 32,
  29. color: 'red300',
  30. description: 'Error',
  31. },
  32. navigation: TestStubs.ReplaySegmentNavigation({})[0].data.payload,
  33. console: TestStubs.ReplaySegmentConsole({})[0].data.payload,
  34. customCrumb: {
  35. timestamp: '2023-05-03T14:17:08.642Z',
  36. type: 'default',
  37. message: 'sending get request',
  38. data: {
  39. fromJs: true,
  40. },
  41. id: 1,
  42. color: 'gray300',
  43. description: 'Default',
  44. level: 'undefined',
  45. },
  46. };
  47. describe('utils', () => {
  48. describe('getTitle', () => {
  49. it.each([
  50. {crumbName: 'replayInitCrumb', expected: 'Start recording'},
  51. {crumbName: 'navigation', expected: 'navigation '},
  52. {crumbName: 'console', expected: 'console '},
  53. {crumbName: 'issueCrumb', expected: 'ErrorNotFoundError'},
  54. {crumbName: 'customCrumb', expected: 'sending get request'},
  55. ])('should return a reasonable title. [$crumbName]', ({crumbName, expected}) => {
  56. expect(getTitle(crumbs[crumbName])).toBe(expected);
  57. });
  58. });
  59. });