eventsTableRow.spec.jsx 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. import {initializeOrg} from 'sentry-test/initializeOrg';
  2. import {render, screen} from 'sentry-test/reactTestingLibrary';
  3. import EventsTableRow from 'sentry/components/eventsTable/eventsTableRow';
  4. describe('EventsTableRow', function () {
  5. const {organization, router, routerContext} = initializeOrg({
  6. organization: TestStubs.Organization(),
  7. project: TestStubs.Project(),
  8. projects: [TestStubs.Project()],
  9. router: {
  10. routes: [
  11. {
  12. path: '/',
  13. },
  14. {
  15. path: '/organizations/:orgId/issues/:groupId/',
  16. },
  17. {
  18. path: 'events/',
  19. },
  20. ],
  21. },
  22. });
  23. it('renders', function () {
  24. const {container} = render(
  25. <table>
  26. <tbody>
  27. <EventsTableRow
  28. organization={organization}
  29. tagList={[]}
  30. {...{orgId: 'orgId', projectId: 'projectId', groupId: 'groupId'}}
  31. event={TestStubs.DetailedEvents()[0]}
  32. />
  33. </tbody>
  34. </table>
  35. );
  36. expect(container).toSnapshot();
  37. });
  38. it('does not render the replay button when there is no replay', () => {
  39. render(
  40. <table>
  41. <tbody>
  42. <EventsTableRow
  43. organization={organization}
  44. tagList={[
  45. {
  46. key: 'replayId',
  47. name: 'Replayid',
  48. totalValues: 5,
  49. },
  50. ]}
  51. {...{orgId: 'orgId', projectId: 'projectId', groupId: 'groupId'}}
  52. event={TestStubs.DetailedEvents()[0]}
  53. />
  54. </tbody>
  55. </table>,
  56. {context: routerContext, router}
  57. );
  58. expect(screen.queryAllByRole('cell').length).toBe(2);
  59. expect(screen.queryByLabelText('View Full Replay')).not.toBeInTheDocument();
  60. });
  61. it('renders the replay column with a correct link', () => {
  62. const event = TestStubs.DetailedEvents()[0];
  63. render(
  64. <table>
  65. <tbody>
  66. <EventsTableRow
  67. organization={organization}
  68. tagList={[
  69. {
  70. key: 'replayId',
  71. name: 'Replayid',
  72. totalValues: 5,
  73. },
  74. ]}
  75. {...{orgId: 'orgId', projectId: 'projectId', groupId: 'groupId'}}
  76. event={{
  77. ...event,
  78. tags: [
  79. {
  80. key: 'replayId',
  81. value: 'test-replay-id',
  82. },
  83. ],
  84. }}
  85. />
  86. </tbody>
  87. </table>,
  88. {context: routerContext, router}
  89. );
  90. expect(screen.queryAllByRole('cell').length).toBe(2);
  91. expect(screen.queryByLabelText('View Full Replay')).toHaveAttribute(
  92. 'href',
  93. `/organizations/org-slug/replays/projectId:test-replay-id/?event_t=${new Date(
  94. event.dateCreated
  95. ).getTime()}&referrer=%2Forganizations%2F%3AorgId%2Fissues%2F%3AgroupId%2Fevents%2F`
  96. );
  97. });
  98. });