index.spec.tsx 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. import {EventFixture} from 'sentry-fixture/event';
  2. import {EntryDebugMetaFixture} from 'sentry-fixture/eventEntry';
  3. import {ImageFixture} from 'sentry-fixture/image';
  4. import {initializeOrg} from 'sentry-test/initializeOrg';
  5. import {
  6. render,
  7. renderGlobalModal,
  8. screen,
  9. userEvent,
  10. } from 'sentry-test/reactTestingLibrary';
  11. import {DebugMeta} from 'sentry/components/events/interfaces/debugMeta';
  12. import {ImageStatus} from 'sentry/types/debugImage';
  13. describe('DebugMeta', function () {
  14. it('opens details modal', async function () {
  15. const eventEntryDebugMeta = EntryDebugMetaFixture();
  16. const event = EventFixture({entries: [eventEntryDebugMeta]});
  17. const {organization, project} = initializeOrg();
  18. const image = eventEntryDebugMeta.data.images[0];
  19. const mockGetDebug = MockApiClient.addMockResponse({
  20. url: `/projects/${organization.slug}/${project.slug}/files/dsyms/?debug_id=${image?.debug_id}`,
  21. method: 'GET',
  22. body: [],
  23. });
  24. render(
  25. <DebugMeta
  26. projectSlug={project.slug}
  27. event={event}
  28. data={eventEntryDebugMeta.data}
  29. />,
  30. {organization}
  31. );
  32. renderGlobalModal();
  33. screen.getByRole('heading', {name: 'Images Loaded'});
  34. const imageName = image?.debug_file as string;
  35. expect(screen.queryByText(imageName)).not.toBeInTheDocument();
  36. await userEvent.click(screen.getByRole('button', {name: 'Show Details'}));
  37. expect(screen.getByText('Ok')).toBeInTheDocument();
  38. expect(screen.getByText(imageName)).toBeInTheDocument();
  39. expect(screen.getByText('Symbolication')).toBeInTheDocument();
  40. expect(mockGetDebug).not.toHaveBeenCalled();
  41. const codeFile = image?.code_file as string;
  42. expect(screen.queryByText(codeFile)).not.toBeInTheDocument();
  43. await userEvent.click(screen.getByRole('button', {name: 'View'}));
  44. expect(screen.getByText(codeFile)).toBeInTheDocument();
  45. expect(mockGetDebug).toHaveBeenCalled();
  46. });
  47. it('searches image contents', async function () {
  48. const eventEntryDebugMeta = EntryDebugMetaFixture();
  49. const event = EventFixture({entries: [eventEntryDebugMeta]});
  50. const {organization, project} = initializeOrg();
  51. const image = eventEntryDebugMeta.data.images[0];
  52. render(
  53. <DebugMeta
  54. projectSlug={project.slug}
  55. event={event}
  56. data={eventEntryDebugMeta.data}
  57. />,
  58. {organization}
  59. );
  60. const imageName = image?.debug_file as string;
  61. const codeFile = image?.code_file as string;
  62. screen.getByRole('heading', {name: 'Images Loaded'});
  63. await userEvent.click(screen.getByRole('button', {name: 'Show Details'}));
  64. const imageNode = screen.getByText(imageName);
  65. expect(imageNode).toBeInTheDocument();
  66. const searchBar = screen.getByRole('textbox');
  67. await userEvent.type(searchBar, 'some jibberish');
  68. expect(screen.queryByText(imageName)).not.toBeInTheDocument();
  69. expect(
  70. screen.getByText('Sorry, no images match your search query')
  71. ).toBeInTheDocument();
  72. await userEvent.clear(searchBar);
  73. expect(screen.getByText(imageName)).toBeInTheDocument();
  74. await userEvent.type(searchBar, codeFile);
  75. expect(screen.getByText(imageName)).toBeInTheDocument();
  76. });
  77. it('filters images', async function () {
  78. const firstImage = ImageFixture();
  79. const secondImage = {
  80. ...ImageFixture(),
  81. debug_status: ImageStatus.MISSING,
  82. debug_file: 'test_file',
  83. code_file: '/Users/foo/Coding/sentry-native/build/./test_file',
  84. };
  85. const eventEntryDebugMeta = {
  86. ...EntryDebugMetaFixture(),
  87. data: {
  88. images: [firstImage, secondImage],
  89. },
  90. };
  91. const event = EventFixture({entries: [eventEntryDebugMeta]});
  92. const {organization, project} = initializeOrg();
  93. render(
  94. <DebugMeta
  95. projectSlug={project.slug}
  96. event={event}
  97. data={eventEntryDebugMeta.data}
  98. />,
  99. {organization}
  100. );
  101. screen.getByRole('heading', {name: 'Images Loaded'});
  102. await userEvent.click(screen.getByRole('button', {name: 'Show Details'}));
  103. expect(screen.getByText(firstImage?.debug_file as string)).toBeInTheDocument();
  104. expect(screen.getByText(secondImage?.debug_file as string)).toBeInTheDocument();
  105. const filterButton = screen.getByRole('button', {name: '2 Active Filters'});
  106. expect(filterButton).toBeInTheDocument();
  107. await userEvent.click(filterButton);
  108. await userEvent.click(screen.getByRole('option', {name: 'Missing'}));
  109. expect(screen.getByText(firstImage?.debug_file as string)).toBeInTheDocument();
  110. expect(screen.queryByText(secondImage?.debug_file as string)).not.toBeInTheDocument();
  111. });
  112. });