eventOrGroupTitle.spec.jsx 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import {render, screen} from 'sentry-test/reactTestingLibrary';
  2. import EventOrGroupTitle from 'sentry/components/eventOrGroupTitle';
  3. describe('EventOrGroupTitle', function () {
  4. const data = {
  5. metadata: {
  6. type: 'metadata type',
  7. directive: 'metadata directive',
  8. uri: 'metadata uri',
  9. },
  10. culprit: 'culprit',
  11. };
  12. it('renders with subtitle when `type = error`', function () {
  13. const wrapper = render(
  14. <EventOrGroupTitle
  15. data={{
  16. ...data,
  17. ...{
  18. type: 'error',
  19. },
  20. }}
  21. />
  22. );
  23. expect(wrapper.container).toSnapshot();
  24. });
  25. it('renders with subtitle when `type = csp`', function () {
  26. const wrapper = render(
  27. <EventOrGroupTitle
  28. data={{
  29. ...data,
  30. ...{
  31. type: 'csp',
  32. },
  33. }}
  34. />
  35. );
  36. expect(wrapper.container).toSnapshot();
  37. });
  38. it('renders with no subtitle when `type = default`', function () {
  39. const wrapper = render(
  40. <EventOrGroupTitle
  41. data={{
  42. ...data,
  43. type: 'default',
  44. metadata: {
  45. ...data.metadata,
  46. title: 'metadata title',
  47. },
  48. }}
  49. />
  50. );
  51. expect(wrapper.container).toSnapshot();
  52. });
  53. it('renders with title override', function () {
  54. const routerContext = TestStubs.routerContext([
  55. {organization: TestStubs.Organization({features: ['custom-event-title']})},
  56. ]);
  57. render(
  58. <EventOrGroupTitle
  59. data={{
  60. ...data,
  61. type: 'error',
  62. metadata: {
  63. ...data.metadata,
  64. title: 'metadata title',
  65. },
  66. }}
  67. />,
  68. {context: routerContext}
  69. );
  70. expect(screen.getByText('metadata title')).toBeInTheDocument();
  71. });
  72. });