line.spec.tsx 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. import {render, screen, within} from 'sentry-test/reactTestingLibrary';
  2. import Line from 'sentry/components/events/interfaces/frame/line';
  3. import {Frame} from 'sentry/types';
  4. describe('Frame - Line', function () {
  5. const event = TestStubs.Event();
  6. const data: Frame = {
  7. absPath: null,
  8. colNo: null,
  9. context: [],
  10. errors: null,
  11. filename: null,
  12. function: null,
  13. inApp: false,
  14. instructionAddr: null,
  15. lineNo: null,
  16. module: null,
  17. package: null,
  18. platform: null,
  19. rawFunction: null,
  20. symbol: null,
  21. symbolAddr: null,
  22. trust: null,
  23. vars: null,
  24. };
  25. describe('renderOriginalSourceInfo()', function () {
  26. it('should render the source map information as a HTML string', function () {
  27. const {container} = render(
  28. <Line
  29. data={{
  30. origAbsPath: 'https://beta.getsentry.com/_static/sentry/dist/vendor.js',
  31. mapUrl: 'https://beta.getsentry.com/_static/sentry/dist/vendor.js.map',
  32. map: 'vendor.js.map',
  33. ...data,
  34. }}
  35. registers={{}}
  36. components={[]}
  37. event={event}
  38. />
  39. );
  40. expect(container).toSnapshot();
  41. });
  42. });
  43. describe('renderContext()', () => {
  44. it('should render context lines', () => {
  45. render(
  46. <Line
  47. data={{
  48. ...data,
  49. context: [
  50. [
  51. 211,
  52. ' # Mark the crashed thread and add its stacktrace to the exception',
  53. ],
  54. [212, " crashed_thread = data['threads'][state.requesting_thread]"],
  55. [213, " crashed_thread['crashed'] = True"],
  56. ],
  57. }}
  58. registers={{}}
  59. components={[]}
  60. event={event}
  61. isExpanded
  62. />
  63. );
  64. expect(screen.getByRole('list')).toSnapshot();
  65. });
  66. it('should render register values', () => {
  67. render(
  68. <Line
  69. data={data}
  70. registers={{
  71. r10: '0x00007fff9300bf70',
  72. r11: '0xffffffffffffffff',
  73. r12: '0x0000000000000000',
  74. r13: '0x0000000000000000',
  75. r14: '0x000000000000000a',
  76. r15: '0x0000000000000000',
  77. r8: '0x00007fff9300bf78',
  78. r9: '0x0000000000000040',
  79. rax: '0x00007fff9291e660',
  80. rbp: '0x00007ffedfdff7e0',
  81. rbx: '0x00007fff9291e660',
  82. rcx: '0x0000000000000008',
  83. rdi: '0x00007ffedfdff790',
  84. rdx: '0x0000020000000303',
  85. rip: '0x000000010fe00a59',
  86. rsi: '0x0000000000000300',
  87. rsp: '0x00007ffedfdff7c0',
  88. }}
  89. components={[]}
  90. event={event}
  91. isExpanded
  92. />
  93. );
  94. expect(screen.getByText('Registers')).toBeInTheDocument();
  95. });
  96. it('should not render empty registers', () => {
  97. render(
  98. <Line data={data} registers={{}} components={[]} event={event} isExpanded />
  99. );
  100. expect(screen.queryByText('Registers')).not.toBeInTheDocument();
  101. });
  102. it('should render context vars', () => {
  103. const vars = {
  104. origin: null,
  105. helper: '<sentry.coreapi.MinidumpApiHelper object at 0x10e157ed0>',
  106. self: '<sentry.web.api.MinidumpView object at 0x10e157250>',
  107. args: [],
  108. request: '<WSGIRequest at 0x4531253712>',
  109. content: '[Filtered]',
  110. kwargs: {},
  111. project_id: "u'3'",
  112. };
  113. render(
  114. <Line
  115. data={{...data, vars}}
  116. registers={{}}
  117. components={[]}
  118. event={event}
  119. isExpanded
  120. />
  121. );
  122. for (const [key, value] of Object.entries(vars)) {
  123. const row = screen.getByText(key).closest('tr');
  124. expect(row).toBeTruthy();
  125. if (!row) {
  126. return;
  127. }
  128. const utils = within(row);
  129. expect(utils.getByText(key)).toBeInTheDocument();
  130. if (typeof value !== 'string') {
  131. return;
  132. }
  133. expect(utils.getByText(value)).toBeInTheDocument();
  134. }
  135. });
  136. });
  137. });