nativeContent.spec.tsx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import {EventEntryStacktrace} from 'sentry-fixture/eventEntryStacktrace';
  2. import {Organization} from 'sentry-fixture/organization';
  3. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  4. import StackTraceContent from 'sentry/components/events/interfaces/crashContent/stackTrace/content';
  5. import {EventOrGroupType} from 'sentry/types';
  6. import {StacktraceType} from 'sentry/types/stacktrace';
  7. const eventEntryStacktrace = EventEntryStacktrace();
  8. const event = TestStubs.Event({
  9. entries: [eventEntryStacktrace],
  10. type: EventOrGroupType.ERROR,
  11. });
  12. const data = eventEntryStacktrace.data as Required<StacktraceType>;
  13. function renderedComponent(
  14. props: Partial<React.ComponentProps<typeof StackTraceContent>>
  15. ) {
  16. return render(
  17. <StackTraceContent
  18. data={data}
  19. className="no-exception"
  20. platform="other"
  21. event={event}
  22. newestFirst
  23. includeSystemFrames
  24. {...props}
  25. />
  26. );
  27. }
  28. describe('with stacktrace improvements feature flag enabled', function () {
  29. const organization = Organization({
  30. features: ['issue-details-stacktrace-improvements'],
  31. });
  32. it('does not render non in app tags', function () {
  33. const dataFrames = [...data.frames];
  34. dataFrames[0] = {...dataFrames[0], inApp: false};
  35. const newData = {
  36. ...data,
  37. frames: dataFrames,
  38. };
  39. renderedComponent({
  40. organization,
  41. data: newData,
  42. });
  43. expect(screen.queryByText('System')).not.toBeInTheDocument();
  44. });
  45. it('displays a toggle button when there is more than one non-inapp frame', function () {
  46. const dataFrames = [...data.frames];
  47. dataFrames[0] = {...dataFrames[0], inApp: true};
  48. const newData = {
  49. ...data,
  50. frames: dataFrames,
  51. };
  52. renderedComponent({
  53. organization,
  54. data: newData,
  55. includeSystemFrames: false,
  56. });
  57. expect(screen.getByText('Show 3 more frames')).toBeInTheDocument();
  58. });
  59. it('shows/hides frames when toggle button clicked', async function () {
  60. const dataFrames = [...data.frames];
  61. dataFrames[0] = {...dataFrames[0], inApp: true};
  62. dataFrames[1] = {...dataFrames[1], function: 'non-in-app-frame'};
  63. dataFrames[2] = {...dataFrames[2], function: 'non-in-app-frame'};
  64. dataFrames[3] = {...dataFrames[3], function: 'non-in-app-frame'};
  65. dataFrames[4] = {...dataFrames[4], function: 'non-in-app-frame'};
  66. const newData = {
  67. ...data,
  68. frames: dataFrames,
  69. };
  70. renderedComponent({
  71. organization,
  72. data: newData,
  73. includeSystemFrames: false,
  74. });
  75. await userEvent.click(screen.getByText('Show 3 more frames'));
  76. expect(screen.getAllByText('non-in-app-frame')).toHaveLength(4);
  77. await userEvent.click(screen.getByText('Hide 3 more frames'));
  78. expect(screen.getByText('non-in-app-frame')).toBeInTheDocument();
  79. });
  80. it('does not display a toggle button when there is only one non-inapp frame', function () {
  81. const dataFrames = [...data.frames];
  82. dataFrames[0] = {...dataFrames[0], inApp: true};
  83. dataFrames[2] = {...dataFrames[2], inApp: true};
  84. dataFrames[4] = {...dataFrames[4], inApp: true};
  85. const newData = {
  86. ...data,
  87. frames: dataFrames,
  88. };
  89. renderedComponent({
  90. organization,
  91. data: newData,
  92. includeSystemFrames: false,
  93. });
  94. expect(screen.queryByText(/Show .* more frames*/)).not.toBeInTheDocument();
  95. });
  96. });