useReplayData.test.jsx 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. const {mapRRWebAttachments} = require('sentry/utils/replays/hooks/useReplayData');
  2. const testPayload = [
  3. {
  4. type: 3,
  5. data: {
  6. source: 1,
  7. positions: [
  8. {x: 737, y: 553, id: 46, timeOffset: -446},
  9. {x: 655, y: 614, id: 52, timeOffset: -385},
  10. {x: 653, y: 614, id: 52, timeOffset: -285},
  11. {x: 653, y: 613, id: 52, timeOffset: -226},
  12. {x: 653, y: 613, id: 52, timeOffset: -171},
  13. {x: 662, y: 601, id: 50, timeOffset: -105},
  14. {x: 671, y: 591, id: 50, timeOffset: -46},
  15. ],
  16. },
  17. timestamp: 1654290037123,
  18. },
  19. {
  20. type: 3,
  21. data: {
  22. source: 0,
  23. texts: [],
  24. attributes: [],
  25. removes: [],
  26. adds: [
  27. {
  28. parentId: 33,
  29. nextId: null,
  30. node: {
  31. type: 2,
  32. tagName: 'com-1password-button',
  33. attributes: {},
  34. childNodes: [],
  35. id: 65,
  36. },
  37. },
  38. ],
  39. },
  40. timestamp: 1654290037561,
  41. },
  42. {
  43. type: 5,
  44. timestamp: 1654290037.267,
  45. data: {
  46. tag: 'breadcrumb',
  47. payload: {
  48. timestamp: 1654290037.267,
  49. type: 'default',
  50. category: 'ui.click',
  51. message: 'body > div#root > div.App > form',
  52. data: {nodeId: 44},
  53. },
  54. },
  55. },
  56. {
  57. type: 5,
  58. timestamp: 1654290034.2623,
  59. data: {
  60. tag: 'performanceSpan',
  61. payload: {
  62. op: 'navigation.navigate',
  63. description: 'http://localhost:3000/',
  64. startTimestamp: 1654290034.2623,
  65. endTimestamp: 1654290034.5808,
  66. data: {size: 1150},
  67. },
  68. },
  69. },
  70. {
  71. type: 5,
  72. timestamp: 1654290034.2623,
  73. data: {
  74. tag: 'performanceSpan',
  75. payload: {
  76. op: 'navigation.navigate',
  77. description: 'http://localhost:3000/',
  78. startTimestamp: 1654290034.2623,
  79. endTimestamp: 1654290034.5808,
  80. data: {size: 1150},
  81. },
  82. },
  83. },
  84. ];
  85. describe('useReplayData Hooks', () => {
  86. it('t', () => {
  87. const results = mapRRWebAttachments(testPayload);
  88. expect(results.breadcrumbs.length).toBe(1);
  89. expect(results.recording.length).toBe(2);
  90. expect(results.replaySpans.length).toBe(2);
  91. });
  92. });