hydrateErrors.spec.tsx 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import hydrateErrors from 'sentry/utils/replays/hydrateErrors';
  2. const ONE_DAY_MS = 60 * 60 * 24 * 1000;
  3. describe('hydrateErrors', () => {
  4. const replayRecord = TestStubs.ReplayRecord({started_at: new Date('2023/12/23')});
  5. it('should set the timestamp & offsetMs for each span in the list', () => {
  6. const errors = [
  7. TestStubs.Replay.RawReplayError({timestamp: new Date('2023/12/23')}),
  8. TestStubs.Replay.RawReplayError({timestamp: new Date('2023/12/24')}),
  9. TestStubs.Replay.RawReplayError({timestamp: new Date('2023/12/25')}),
  10. ];
  11. expect(hydrateErrors(replayRecord, errors)).toStrictEqual([
  12. {
  13. category: 'issue',
  14. data: {
  15. eventId: 'e123',
  16. groupId: 3740335939,
  17. groupShortId: 'JS-374',
  18. label: '',
  19. projectSlug: 'javascript',
  20. },
  21. message: 'A Redirect with :orgId param on customer domain',
  22. offsetMs: 0,
  23. timestamp: new Date('2023/12/23'),
  24. timestampMs: 1703307600000,
  25. type: 'error',
  26. },
  27. {
  28. category: 'issue',
  29. data: {
  30. eventId: 'e123',
  31. groupId: 3740335939,
  32. groupShortId: 'JS-374',
  33. label: '',
  34. projectSlug: 'javascript',
  35. },
  36. message: 'A Redirect with :orgId param on customer domain',
  37. offsetMs: ONE_DAY_MS,
  38. timestamp: new Date('2023/12/24'),
  39. timestampMs: 1703307600000 + ONE_DAY_MS,
  40. type: 'error',
  41. },
  42. {
  43. category: 'issue',
  44. data: {
  45. eventId: 'e123',
  46. groupId: 3740335939,
  47. groupShortId: 'JS-374',
  48. label: '',
  49. projectSlug: 'javascript',
  50. },
  51. message: 'A Redirect with :orgId param on customer domain',
  52. offsetMs: ONE_DAY_MS * 2,
  53. timestamp: new Date('2023/12/25'),
  54. timestampMs: 1703307600000 + ONE_DAY_MS * 2,
  55. type: 'error',
  56. },
  57. ]);
  58. });
  59. it('should drop errors that cannot be parsed', () => {
  60. const errors = [{foo: 'bar'}];
  61. // @ts-expect-error: Explicitly test invalid input
  62. expect(hydrateErrors(replayRecord, errors)).toStrictEqual([]);
  63. });
  64. });