errorItem.spec.tsx 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import {initializeOrg} from 'sentry-test/initializeOrg';
  2. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  3. import {textWithMarkupMatcher} from 'sentry-test/utils';
  4. import {ErrorItem} from 'sentry/components/events/errorItem';
  5. import {OrganizationContext} from 'sentry/views/organizationContext';
  6. import {RouteContext} from 'sentry/views/routeContext';
  7. describe('Issue error item', function () {
  8. it('expand subitems', function () {
  9. const {organization, router} = initializeOrg();
  10. render(
  11. <OrganizationContext.Provider value={organization}>
  12. <RouteContext.Provider
  13. value={{
  14. router,
  15. location: router.location,
  16. params: {},
  17. routes: [],
  18. }}
  19. >
  20. <ErrorItem
  21. error={{
  22. data: {
  23. mapping_uuid: 'd270a1a0-1970-3c05-cb09-2cb00b4335ee',
  24. },
  25. type: 'proguard_missing_mapping',
  26. message: 'A proguard mapping file was missing.',
  27. }}
  28. />
  29. </RouteContext.Provider>
  30. </OrganizationContext.Provider>
  31. );
  32. expect(screen.getByText('A proguard mapping file was missing.')).toBeInTheDocument();
  33. expect(screen.queryByText('Mapping Uuid')).not.toBeInTheDocument();
  34. userEvent.click(screen.getByLabelText('Expand'));
  35. expect(screen.getByText('Mapping Uuid')).toBeInTheDocument();
  36. });
  37. it('display redacted data', async function () {
  38. const {organization, router} = initializeOrg();
  39. render(
  40. <OrganizationContext.Provider value={organization}>
  41. <RouteContext.Provider
  42. value={{
  43. router,
  44. location: router.location,
  45. params: {},
  46. routes: [],
  47. }}
  48. >
  49. <ErrorItem
  50. error={{
  51. data: {
  52. image_path: '',
  53. image_uuid: '6b77ffb6-5aba-3b5f-9171-434f9660f738',
  54. message: '',
  55. },
  56. message: 'A required debug information file was missing.',
  57. type: 'native_missing_dsym',
  58. }}
  59. meta={{
  60. image_path: {'': {rem: [['project:2', 's', 0, 0]], len: 117}},
  61. }}
  62. />
  63. </RouteContext.Provider>
  64. </OrganizationContext.Provider>
  65. );
  66. userEvent.click(screen.getByLabelText('Expand'));
  67. expect(screen.getByText('File Name')).toBeInTheDocument();
  68. expect(screen.getByText('File Path')).toBeInTheDocument();
  69. expect(screen.getAllByText(/redacted/)).toHaveLength(2);
  70. userEvent.hover(screen.getAllByText(/redacted/)[0]);
  71. expect(
  72. await screen.findByText(
  73. textWithMarkupMatcher('Replaced because of the PII rule project:2')
  74. ) // Fall back case
  75. ).toBeInTheDocument(); // tooltip description
  76. });
  77. });