eventAttachments.spec.tsx 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import {initializeOrg} from 'sentry-test/initializeOrg';
  2. import {render, screen} from 'sentry-test/reactTestingLibrary';
  3. import {EventAttachments} from 'sentry/components/events/eventAttachments';
  4. describe('EventAttachments', function () {
  5. const {routerContext, organization, project} = initializeOrg();
  6. const event = TestStubs.Event({metadata: {stripped_crash: true}});
  7. const props = {
  8. orgId: organization.slug,
  9. projectId: project.slug,
  10. location: routerContext.context.location,
  11. attachments: [],
  12. onDeleteAttachment: jest.fn(),
  13. event,
  14. };
  15. it('shows attachments limit reached notice', function () {
  16. render(<EventAttachments {...props} />, {context: routerContext});
  17. expect(screen.getByText('Attachments (0)')).toBeInTheDocument();
  18. expect(screen.getByRole('link', {name: 'View crashes'})).toHaveAttribute(
  19. 'href',
  20. '/organizations/org-slug/issues/1/attachments/?types=event.minidump&types=event.applecrashreport'
  21. );
  22. expect(screen.getByRole('link', {name: 'configure limit'})).toHaveAttribute(
  23. 'href',
  24. `/settings/${props.orgId}/projects/${props.projectId}/security-and-privacy/`
  25. );
  26. expect(
  27. screen.getByText(
  28. 'Your limit of stored crash reports has been reached for this issue.'
  29. )
  30. ).toBeInTheDocument();
  31. });
  32. it('does not render anything if no attachments (nor stripped) are available', function () {
  33. const {container} = render(
  34. <EventAttachments
  35. {...props}
  36. event={{...event, metadata: {stripped_crash: false}}}
  37. />
  38. );
  39. expect(container).toBeEmptyDOMElement();
  40. });
  41. });