eventErrors.spec.tsx 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. import {render, screen, userEvent, within} from 'sentry-test/reactTestingLibrary';
  2. import {textWithMarkupMatcher} from 'sentry-test/utils';
  3. import {EventErrors} from 'sentry/components/events/eventErrors';
  4. import {JavascriptProcessingErrors} from 'sentry/constants/eventErrors';
  5. import {EntryType} from 'sentry/types';
  6. describe('EventErrors', () => {
  7. const defaultProps = {
  8. project: TestStubs.Project(),
  9. event: TestStubs.Event(),
  10. isShare: false,
  11. };
  12. beforeEach(() => {
  13. jest.resetAllMocks();
  14. MockApiClient.clearMockResponses();
  15. });
  16. it('does not render anything when no errors', () => {
  17. const {container} = render(<EventErrors {...defaultProps} />);
  18. expect(container).toBeEmptyDOMElement();
  19. });
  20. it('renders with errors in event', async () => {
  21. const eventWithErrors = TestStubs.Event({
  22. errors: [
  23. {
  24. type: 'invalid_data',
  25. data: {
  26. name: 'logentry',
  27. },
  28. message: 'no message present',
  29. },
  30. {
  31. type: 'invalid_data',
  32. data: {
  33. name: 'breadcrumbs.values.2.data',
  34. },
  35. message: 'expected an object',
  36. },
  37. ],
  38. });
  39. render(<EventErrors {...defaultProps} event={eventWithErrors} />);
  40. await userEvent.click(
  41. screen.getByText(/there were 2 problems processing this event/i)
  42. );
  43. const errorItems = screen.getAllByTestId('event-error-item');
  44. expect(errorItems).toHaveLength(2);
  45. expect(within(errorItems[0]).getByText('logentry')).toBeInTheDocument();
  46. expect(
  47. within(errorItems[1]).getByText('breadcrumbs.values.2.data')
  48. ).toBeInTheDocument();
  49. });
  50. it('does not render hidden cocoa errors', async () => {
  51. const eventWithErrors = TestStubs.Event({
  52. errors: [
  53. {
  54. type: 'not_invalid_data',
  55. data: {
  56. name: 'logentry',
  57. },
  58. message: 'no message present',
  59. },
  60. {
  61. type: 'invalid_data',
  62. data: {
  63. name: 'contexts.trace.sampled',
  64. },
  65. message: 'expected an object',
  66. },
  67. ],
  68. sdk: {
  69. name: 'sentry.cocoa',
  70. version: '8.7.3',
  71. },
  72. });
  73. render(<EventErrors {...defaultProps} event={eventWithErrors} />);
  74. await userEvent.click(screen.getByText(/there was 1 problem processing this event/i));
  75. const errorItem = screen.getByTestId('event-error-item');
  76. expect(errorItem).toBeInTheDocument();
  77. expect(within(errorItem).getByText('logentry')).toBeInTheDocument();
  78. });
  79. it('hides source map not found error', () => {
  80. const eventWithDifferentDist = TestStubs.Event({
  81. errors: [
  82. {
  83. type: JavascriptProcessingErrors.JS_MISSING_SOURCE,
  84. },
  85. ],
  86. });
  87. render(<EventErrors {...defaultProps} event={eventWithDifferentDist} />);
  88. expect(screen.queryByText(/problem processing this event/i)).not.toBeInTheDocument();
  89. });
  90. describe('proguard errors', () => {
  91. beforeEach(() => {
  92. MockApiClient.addMockResponse({
  93. url: `/projects/org-slug/project-slug/files/dsyms/`,
  94. body: [],
  95. });
  96. });
  97. const proGuardUuid = 'a59c8fcc-2f27-49f8-af9e-02661fc3e8d7';
  98. it('displays missing mapping file with debugmeta but no event error', async () => {
  99. const eventWithDebugMeta = TestStubs.Event({
  100. platform: 'java',
  101. entries: [
  102. {
  103. type: EntryType.DEBUGMETA,
  104. data: {
  105. images: [{type: 'proguard', uuid: proGuardUuid}],
  106. },
  107. },
  108. ],
  109. });
  110. render(<EventErrors {...defaultProps} event={eventWithDebugMeta} />);
  111. await userEvent.click(
  112. await screen.findByText(/there was 1 problem processing this event/i)
  113. );
  114. const errorItem = screen.getByTestId('event-error-item');
  115. expect(errorItem).toBeInTheDocument();
  116. expect(
  117. within(errorItem).getByText('A proguard mapping file was missing.')
  118. ).toBeInTheDocument();
  119. });
  120. it('displays missing mapping file with debugmeta and matching event error', async () => {
  121. const eventWithDebugMeta = TestStubs.Event({
  122. platform: 'java',
  123. entries: [
  124. {
  125. type: EntryType.DEBUGMETA,
  126. data: {
  127. images: [{type: 'proguard', uuid: proGuardUuid}],
  128. },
  129. },
  130. ],
  131. errors: [
  132. {
  133. type: 'proguard_missing_mapping',
  134. message: 'A proguard mapping file was missing.',
  135. data: {mapping_uuid: proGuardUuid},
  136. },
  137. ],
  138. });
  139. render(<EventErrors {...defaultProps} event={eventWithDebugMeta} />);
  140. await userEvent.click(
  141. await screen.findByText(/there was 1 problem processing this event/i)
  142. );
  143. const errorItem = screen.getByTestId('event-error-item');
  144. expect(errorItem).toBeInTheDocument();
  145. expect(
  146. within(errorItem).getByText('A proguard mapping file was missing.')
  147. ).toBeInTheDocument();
  148. });
  149. describe('ProGuard Plugin seems to not be correctly configured', function () {
  150. it('find minified data in the exception entry', async function () {
  151. const newEvent = TestStubs.Event({
  152. platform: 'java',
  153. entries: [
  154. {
  155. type: 'exception',
  156. data: {
  157. values: [
  158. {
  159. stacktrace: {
  160. frames: [
  161. {
  162. function: null,
  163. colNo: null,
  164. vars: {},
  165. symbol: null,
  166. module: 'a.$a.a.a',
  167. },
  168. ],
  169. framesOmitted: null,
  170. registers: null,
  171. hasSystemFrames: false,
  172. },
  173. module: null,
  174. rawStacktrace: null,
  175. mechanism: null,
  176. threadId: null,
  177. value: 'Unexpected token else',
  178. type: 'SyntaxError',
  179. },
  180. ],
  181. excOmitted: null,
  182. hasSystemFrames: false,
  183. },
  184. },
  185. ],
  186. });
  187. render(<EventErrors {...defaultProps} event={newEvent} />);
  188. await userEvent.click(
  189. await screen.findByText(/there was 1 problem processing this event/i)
  190. );
  191. const errorItem = screen.getByTestId('event-error-item');
  192. expect(errorItem).toBeInTheDocument();
  193. expect(
  194. within(errorItem).getByText(
  195. textWithMarkupMatcher(
  196. 'Some frames appear to be minified. Did you configure the Sentry Gradle Plugin?'
  197. )
  198. )
  199. ).toBeInTheDocument();
  200. });
  201. it('find minified data in the threads entry', async function () {
  202. const newEvent = TestStubs.Event({
  203. platform: 'java',
  204. entries: [
  205. {
  206. type: 'exception',
  207. data: {
  208. values: [
  209. {
  210. stacktrace: {
  211. frames: [
  212. {
  213. function: null,
  214. colNo: null,
  215. vars: {},
  216. symbol: null,
  217. module: 'a.$a.a.a',
  218. },
  219. ],
  220. framesOmitted: null,
  221. registers: null,
  222. hasSystemFrames: false,
  223. },
  224. module: null,
  225. rawStacktrace: null,
  226. mechanism: null,
  227. threadId: null,
  228. value: 'Unexpected token else',
  229. type: 'SyntaxError',
  230. },
  231. ],
  232. excOmitted: null,
  233. hasSystemFrames: false,
  234. },
  235. },
  236. {
  237. type: 'threads',
  238. data: {
  239. values: [
  240. {
  241. stacktrace: {
  242. frames: [
  243. {
  244. function: 'start',
  245. package: 'libdyld.dylib',
  246. module: 'a.$a.a.a',
  247. },
  248. {
  249. function: 'main',
  250. package: 'iOS-Swift',
  251. module: '',
  252. },
  253. ],
  254. },
  255. },
  256. ],
  257. },
  258. },
  259. ],
  260. });
  261. render(<EventErrors {...defaultProps} event={newEvent} />);
  262. await userEvent.click(
  263. await screen.findByText(/there was 1 problem processing this event/i)
  264. );
  265. const errorItem = screen.getByTestId('event-error-item');
  266. expect(errorItem).toBeInTheDocument();
  267. expect(
  268. within(errorItem).getByText(
  269. textWithMarkupMatcher(
  270. 'Some frames appear to be minified. Did you configure the Sentry Gradle Plugin?'
  271. )
  272. )
  273. ).toBeInTheDocument();
  274. });
  275. });
  276. });
  277. });