imageDetailsCandidates.spec.tsx 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import {mountWithTheme} from 'sentry-test/enzyme';
  2. import {openModal} from 'sentry/actionCreators/modal';
  3. import DebugImageDetails, {
  4. modalCss,
  5. } from 'sentry/components/events/interfaces/debugMeta/debugImageDetails';
  6. import {getFileName} from 'sentry/components/events/interfaces/debugMeta/utils';
  7. import GlobalModal from 'sentry/components/globalModal';
  8. describe('Debug Meta - Image Details Candidates', function () {
  9. let wrapper: ReturnType<typeof mountWithTheme>;
  10. const projSlug = 'foo';
  11. const organization = TestStubs.Organization();
  12. const event = TestStubs.Event();
  13. const eventEntryDebugMeta = TestStubs.EventEntryDebugMeta();
  14. const {data} = eventEntryDebugMeta;
  15. const {images} = data;
  16. const debugImage = images[0];
  17. beforeAll(async function () {
  18. MockApiClient.addMockResponse({
  19. url: `/projects/${organization.slug}/${projSlug}/files/dsyms/?debug_id=${debugImage.debug_id}`,
  20. method: 'GET',
  21. body: [],
  22. });
  23. MockApiClient.addMockResponse({
  24. url: `/builtin-symbol-sources/`,
  25. method: 'GET',
  26. body: [],
  27. });
  28. wrapper = mountWithTheme(<GlobalModal />);
  29. openModal(
  30. modalProps => (
  31. <DebugImageDetails
  32. {...modalProps}
  33. image={debugImage}
  34. organization={organization}
  35. projSlug={projSlug}
  36. event={event}
  37. />
  38. ),
  39. {
  40. modalCss,
  41. onClose: jest.fn(),
  42. }
  43. );
  44. await tick();
  45. wrapper.update();
  46. });
  47. it('Image Details Modal is open', () => {
  48. const fileName = wrapper.find('Title FileName');
  49. expect(fileName.text()).toEqual(getFileName(debugImage.code_file));
  50. });
  51. it('Image Candidates correctly sorted', () => {
  52. const candidates = wrapper.find('Candidate');
  53. // Check status order.
  54. // The UI shall sort the candidates by status. However, this sorting is not alphabetical but in the following order:
  55. // Permissions -> Failed -> Ok -> Deleted (previous Ok) -> Unapplied -> Not Found
  56. const statusColumns = candidates
  57. .find('Status')
  58. .map(statusColumn => statusColumn.text());
  59. expect(statusColumns).toEqual(['Failed', 'Failed', 'Failed', 'Deleted']);
  60. const informationColumn = candidates.find('InformationColumn');
  61. // Check source names order.
  62. // The UI shall sort the candidates by source name (alphabetical)
  63. const sourceNames = informationColumn
  64. .find('[data-test-id="source_name"]')
  65. .map(sourceName => sourceName.text());
  66. expect(sourceNames).toEqual(['America', 'Austria', 'Belgium', 'Sentry']);
  67. // Check location order.
  68. // The UI shall sort the candidates by source location (alphabetical)
  69. const locations = informationColumn
  70. .find('FilenameOrLocation')
  71. .map(location => location.text());
  72. // Only 3 results are returned, as the UI only displays the Location component
  73. // when the location is defined and when it is not internal
  74. expect(locations).toEqual(['arizona', 'burgenland', 'brussels']);
  75. });
  76. });