index.spec.tsx 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  2. import {textWithMarkupMatcher} from 'sentry-test/utils';
  3. import EventExtraData from 'sentry/components/events/eventExtraData';
  4. describe('EventExtraData', function () {
  5. it('display redacted data', async function () {
  6. const event = {
  7. ...TestStubs.Event(),
  8. context: {
  9. 'sys.argv': ['', '', '', '', '', '', '', '', '', ''],
  10. sdk: {
  11. clientIP: '127.0.0.1',
  12. version: '3.16.1',
  13. name: 'raven-js',
  14. upstream: {
  15. url: 'https://docs.sentry.io/clients/javascript/',
  16. isNewer: '\n',
  17. },
  18. },
  19. },
  20. _meta: {
  21. context: {
  22. 'sys.argv': {
  23. '0': {
  24. '': {
  25. rem: [['organization:2', 's', 0, 0]],
  26. len: 49,
  27. chunks: [
  28. {
  29. type: 'redaction',
  30. text: '',
  31. rule_id: 'organization:2',
  32. remark: 's',
  33. },
  34. ],
  35. },
  36. },
  37. '1': {
  38. '': {
  39. rem: [['organization:2', 's', 0, 0]],
  40. len: 17,
  41. chunks: [
  42. {
  43. type: 'redaction',
  44. text: '',
  45. rule_id: 'organization:2',
  46. remark: 's',
  47. },
  48. ],
  49. },
  50. },
  51. '2': {
  52. '': {
  53. rem: [['organization:2', 's', 0, 0]],
  54. len: 12,
  55. chunks: [
  56. {
  57. type: 'redaction',
  58. text: '',
  59. rule_id: 'organization:2',
  60. remark: 's',
  61. },
  62. ],
  63. },
  64. },
  65. '3': {
  66. '': {
  67. rem: [['organization:2', 's', 0, 0]],
  68. len: 8,
  69. chunks: [
  70. {
  71. type: 'redaction',
  72. text: '',
  73. rule_id: 'organization:2',
  74. remark: 's',
  75. },
  76. ],
  77. },
  78. },
  79. '4': {
  80. '': {
  81. rem: [['organization:2', 's', 0, 0]],
  82. len: 30,
  83. chunks: [
  84. {
  85. type: 'redaction',
  86. text: '',
  87. rule_id: 'organization:2',
  88. remark: 's',
  89. },
  90. ],
  91. },
  92. },
  93. '5': {
  94. '': {
  95. rem: [['organization:2', 's', 0, 0]],
  96. len: 8,
  97. chunks: [
  98. {
  99. type: 'redaction',
  100. text: '',
  101. rule_id: 'organization:2',
  102. remark: 's',
  103. },
  104. ],
  105. },
  106. },
  107. '6': {
  108. '': {
  109. rem: [['organization:2', 's', 0, 0]],
  110. len: 18,
  111. chunks: [
  112. {
  113. type: 'redaction',
  114. text: '',
  115. rule_id: 'organization:2',
  116. remark: 's',
  117. },
  118. ],
  119. },
  120. },
  121. '7': {
  122. '': {
  123. rem: [['organization:2', 's', 0, 0]],
  124. len: 8,
  125. chunks: [
  126. {
  127. type: 'redaction',
  128. text: '',
  129. rule_id: 'organization:2',
  130. remark: 's',
  131. },
  132. ],
  133. },
  134. },
  135. '8': {
  136. '': {
  137. rem: [['organization:2', 's', 0, 0]],
  138. len: 26,
  139. chunks: [
  140. {
  141. type: 'redaction',
  142. text: '',
  143. rule_id: 'organization:2',
  144. remark: 's',
  145. },
  146. ],
  147. },
  148. },
  149. '9': {
  150. '': {
  151. rem: [['organization:2', 's', 0, 0]],
  152. len: 8,
  153. chunks: [
  154. {
  155. type: 'redaction',
  156. text: '',
  157. rule_id: 'organization:2',
  158. remark: 's',
  159. },
  160. ],
  161. },
  162. },
  163. '': {
  164. len: 14,
  165. },
  166. },
  167. },
  168. },
  169. };
  170. render(<EventExtraData event={event} />, {
  171. organization: {
  172. relayPiiConfig: JSON.stringify(TestStubs.DataScrubbingRelayPiiConfig()),
  173. },
  174. });
  175. expect(await screen.findAllByText(/redacted/)).toHaveLength(10);
  176. userEvent.hover(screen.getAllByText(/redacted/)[0]);
  177. expect(
  178. await screen.findByText(
  179. textWithMarkupMatcher(
  180. "Replaced because of the data scrubbing rule [Replace] [[a-zA-Z0-9]+] with [Placeholder] from [$message] in your organization's settings"
  181. )
  182. )
  183. ).toBeInTheDocument(); // tooltip description
  184. expect(screen.getByText('isNewer')).toBeInTheDocument(); // key
  185. expect(screen.queryByText('\\n')).not.toBeInTheDocument(); // value
  186. });
  187. });