eventErrors.spec.tsx 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  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. describe('release artifacts', () => {
  51. it('displays extra error info when event dist does not match file dist', async () => {
  52. const mock = MockApiClient.addMockResponse({
  53. url: '/projects/org-slug/project-slug/releases/release-version/files/',
  54. body: [{name: 'dist-1'}],
  55. });
  56. const eventWithDifferentDist = TestStubs.Event({
  57. release: {
  58. version: 'release-version',
  59. },
  60. errors: [
  61. {
  62. type: JavascriptProcessingErrors.JS_MISSING_SOURCE,
  63. data: {
  64. url: 'https://place.com/dist-2',
  65. },
  66. },
  67. ],
  68. });
  69. render(<EventErrors {...defaultProps} event={eventWithDifferentDist} />);
  70. await userEvent.click(
  71. screen.getByText(/there was 1 problem processing this event/i)
  72. );
  73. expect(mock).toHaveBeenCalled();
  74. await screen.findByText(
  75. /Source code was not found because the distribution did not match/i
  76. );
  77. });
  78. });
  79. describe('proguard errors', () => {
  80. beforeEach(() => {
  81. MockApiClient.addMockResponse({
  82. url: `/projects/org-slug/project-slug/files/dsyms/`,
  83. body: [],
  84. });
  85. });
  86. const proGuardUuid = 'a59c8fcc-2f27-49f8-af9e-02661fc3e8d7';
  87. it('displays missing mapping file with debugmeta but no event error', async () => {
  88. const eventWithDebugMeta = TestStubs.Event({
  89. platform: 'java',
  90. entries: [
  91. {
  92. type: EntryType.DEBUGMETA,
  93. data: {
  94. images: [{type: 'proguard', uuid: proGuardUuid}],
  95. },
  96. },
  97. ],
  98. });
  99. render(<EventErrors {...defaultProps} event={eventWithDebugMeta} />);
  100. await userEvent.click(
  101. await screen.findByText(/there was 1 problem processing this event/i)
  102. );
  103. const errorItem = screen.getByTestId('event-error-item');
  104. expect(errorItem).toBeInTheDocument();
  105. expect(
  106. within(errorItem).getByText('A proguard mapping file was missing.')
  107. ).toBeInTheDocument();
  108. });
  109. it('displays missing mapping file with debugmeta and matching event error', async () => {
  110. const eventWithDebugMeta = TestStubs.Event({
  111. platform: 'java',
  112. entries: [
  113. {
  114. type: EntryType.DEBUGMETA,
  115. data: {
  116. images: [{type: 'proguard', uuid: proGuardUuid}],
  117. },
  118. },
  119. ],
  120. errors: [
  121. {
  122. type: 'proguard_missing_mapping',
  123. message: 'A proguard mapping file was missing.',
  124. data: {mapping_uuid: proGuardUuid},
  125. },
  126. ],
  127. });
  128. render(<EventErrors {...defaultProps} event={eventWithDebugMeta} />);
  129. await userEvent.click(
  130. await screen.findByText(/there was 1 problem processing this event/i)
  131. );
  132. const errorItem = screen.getByTestId('event-error-item');
  133. expect(errorItem).toBeInTheDocument();
  134. expect(
  135. within(errorItem).getByText('A proguard mapping file was missing.')
  136. ).toBeInTheDocument();
  137. });
  138. describe('ProGuard Plugin seems to not be correctly configured', function () {
  139. it('find minified data in the exception entry', async function () {
  140. const newEvent = TestStubs.Event({
  141. platform: 'java',
  142. entries: [
  143. {
  144. type: 'exception',
  145. data: {
  146. values: [
  147. {
  148. stacktrace: {
  149. frames: [
  150. {
  151. function: null,
  152. colNo: null,
  153. vars: {},
  154. symbol: null,
  155. module: 'a.$a.a.a',
  156. },
  157. ],
  158. framesOmitted: null,
  159. registers: null,
  160. hasSystemFrames: false,
  161. },
  162. module: null,
  163. rawStacktrace: null,
  164. mechanism: null,
  165. threadId: null,
  166. value: 'Unexpected token else',
  167. type: 'SyntaxError',
  168. },
  169. ],
  170. excOmitted: null,
  171. hasSystemFrames: false,
  172. },
  173. },
  174. ],
  175. });
  176. render(<EventErrors {...defaultProps} event={newEvent} />);
  177. await userEvent.click(
  178. await screen.findByText(/there was 1 problem processing this event/i)
  179. );
  180. const errorItem = screen.getByTestId('event-error-item');
  181. expect(errorItem).toBeInTheDocument();
  182. expect(
  183. within(errorItem).getByText(
  184. textWithMarkupMatcher(
  185. 'Some frames appear to be minified. Did you configure the Sentry Gradle Plugin?'
  186. )
  187. )
  188. ).toBeInTheDocument();
  189. });
  190. it('find minified data in the threads entry', async function () {
  191. const newEvent = TestStubs.Event({
  192. platform: 'java',
  193. entries: [
  194. {
  195. type: 'exception',
  196. data: {
  197. values: [
  198. {
  199. stacktrace: {
  200. frames: [
  201. {
  202. function: null,
  203. colNo: null,
  204. vars: {},
  205. symbol: null,
  206. module: 'a.$a.a.a',
  207. },
  208. ],
  209. framesOmitted: null,
  210. registers: null,
  211. hasSystemFrames: false,
  212. },
  213. module: null,
  214. rawStacktrace: null,
  215. mechanism: null,
  216. threadId: null,
  217. value: 'Unexpected token else',
  218. type: 'SyntaxError',
  219. },
  220. ],
  221. excOmitted: null,
  222. hasSystemFrames: false,
  223. },
  224. },
  225. {
  226. type: 'threads',
  227. data: {
  228. values: [
  229. {
  230. stacktrace: {
  231. frames: [
  232. {
  233. function: 'start',
  234. package: 'libdyld.dylib',
  235. module: 'a.$a.a.a',
  236. },
  237. {
  238. function: 'main',
  239. package: 'iOS-Swift',
  240. module: '',
  241. },
  242. ],
  243. },
  244. },
  245. ],
  246. },
  247. },
  248. ],
  249. });
  250. render(<EventErrors {...defaultProps} event={newEvent} />);
  251. await userEvent.click(
  252. await screen.findByText(/there was 1 problem processing this event/i)
  253. );
  254. const errorItem = screen.getByTestId('event-error-item');
  255. expect(errorItem).toBeInTheDocument();
  256. expect(
  257. within(errorItem).getByText(
  258. textWithMarkupMatcher(
  259. 'Some frames appear to be minified. Did you configure the Sentry Gradle Plugin?'
  260. )
  261. )
  262. ).toBeInTheDocument();
  263. });
  264. });
  265. });
  266. });