groupEventEntries.spec.tsx 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. import {initializeOrg} from 'sentry-test/initializeOrg';
  2. import {act, render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  3. import type {Error} from 'sentry/components/events/errors';
  4. import EventEntries from 'sentry/components/events/eventEntries';
  5. import {EntryType, Event} from 'sentry/types/event';
  6. import {OrganizationContext} from 'sentry/views/organizationContext';
  7. const {organization, project} = initializeOrg();
  8. const api = new MockApiClient();
  9. async function renderComponent(event: Event, errors?: Array<Error>) {
  10. render(
  11. <OrganizationContext.Provider value={organization}>
  12. <EventEntries
  13. organization={organization}
  14. event={{...event, errors: errors ?? event.errors}}
  15. project={project}
  16. location={location}
  17. api={api}
  18. />
  19. </OrganizationContext.Provider>
  20. );
  21. const alertSummaryInfo = await screen.findByTestId('event-error-alert');
  22. userEvent.click(alertSummaryInfo);
  23. const errorItems = await screen.findAllByTestId('event-error-item');
  24. return {alertSummaryInfo, errorItem: errorItems};
  25. }
  26. describe('GroupEventEntries', function () {
  27. const event = TestStubs.Event();
  28. beforeEach(() => {
  29. MockApiClient.addMockResponse({
  30. url: `/projects/${organization.slug}/${project.slug}/events/${event.id}/grouping-info/`,
  31. body: {},
  32. });
  33. MockApiClient.addMockResponse({
  34. url: `/projects/${organization.slug}/${project.slug}/files/dsyms/`,
  35. body: [],
  36. });
  37. });
  38. afterEach(() => {
  39. MockApiClient.clearMockResponses();
  40. });
  41. describe('EventError', function () {
  42. it('renders', async function () {
  43. const errors: Array<Error> = [
  44. {
  45. type: 'invalid_data',
  46. data: {
  47. name: 'logentry',
  48. },
  49. message: 'no message present',
  50. },
  51. {
  52. type: 'invalid_data',
  53. data: {
  54. name: 'breadcrumbs.values.2.data',
  55. },
  56. message: 'expected an object',
  57. },
  58. ];
  59. const {alertSummaryInfo, errorItem} = await renderComponent(event, errors);
  60. expect(alertSummaryInfo).toHaveTextContent(
  61. `There were ${errors.length} problems processing this event`
  62. );
  63. expect(errorItem.length).toBe(2);
  64. expect(screen.getByText(errors[0].data?.name!)).toBeInTheDocument();
  65. expect(screen.getByText(errors[1].data?.name!)).toBeInTheDocument();
  66. });
  67. describe('Proguard erros', function () {
  68. const proGuardUuid = 'a59c8fcc-2f27-49f8-af9e-02661fc3e8d7';
  69. it('Missing mapping file', async function () {
  70. const newEvent = {
  71. ...event,
  72. platform: 'java',
  73. entries: [
  74. {
  75. type: EntryType.DEBUGMETA,
  76. data: {
  77. images: [{type: 'proguard', uuid: proGuardUuid}],
  78. },
  79. },
  80. ],
  81. };
  82. await act(async () => {
  83. const {errorItem, alertSummaryInfo} = await renderComponent(newEvent);
  84. expect(alertSummaryInfo).toHaveTextContent(
  85. 'There was 1 problem processing this event'
  86. );
  87. expect(errorItem.length).toBe(1);
  88. expect(
  89. screen.getByText('A proguard mapping file was missing.')
  90. ).toBeInTheDocument();
  91. userEvent.click(screen.getByRole('button', {name: 'Expand'}));
  92. expect(await screen.findByText(proGuardUuid)).toBeInTheDocument();
  93. });
  94. });
  95. it("Don't display extra proguard errors, if the entry error of an event has an error of type 'proguard_missing_mapping'", async function () {
  96. const newEvent = {
  97. ...event,
  98. platform: 'java',
  99. entries: [
  100. {
  101. type: EntryType.DEBUGMETA,
  102. data: {
  103. images: [{type: 'proguard', uuid: proGuardUuid}],
  104. },
  105. },
  106. ],
  107. errors: [
  108. {
  109. type: 'proguard_missing_mapping',
  110. message: 'A proguard mapping file was missing.',
  111. data: {mapping_uuid: proGuardUuid},
  112. },
  113. ],
  114. };
  115. const {alertSummaryInfo, errorItem} = await renderComponent(newEvent);
  116. expect(alertSummaryInfo).toHaveTextContent(
  117. 'There was 1 problem processing this event'
  118. );
  119. expect(errorItem.length).toBe(1);
  120. expect(
  121. screen.getByText('A proguard mapping file was missing.')
  122. ).toBeInTheDocument();
  123. userEvent.click(screen.getByRole('button', {name: 'Expand'}));
  124. expect(await screen.findByText(proGuardUuid)).toBeInTheDocument();
  125. });
  126. describe('ProGuard Plugin seems to not be correctly configured', function () {
  127. it('find minified data in the exception entry', async function () {
  128. const newEvent = {
  129. ...event,
  130. platform: 'java',
  131. entries: [
  132. {
  133. type: 'exception',
  134. data: {
  135. values: [
  136. {
  137. stacktrace: {
  138. frames: [
  139. {
  140. function: null,
  141. colNo: null,
  142. vars: {},
  143. symbol: null,
  144. module: 'a.$a.a.a',
  145. },
  146. ],
  147. framesOmitted: null,
  148. registers: null,
  149. hasSystemFrames: false,
  150. },
  151. module: null,
  152. rawStacktrace: null,
  153. mechanism: null,
  154. threadId: null,
  155. value: 'Unexpected token else',
  156. type: 'SyntaxError',
  157. },
  158. ],
  159. excOmitted: null,
  160. hasSystemFrames: false,
  161. },
  162. },
  163. ],
  164. };
  165. const {alertSummaryInfo, errorItem} = await renderComponent(newEvent);
  166. expect(alertSummaryInfo).toHaveTextContent(
  167. 'There was 1 problem processing this event'
  168. );
  169. expect(errorItem.length).toBe(1);
  170. expect(
  171. screen.getByText('Some frames appear to be minified. Did you configure the')
  172. ).toBeInTheDocument();
  173. expect(
  174. screen.getByText('No additional details are available for this frame.')
  175. ).toBeInTheDocument();
  176. });
  177. it('find minified data in the threads entry', async function () {
  178. const newEvent = {
  179. ...event,
  180. platform: 'java',
  181. entries: [
  182. {
  183. type: 'exception',
  184. data: {
  185. values: [
  186. {
  187. stacktrace: {
  188. frames: [
  189. {
  190. function: null,
  191. colNo: null,
  192. vars: {},
  193. symbol: null,
  194. module: 'a.$a.a.a',
  195. },
  196. ],
  197. framesOmitted: null,
  198. registers: null,
  199. hasSystemFrames: false,
  200. },
  201. module: null,
  202. rawStacktrace: null,
  203. mechanism: null,
  204. threadId: null,
  205. value: 'Unexpected token else',
  206. type: 'SyntaxError',
  207. },
  208. ],
  209. excOmitted: null,
  210. hasSystemFrames: false,
  211. },
  212. },
  213. {
  214. type: 'threads',
  215. data: {
  216. values: [
  217. {
  218. stacktrace: {
  219. frames: [
  220. {
  221. function: 'start',
  222. package: 'libdyld.dylib',
  223. module: 'a.$a.a.a',
  224. },
  225. {
  226. function: 'main',
  227. package: 'iOS-Swift',
  228. module: '',
  229. },
  230. ],
  231. },
  232. },
  233. ],
  234. },
  235. },
  236. ],
  237. };
  238. const {alertSummaryInfo, errorItem} = await renderComponent(newEvent);
  239. expect(alertSummaryInfo).toHaveTextContent(
  240. 'There was 1 problem processing this event'
  241. );
  242. expect(errorItem.length).toBe(1);
  243. expect(
  244. screen.getByText('Some frames appear to be minified. Did you configure the')
  245. ).toBeInTheDocument();
  246. expect(screen.getByText('Sentry Gradle Plugin')).toBeInTheDocument();
  247. });
  248. });
  249. });
  250. });
  251. });