threadsV2.spec.tsx 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101
  1. import {InjectedRouter} from 'react-router';
  2. import {initializeOrg} from 'sentry-test/initializeOrg';
  3. import {render, screen, userEvent, within} from 'sentry-test/reactTestingLibrary';
  4. import ThreadsV2 from 'sentry/components/events/interfaces/threadsV2';
  5. import {displayOptions} from 'sentry/components/events/traceEventDataSection';
  6. import {EventOrGroupType, Organization} from 'sentry/types';
  7. import {EntryType, Event} from 'sentry/types/event';
  8. import {OrganizationContext} from 'sentry/views/organizationContext';
  9. import {RouteContext} from 'sentry/views/routeContext';
  10. function TestComponent({
  11. organization,
  12. router,
  13. children,
  14. }: {
  15. children: React.ReactNode;
  16. organization: Organization;
  17. router: InjectedRouter;
  18. }) {
  19. return (
  20. <OrganizationContext.Provider value={organization}>
  21. <RouteContext.Provider
  22. value={{
  23. router,
  24. location: router.location,
  25. params: {},
  26. routes: [],
  27. }}
  28. >
  29. {children}
  30. </RouteContext.Provider>
  31. </OrganizationContext.Provider>
  32. );
  33. }
  34. describe('ThreadsV2', function () {
  35. const {project, organization, router} = initializeOrg();
  36. const org = {...organization, features: ['native-stack-trace-v2']};
  37. describe('non native platform', function () {
  38. describe('other platform', function () {
  39. const event: Event = {
  40. id: '020eb33f6ce64ed6adc60f8993535816',
  41. groupID: '68',
  42. eventID: '020eb33f6ce64ed6adc60f8993535816',
  43. projectID: '2',
  44. size: 3481,
  45. entries: [
  46. {
  47. data: {
  48. values: [
  49. {
  50. type: 'ZeroDivisionError',
  51. value: 'divided by 0',
  52. mechanism: null,
  53. threadId: null,
  54. module: '',
  55. stacktrace: {
  56. frames: [
  57. {
  58. filename: 'puma (3.12.6) lib/puma/thread_pool.rb',
  59. absPath: 'puma (3.12.6) lib/puma/thread_pool.rb',
  60. module: null,
  61. package: null,
  62. platform: null,
  63. instructionAddr: null,
  64. symbolAddr: null,
  65. function: 'block in spawn_thread',
  66. rawFunction: null,
  67. symbol: null,
  68. context: [],
  69. lineNo: 135,
  70. colNo: null,
  71. inApp: false,
  72. trust: null,
  73. errors: null,
  74. vars: null,
  75. },
  76. {
  77. filename: 'puma (3.12.6) lib/puma/server.rb',
  78. absPath: 'puma (3.12.6) lib/puma/server.rb',
  79. module: null,
  80. package: null,
  81. platform: null,
  82. instructionAddr: null,
  83. symbolAddr: null,
  84. function: 'block in run',
  85. rawFunction: null,
  86. symbol: null,
  87. context: [],
  88. lineNo: 334,
  89. colNo: null,
  90. inApp: false,
  91. trust: null,
  92. errors: null,
  93. vars: null,
  94. },
  95. {
  96. filename: 'sentry/controllers/welcome_controller.rb',
  97. absPath: 'sentry/controllers/welcome_controller.rb',
  98. module: null,
  99. package: null,
  100. platform: null,
  101. instructionAddr: null,
  102. symbolAddr: null,
  103. function: 'index',
  104. rawFunction: null,
  105. symbol: null,
  106. context: [
  107. [2, ' before_action :set_sentry_context\n'],
  108. [3, '\n'],
  109. [4, ' def index\n'],
  110. [5, ' 1 / 0\n'],
  111. [6, ' end\n'],
  112. [7, '\n'],
  113. [8, ' def view_error\n'],
  114. ],
  115. lineNo: 5,
  116. colNo: null,
  117. inApp: true,
  118. trust: null,
  119. errors: null,
  120. vars: null,
  121. minGroupingLevel: 1,
  122. },
  123. {
  124. filename: 'sentry/controllers/welcome_controller.rb',
  125. absPath: 'sentry/controllers/welcome_controller.rb',
  126. module: null,
  127. package: null,
  128. platform: null,
  129. instructionAddr: null,
  130. symbolAddr: null,
  131. function: '/',
  132. rawFunction: null,
  133. symbol: null,
  134. context: [
  135. [2, ' before_action :set_sentry_context\n'],
  136. [3, '\n'],
  137. [4, ' def index\n'],
  138. [5, ' 1 / 0\n'],
  139. [6, ' end\n'],
  140. [7, '\n'],
  141. [8, ' def view_error\n'],
  142. ],
  143. lineNo: 5,
  144. colNo: null,
  145. inApp: true,
  146. trust: null,
  147. errors: null,
  148. vars: null,
  149. minGroupingLevel: 0,
  150. },
  151. ],
  152. framesOmitted: null,
  153. registers: null,
  154. hasSystemFrames: true,
  155. },
  156. rawStacktrace: null,
  157. frames: null,
  158. },
  159. ],
  160. hasSystemFrames: true,
  161. excOmitted: null,
  162. },
  163. type: EntryType.EXCEPTION,
  164. },
  165. {
  166. data: {
  167. values: [
  168. {
  169. id: 13920,
  170. current: true,
  171. crashed: true,
  172. name: 'puma 002',
  173. stacktrace: null,
  174. rawStacktrace: null,
  175. },
  176. ],
  177. },
  178. type: EntryType.THREADS,
  179. },
  180. ],
  181. dist: null,
  182. message: '',
  183. title: 'ZeroDivisionError: divided by 0',
  184. location: 'sentry/controllers/welcome_controller.rb',
  185. user: null,
  186. contexts: {},
  187. sdk: null,
  188. context: {},
  189. packages: {},
  190. type: EventOrGroupType.ERROR,
  191. metadata: {
  192. display_title_with_tree_label: false,
  193. filename: 'sentry/controllers/welcome_controller.rb',
  194. finest_tree_label: [
  195. {filebase: 'welcome_controller.rb', function: '/'},
  196. {filebase: 'welcome_controller.rb', function: 'index'},
  197. ],
  198. function: '/',
  199. type: 'ZeroDivisionError',
  200. value: 'divided by 0',
  201. },
  202. tags: [{key: 'level', value: 'error'}],
  203. platform: 'other',
  204. dateReceived: '2021-10-28T12:28:22.318469Z',
  205. errors: [],
  206. crashFile: null,
  207. culprit: 'sentry/controllers/welcome_controller.rb in /',
  208. dateCreated: '2021-10-28T12:28:22.318469Z',
  209. fingerprints: ['58f1f47bea5239ea25397888dc9253d1'],
  210. groupingConfig: {
  211. enhancements: 'eJybzDRxY25-UmZOqpWRgZGhroGJroHRBABbUQb_',
  212. id: 'mobile:2021-02-12',
  213. },
  214. release: null,
  215. userReport: null,
  216. sdkUpdates: [],
  217. nextEventID: null,
  218. previousEventID: null,
  219. };
  220. const props: React.ComponentProps<typeof ThreadsV2> = {
  221. data: event.entries[1].data as React.ComponentProps<typeof ThreadsV2>['data'],
  222. event,
  223. groupingCurrentLevel: 0,
  224. hasHierarchicalGrouping: true,
  225. projectId: project.id,
  226. };
  227. it('renders', function () {
  228. const {container} = render(
  229. <TestComponent organization={org} router={router}>
  230. <ThreadsV2 {...props} />
  231. </TestComponent>,
  232. {
  233. organization: org,
  234. }
  235. );
  236. // Title
  237. expect(screen.getByRole('heading', {name: 'Stack Trace'})).toBeInTheDocument();
  238. // Actions
  239. expect(
  240. screen.getByRole('button', {name: 'Full Stack Trace'})
  241. ).toBeInTheDocument();
  242. expect(screen.getByRole('button', {name: 'Full Stack Trace'})).not.toHaveClass(
  243. 'active'
  244. );
  245. expect(screen.getByRole('button', {name: 'Options'})).toBeInTheDocument();
  246. // Stack Trace
  247. expect(
  248. screen.getByRole('heading', {name: 'ZeroDivisionError'})
  249. ).toBeInTheDocument();
  250. expect(screen.getByText('divided by 0')).toBeInTheDocument();
  251. expect(screen.getByTestId('stack-trace-content-v2')).toBeInTheDocument();
  252. expect(screen.queryAllByTestId('stack-trace-frame')).toHaveLength(3);
  253. expect(container).toSnapshot();
  254. });
  255. it('toggle full stack trace button', function () {
  256. render(
  257. <TestComponent organization={org} router={router}>
  258. <ThreadsV2 {...props} />
  259. </TestComponent>,
  260. {organization: org}
  261. );
  262. expect(screen.queryAllByTestId('stack-trace-frame')).toHaveLength(3);
  263. expect(screen.getByRole('button', {name: 'Full Stack Trace'})).not.toHaveClass(
  264. 'active'
  265. );
  266. userEvent.click(screen.getByRole('button', {name: 'Full Stack Trace'}));
  267. expect(screen.getByRole('button', {name: 'Full Stack Trace'})).toHaveClass(
  268. 'active'
  269. );
  270. expect(screen.queryAllByTestId('stack-trace-frame')).toHaveLength(4);
  271. });
  272. it('toggle sort by display option', function () {
  273. render(
  274. <TestComponent organization={org} router={router}>
  275. <ThreadsV2 {...props} />
  276. </TestComponent>,
  277. {organization: org}
  278. );
  279. expect(
  280. within(screen.getAllByTestId('stack-trace-frame')[0]).getByText(
  281. 'sentry/controllers/welcome_controller.rb'
  282. )
  283. ).toBeInTheDocument();
  284. // Sort by options
  285. expect(screen.getByText('Newest')).toBeInTheDocument();
  286. expect(screen.queryByText('Oldest')).not.toBeInTheDocument();
  287. // Switch to recent last
  288. userEvent.click(screen.getByText('Newest'));
  289. userEvent.click(screen.getByText('Oldest'));
  290. // Recent last is checked
  291. expect(screen.getByText('Oldest')).toBeInTheDocument();
  292. expect(screen.queryByText('Newest')).not.toBeInTheDocument();
  293. // Last frame is the first on the list
  294. expect(
  295. within(screen.getAllByTestId('stack-trace-frame')[0]).getByText(
  296. 'puma (3.12.6) lib/puma/server.rb'
  297. )
  298. ).toBeInTheDocument();
  299. // Click on recent first
  300. userEvent.click(screen.getByText('Oldest'));
  301. userEvent.click(screen.getByText('Newest'));
  302. // First frame is the first on the list
  303. expect(
  304. within(screen.getAllByTestId('stack-trace-frame')[0]).getByText(
  305. 'sentry/controllers/welcome_controller.rb'
  306. )
  307. ).toBeInTheDocument();
  308. });
  309. it('check display options', async function () {
  310. render(
  311. <TestComponent organization={org} router={router}>
  312. <ThreadsV2 {...props} />
  313. </TestComponent>,
  314. {organization: org}
  315. );
  316. userEvent.click(screen.getByRole('button', {name: 'Options'}));
  317. expect(await screen.findByText('Display')).toBeInTheDocument();
  318. Object.entries(displayOptions).forEach(([key, value]) => {
  319. if (key === 'minified' || key === 'raw-stack-trace') {
  320. expect(screen.getByText(value)).toBeInTheDocument();
  321. return;
  322. }
  323. expect(screen.queryByText(value)).not.toBeInTheDocument();
  324. });
  325. // Hover over the Minified option
  326. userEvent.hover(screen.getByText(displayOptions.minified));
  327. // Minified option is disabled
  328. expect(
  329. await screen.findByText('Minified version not available')
  330. ).toBeInTheDocument();
  331. });
  332. });
  333. });
  334. describe('native platform', function () {
  335. describe('cocoa', function () {
  336. const event: Event = {
  337. id: 'bfe4379d82934b2b91d70b1167bcae8d',
  338. groupID: '24',
  339. eventID: 'bfe4379d82934b2b91d70b1167bcae8d',
  340. projectID: '2',
  341. size: 89101,
  342. entries: [
  343. {
  344. data: {
  345. values: [
  346. {
  347. stacktrace: {
  348. frames: [
  349. {
  350. filename: null,
  351. absPath: null,
  352. module: null,
  353. package:
  354. '/private/var/containers/Bundle/Application/575F9D39-D486-4728-B035-84923A0BE206/sentry-ios-cocoapods.app/Frameworks/Sentry.framework/Sentry',
  355. platform: null,
  356. instructionAddr: '0x1000adb08',
  357. symbolAddr: '0x1000ad5c4',
  358. function:
  359. '__44-[SentryBreadcrumbTracker swizzleSendAction]_block_invoke_2',
  360. rawFunction: null,
  361. symbol: null,
  362. context: [],
  363. lineNo: null,
  364. colNo: null,
  365. inApp: false,
  366. trust: null,
  367. errors: null,
  368. vars: null,
  369. },
  370. {
  371. filename: null,
  372. absPath: null,
  373. module: null,
  374. package: '/System/Library/Frameworks/UIKit.framework/UIKit',
  375. platform: null,
  376. instructionAddr: '0x197885c54',
  377. symbolAddr: '0x197885bf4',
  378. function: '<redacted>',
  379. rawFunction: null,
  380. symbol: null,
  381. context: [],
  382. lineNo: null,
  383. colNo: null,
  384. inApp: false,
  385. trust: null,
  386. errors: null,
  387. vars: null,
  388. },
  389. {
  390. filename: null,
  391. absPath: null,
  392. module: null,
  393. package: '/System/Library/Frameworks/UIKit.framework/UIKit',
  394. platform: null,
  395. instructionAddr: '0x197885c54',
  396. symbolAddr: '0x197885bf4',
  397. function: '<redacted>',
  398. rawFunction: null,
  399. symbol: null,
  400. context: [],
  401. lineNo: null,
  402. colNo: null,
  403. inApp: false,
  404. trust: null,
  405. errors: null,
  406. vars: null,
  407. },
  408. {
  409. filename: null,
  410. absPath: null,
  411. module: null,
  412. package:
  413. '/var/containers/Bundle/Application/575F9D39-D486-4728-B035-84923A0BE206/sentry-ios-cocoapods.app/sentry-ios-cocoapods',
  414. platform: null,
  415. instructionAddr: '0x10008c5ac',
  416. symbolAddr: '0x10008c500',
  417. function: 'ViewController.causeCrash',
  418. rawFunction: 'ViewController.causeCrash(Any) -> ()',
  419. symbol: null,
  420. context: [],
  421. lineNo: null,
  422. colNo: null,
  423. inApp: true,
  424. trust: null,
  425. errors: null,
  426. vars: null,
  427. },
  428. {
  429. filename: null,
  430. absPath: null,
  431. module: null,
  432. package:
  433. '/private/var/containers/Bundle/Application/575F9D39-D486-4728-B035-84923A0BE206/sentry-ios-cocoapods.app/Frameworks/Sentry.framework/Sentry',
  434. platform: null,
  435. instructionAddr: '0x1000b0bfc',
  436. symbolAddr: '0x1000b0be4',
  437. function: '-[SentryClient crash]',
  438. rawFunction: null,
  439. symbol: null,
  440. context: [],
  441. lineNo: null,
  442. colNo: null,
  443. inApp: false,
  444. trust: null,
  445. errors: null,
  446. vars: null,
  447. },
  448. ],
  449. framesOmitted: null,
  450. hasSystemFrames: true,
  451. registers: {
  452. cpsr: '0x60000000',
  453. fp: '0x16fd79870',
  454. lr: '0x10008c5ac',
  455. pc: '0x1000b0bfc',
  456. sp: '0x16fd79810',
  457. x0: '0x1700eee80',
  458. x1: '0x10008e49c',
  459. x10: '0x1b7886ff0',
  460. x11: '0x59160100591680',
  461. x12: '0x0',
  462. x13: '0x591600',
  463. x14: '0x591700',
  464. x15: '0x5916c0',
  465. x16: '0x591601',
  466. x17: '0x1000b0be4',
  467. x18: '0x0',
  468. x19: '0x1740eb200',
  469. x2: '0x0',
  470. x20: '0x10fd08db0',
  471. x21: '0x10008e4de',
  472. x22: '0x10fe0a470',
  473. x23: '0x10fe0a470',
  474. x24: '0x174008ba0',
  475. x25: '0x0',
  476. x26: '0x19838eb61',
  477. x27: '0x1',
  478. x28: '0x170046c60',
  479. x29: '0x16fd79870',
  480. x3: '0x1740eb200',
  481. x4: '0x1740eb200',
  482. x5: '0x1740eb200',
  483. x6: '0x0',
  484. x7: '0x2',
  485. x8: '0x0',
  486. x9: '0x1b7886fec',
  487. },
  488. },
  489. threadId: 0,
  490. module: null,
  491. mechanism: null,
  492. rawStacktrace: null,
  493. value:
  494. 'Attempted to dereference null pointer.\nOriginated at or in a subcall of ViewController.causeCrash(Any) -> ()',
  495. type: 'EXC_BAD_ACCESS',
  496. },
  497. ],
  498. hasSystemFrames: true,
  499. excOmitted: null,
  500. },
  501. type: EntryType.EXCEPTION,
  502. },
  503. {
  504. data: {
  505. values: [
  506. {
  507. id: 0,
  508. current: false,
  509. crashed: true,
  510. name: null,
  511. stacktrace: {
  512. frames: [
  513. {
  514. filename: null,
  515. absPath: null,
  516. module: null,
  517. package: '/System/Library/Frameworks/UIKit.framework/UIKit',
  518. platform: null,
  519. instructionAddr: '0x197885c54',
  520. symbolAddr: '0x197885bf4',
  521. function: '<redacted>',
  522. rawFunction: null,
  523. symbol: null,
  524. context: [],
  525. lineNo: null,
  526. colNo: null,
  527. inApp: false,
  528. trust: null,
  529. errors: null,
  530. vars: null,
  531. },
  532. {
  533. filename: null,
  534. absPath: null,
  535. module: null,
  536. package: '/System/Library/Frameworks/UIKit.framework/UIKit',
  537. platform: null,
  538. instructionAddr: '0x197885c54',
  539. symbolAddr: '0x197885bf4',
  540. function: '<redacted>',
  541. rawFunction: null,
  542. symbol: null,
  543. context: [],
  544. lineNo: null,
  545. colNo: null,
  546. inApp: false,
  547. trust: null,
  548. errors: null,
  549. vars: null,
  550. },
  551. {
  552. filename: null,
  553. absPath: null,
  554. module: null,
  555. package:
  556. '/var/containers/Bundle/Application/575F9D39-D486-4728-B035-84923A0BE206/sentry-ios-cocoapods.app/sentry-ios-cocoapods',
  557. platform: null,
  558. instructionAddr: '0x10008c630',
  559. symbolAddr: '0x10008c5e8',
  560. function: 'ViewController.causeCrash',
  561. rawFunction: '@objc ViewController.causeCrash(Any) -> ()',
  562. symbol: null,
  563. context: [],
  564. lineNo: null,
  565. colNo: null,
  566. inApp: true,
  567. trust: null,
  568. errors: null,
  569. vars: null,
  570. },
  571. {
  572. filename: null,
  573. absPath: null,
  574. module: null,
  575. package:
  576. '/var/containers/Bundle/Application/575F9D39-D486-4728-B035-84923A0BE206/sentry-ios-cocoapods.app/sentry-ios-cocoapods',
  577. platform: null,
  578. instructionAddr: '0x10008c5ac',
  579. symbolAddr: '0x10008c500',
  580. function: 'ViewController.causeCrash',
  581. rawFunction: 'ViewController.causeCrash(Any) -> ()',
  582. symbol: null,
  583. context: [],
  584. lineNo: null,
  585. colNo: null,
  586. inApp: true,
  587. trust: null,
  588. errors: null,
  589. vars: null,
  590. },
  591. {
  592. filename: null,
  593. absPath: null,
  594. module: null,
  595. package:
  596. '/private/var/containers/Bundle/Application/575F9D39-D486-4728-B035-84923A0BE206/sentry-ios-cocoapods.app/Frameworks/Sentry.framework/Sentry',
  597. platform: null,
  598. instructionAddr: '0x1000b0bfc',
  599. symbolAddr: '0x1000b0be4',
  600. function: '-[SentryClient crash]',
  601. rawFunction: null,
  602. symbol: null,
  603. context: [],
  604. lineNo: null,
  605. colNo: null,
  606. inApp: false,
  607. trust: null,
  608. errors: null,
  609. vars: null,
  610. },
  611. ],
  612. framesOmitted: null,
  613. registers: {
  614. cpsr: '0x60000000',
  615. fp: '0x16fd79870',
  616. lr: '0x10008c5ac',
  617. pc: '0x1000b0bfc',
  618. sp: '0x16fd79810',
  619. x0: '0x1700eee80',
  620. x1: '0x10008e49c',
  621. x10: '0x1b7886ff0',
  622. x11: '0x59160100591680',
  623. x12: '0x0',
  624. x13: '0x591600',
  625. x14: '0x591700',
  626. x15: '0x5916c0',
  627. x16: '0x591601',
  628. x17: '0x1000b0be4',
  629. x18: '0x0',
  630. x19: '0x1740eb200',
  631. x2: '0x0',
  632. x20: '0x10fd08db0',
  633. x21: '0x10008e4de',
  634. x22: '0x10fe0a470',
  635. x23: '0x10fe0a470',
  636. x24: '0x174008ba0',
  637. x25: '0x0',
  638. x26: '0x19838eb61',
  639. x27: '0x1',
  640. x28: '0x170046c60',
  641. x29: '0x16fd79870',
  642. x3: '0x1740eb200',
  643. x4: '0x1740eb200',
  644. x5: '0x1740eb200',
  645. x6: '0x0',
  646. x7: '0x2',
  647. x8: '0x0',
  648. x9: '0x1b7886fec',
  649. },
  650. hasSystemFrames: true,
  651. },
  652. rawStacktrace: null,
  653. },
  654. {
  655. id: 1,
  656. current: false,
  657. crashed: false,
  658. name: null,
  659. stacktrace: {
  660. frames: [
  661. {
  662. filename: null,
  663. absPath: null,
  664. module: null,
  665. package: '/usr/lib/system/libsystem_pthread.dylib',
  666. platform: null,
  667. instructionAddr: '0x1907df1a4',
  668. symbolAddr: '0x1907decb8',
  669. function: '_pthread_wqthread',
  670. rawFunction: null,
  671. symbol: null,
  672. context: [],
  673. lineNo: null,
  674. colNo: null,
  675. inApp: false,
  676. trust: null,
  677. errors: null,
  678. vars: null,
  679. },
  680. {
  681. filename: null,
  682. absPath: null,
  683. module: null,
  684. package: '/usr/lib/system/libsystem_kernel.dylib',
  685. platform: null,
  686. instructionAddr: '0x190719a88',
  687. symbolAddr: '0x190719a80',
  688. function: '__workq_kernreturn',
  689. rawFunction: null,
  690. symbol: null,
  691. context: [],
  692. lineNo: null,
  693. colNo: null,
  694. inApp: false,
  695. trust: null,
  696. errors: null,
  697. vars: null,
  698. },
  699. ],
  700. framesOmitted: null,
  701. registers: {
  702. cpsr: '0x0',
  703. fp: '0x16dfcaf70',
  704. lr: '0x1907df1a4',
  705. pc: '0x190719a88',
  706. sp: '0x16dfcaef0',
  707. x0: '0x4',
  708. x1: '0x0',
  709. x10: '0x1',
  710. x11: '0x0',
  711. x12: '0x30000400000d03',
  712. x13: '0x0',
  713. x14: '0x1740e9edc',
  714. x15: '0xfffffff100000000',
  715. x16: '0x170',
  716. x17: '0x191619c10',
  717. x18: '0x0',
  718. x19: '0x16dfcb000',
  719. x2: '0x0',
  720. x20: '0x19',
  721. x21: '0x270019',
  722. x22: '0x0',
  723. x23: '0xd03',
  724. x24: '0x1b788d000',
  725. x25: '0x1b788d000',
  726. x26: '0x0',
  727. x27: '0x80000000',
  728. x28: '0x800010ff',
  729. x29: '0x16dfcaf70',
  730. x3: '0x0',
  731. x4: '0x80010ff',
  732. x5: '0x0',
  733. x6: '0x0',
  734. x7: '0x0',
  735. x8: '0x2',
  736. x9: '0x17409b4ec',
  737. },
  738. hasSystemFrames: false,
  739. },
  740. rawStacktrace: null,
  741. },
  742. ],
  743. },
  744. type: EntryType.THREADS,
  745. },
  746. {
  747. data: {
  748. images: [
  749. {
  750. code_file:
  751. '/var/containers/Bundle/Application/575F9D39-D486-4728-B035-84923A0BE206/sentry-ios-cocoapods.app/sentry-ios-cocoapods',
  752. debug_id: '6b77ffb6-5aba-3b5f-9171-434f9660f738',
  753. image_addr: '0x100084000',
  754. image_size: 49152,
  755. image_vmaddr: '0x100000000',
  756. type: 'macho',
  757. candidates: [],
  758. features: {
  759. has_debug_info: false,
  760. has_sources: false,
  761. has_symbols: false,
  762. has_unwind_info: false,
  763. },
  764. },
  765. {
  766. code_file: '/System/Library/Frameworks/UIKit.framework/UIKit',
  767. debug_id: '314063bd-f85f-321d-88d6-e24a0de464a2',
  768. image_addr: '0x197841000',
  769. image_size: 14315520,
  770. image_vmaddr: '0x187769000',
  771. type: 'macho',
  772. candidates: [],
  773. features: {
  774. has_debug_info: false,
  775. has_sources: false,
  776. has_symbols: false,
  777. has_unwind_info: false,
  778. },
  779. },
  780. {
  781. code_file:
  782. '/private/var/containers/Bundle/Application/575F9D39-D486-4728-B035-84923A0BE206/sentry-ios-cocoapods.app/Frameworks/Sentry.framework/Sentry',
  783. debug_id: '141a9203-b953-3cd6-b9fd-7ba60191a36d',
  784. image_addr: '0x1000a4000',
  785. image_size: 163840,
  786. image_vmaddr: '0x0',
  787. type: 'macho',
  788. candidates: [],
  789. features: {
  790. has_debug_info: false,
  791. has_sources: false,
  792. has_symbols: false,
  793. has_unwind_info: false,
  794. },
  795. },
  796. {
  797. code_file:
  798. '/private/var/containers/Bundle/Application/575F9D39-D486-4728-B035-84923A0BE206/sentry-ios-cocoapods.app/Frameworks/Sentry.framework/Sentry',
  799. debug_id: '141a9203-b953-3cd6-b9fd-7ba60191a36d',
  800. image_addr: '0x1000a4000',
  801. image_size: 163840,
  802. image_vmaddr: '0x0',
  803. type: 'macho',
  804. candidates: [],
  805. features: {
  806. has_debug_info: false,
  807. has_sources: false,
  808. has_symbols: false,
  809. has_unwind_info: false,
  810. },
  811. },
  812. ],
  813. },
  814. type: EntryType.DEBUGMETA,
  815. },
  816. ],
  817. dist: '1',
  818. message: '',
  819. title: 'ViewController.causeCrash | main',
  820. location: null,
  821. user: {
  822. id: '1234',
  823. email: 'hello@sentry.io',
  824. username: null,
  825. ip_address: '172.18.0.1',
  826. name: null,
  827. data: null,
  828. },
  829. type: EventOrGroupType.ERROR,
  830. metadata: {
  831. display_title_with_tree_label: true,
  832. finest_tree_label: [
  833. {
  834. function: 'ViewController.causeCrash',
  835. },
  836. {
  837. function: 'main',
  838. },
  839. ],
  840. function: 'ViewController.causeCrash',
  841. value:
  842. 'Attempted to dereference null pointer.\nOriginated at or in a subcall of ViewController.causeCrash(Any) -> ()',
  843. },
  844. platform: 'cocoa',
  845. dateReceived: '2021-11-02T07:33:38.831104Z',
  846. errors: [
  847. {
  848. type: 'invalid_data',
  849. message: 'Discarded invalid value',
  850. data: {
  851. name: 'threads.values.9.stacktrace.frames',
  852. reason: 'expected a non-empty value',
  853. },
  854. },
  855. ],
  856. crashFile: null,
  857. culprit: '',
  858. dateCreated: '2021-11-02T07:33:38.831104Z',
  859. fingerprints: ['852f6cf1ed76d284b95e7d62275088ca'],
  860. groupingConfig: {
  861. enhancements: 'eJybzDRxY25-UmZOqpWRgZGhroGJroHRBABbUQb_',
  862. id: 'mobile:2021-02-12',
  863. },
  864. tags: [],
  865. contexts: {},
  866. userReport: null,
  867. sdkUpdates: [],
  868. nextEventID: null,
  869. previousEventID: null,
  870. };
  871. const props: React.ComponentProps<typeof ThreadsV2> = {
  872. data: event.entries[1].data as React.ComponentProps<typeof ThreadsV2>['data'],
  873. event,
  874. groupingCurrentLevel: 0,
  875. hasHierarchicalGrouping: true,
  876. projectId: project.id,
  877. };
  878. it('renders', function () {
  879. const {container} = render(
  880. <TestComponent organization={org} router={router}>
  881. <ThreadsV2 {...props} />
  882. </TestComponent>,
  883. {organization: org}
  884. );
  885. // Title
  886. expect(screen.getByTestId('thread-selector')).toBeInTheDocument();
  887. // Actions
  888. expect(
  889. screen.getByRole('button', {name: 'Full Stack Trace'})
  890. ).toBeInTheDocument();
  891. expect(screen.getByRole('button', {name: 'Full Stack Trace'})).not.toHaveClass(
  892. 'active'
  893. );
  894. expect(screen.getByRole('button', {name: 'Options'})).toBeInTheDocument();
  895. // Stack Trace
  896. expect(screen.getByRole('heading', {name: 'EXC_BAD_ACCESS'})).toBeInTheDocument();
  897. expect(
  898. screen.getByText(
  899. 'Attempted to dereference null pointer. Originated at or in a subcall of ViewController.causeCrash(Any) -> ()'
  900. )
  901. ).toBeInTheDocument();
  902. expect(screen.getByTestId('stack-trace')).toBeInTheDocument();
  903. expect(screen.queryAllByTestId('stack-trace-frame')).toHaveLength(3);
  904. expect(container).toSnapshot();
  905. });
  906. it('toggle full stack trace button', function () {
  907. render(
  908. <TestComponent organization={org} router={router}>
  909. <ThreadsV2 {...props} />
  910. </TestComponent>,
  911. {organization: org}
  912. );
  913. expect(screen.queryAllByTestId('stack-trace-frame')).toHaveLength(3);
  914. expect(screen.getByRole('button', {name: 'Full Stack Trace'})).not.toHaveClass(
  915. 'active'
  916. );
  917. userEvent.click(screen.getByRole('button', {name: 'Full Stack Trace'}));
  918. expect(screen.getByRole('button', {name: 'Full Stack Trace'})).toHaveClass(
  919. 'active'
  920. );
  921. expect(screen.queryAllByTestId('stack-trace-frame')).toHaveLength(4);
  922. });
  923. it('toggle sort by option', function () {
  924. render(
  925. <TestComponent organization={org} router={router}>
  926. <ThreadsV2 {...props} />
  927. </TestComponent>,
  928. {organization: org}
  929. );
  930. expect(
  931. within(screen.getAllByTestId('stack-trace-frame')[0]).getByText(
  932. '-[SentryClient crash]'
  933. )
  934. ).toBeInTheDocument();
  935. userEvent.click(screen.getByRole('button', {name: 'Newest'}));
  936. // Sort by options
  937. expect(screen.getAllByText('Newest')).toHaveLength(2);
  938. expect(screen.getByText('Oldest')).toBeInTheDocument();
  939. // Recent first is checked by default
  940. expect(
  941. within(screen.getByTestId('recent-first')).getByTestId('icon-check-mark')
  942. ).toBeInTheDocument();
  943. // Click on recent last
  944. userEvent.click(screen.getByText('Oldest'));
  945. // Recent last is enabled
  946. expect(screen.queryByText('Newest')).not.toBeInTheDocument();
  947. expect(screen.getByText('Oldest')).toBeInTheDocument();
  948. // Last frame is the first on the list
  949. expect(
  950. within(screen.getAllByTestId('stack-trace-frame')[0]).getByText('UIKit')
  951. ).toBeInTheDocument();
  952. // Switch back to recent first
  953. userEvent.click(screen.getByRole('button', {name: 'Oldest'}));
  954. userEvent.click(screen.getByText('Newest'));
  955. // First frame is the first on the list
  956. expect(
  957. within(screen.getAllByTestId('stack-trace-frame')[0]).getByText(
  958. '-[SentryClient crash]'
  959. )
  960. ).toBeInTheDocument();
  961. });
  962. it('check display options', async function () {
  963. render(
  964. <TestComponent organization={org} router={router}>
  965. <ThreadsV2 {...props} />
  966. </TestComponent>,
  967. {organization: org}
  968. );
  969. userEvent.click(screen.getByRole('button', {name: 'Options'}));
  970. expect(await screen.findByText('Display')).toBeInTheDocument();
  971. Object.values(displayOptions).forEach(value => {
  972. expect(screen.getByText(value)).toBeInTheDocument();
  973. });
  974. // Hover over absolute file paths option
  975. userEvent.hover(screen.getByText(displayOptions['absolute-file-paths']));
  976. // Absolute file paths option is disabled
  977. expect(
  978. await screen.findByText('Absolute file paths not available')
  979. ).toBeInTheDocument();
  980. // Hover over Minified option
  981. userEvent.hover(screen.getByText(displayOptions.minified));
  982. // Minified option is disabled
  983. expect(
  984. await screen.findByText('Unsymbolicated version not available')
  985. ).toBeInTheDocument();
  986. // Function name is not verbose
  987. expect(
  988. within(screen.getAllByTestId('stack-trace-frame')[1]).getByText(
  989. 'ViewController.causeCrash'
  990. )
  991. ).toBeInTheDocument();
  992. // Click on verbose function name option
  993. userEvent.click(screen.getByText(displayOptions['verbose-function-names']));
  994. // Function name is now verbose
  995. expect(
  996. within(screen.getAllByTestId('stack-trace-frame')[1]).getByText(
  997. 'ViewController.causeCrash(Any) -> ()'
  998. )
  999. ).toBeInTheDocument();
  1000. // Address is not absolute
  1001. expect(
  1002. within(screen.getAllByTestId('stack-trace-frame')[1]).getByText('+0x085ac')
  1003. ).toBeInTheDocument();
  1004. // Click on absolute file paths option
  1005. userEvent.click(screen.getByText(displayOptions['absolute-addresses']));
  1006. // Address is now absolute
  1007. expect(
  1008. within(screen.getAllByTestId('stack-trace-frame')[1]).getByText('0x10008c5ac')
  1009. ).toBeInTheDocument();
  1010. // Click on raw stack trace option
  1011. MockApiClient.warnOnMissingMocks();
  1012. userEvent.click(screen.getByText(displayOptions['raw-stack-trace']));
  1013. // Download button is displayed
  1014. expect(screen.getByRole('button', {name: 'Download'})).toBeInTheDocument();
  1015. // Full stack trace toggler is not displayed
  1016. expect(
  1017. screen.queryByRole('button', {name: 'Full Stack Trace'})
  1018. ).not.toBeInTheDocument();
  1019. // Raw content is displayed
  1020. expect(screen.queryByRole('list', {name: 'Stack trace'})).not.toBeInTheDocument();
  1021. // Raw content and the Raw stack trace option
  1022. expect(screen.getAllByTestId('raw-stack-trace')).toHaveLength(2);
  1023. });
  1024. });
  1025. });
  1026. });