eventAttachments.spec.tsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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} />);
  17. expect(screen.getByText('Attachments (0)')).toBeInTheDocument();
  18. expect(screen.getByRole('link', {name: 'View crashes'})).toHaveAttribute('href', '');
  19. expect(screen.getByRole('link', {name: 'configure limit'})).toHaveAttribute(
  20. 'href',
  21. `/settings/${props.orgId}/projects/${props.projectId}/security-and-privacy/`
  22. );
  23. expect(
  24. screen.getByText(
  25. 'Your limit of stored crash reports has been reached for this issue.'
  26. )
  27. ).toBeInTheDocument();
  28. });
  29. it('does not render anything if no attachments (nor stripped) are available', function () {
  30. const {container} = render(
  31. <EventAttachments
  32. {...props}
  33. event={{...event, metadata: {stripped_crash: false}}}
  34. />
  35. );
  36. expect(container).toBeEmptyDOMElement();
  37. });
  38. });