index.spec.tsx 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import {EventFixture} from 'sentry-fixture/event';
  2. import {EventEntryFixture} from 'sentry-fixture/eventEntry';
  3. import {EventStacktraceExceptionFixture} from 'sentry-fixture/eventStacktraceException';
  4. import {GroupFixture} from 'sentry-fixture/group';
  5. import {OrganizationFixture} from 'sentry-fixture/organization';
  6. import {ProjectFixture} from 'sentry-fixture/project';
  7. import {RouterFixture} from 'sentry-fixture/routerFixture';
  8. import {render, screen} from 'sentry-test/reactTestingLibrary';
  9. import SharedGroupDetails from 'sentry/views/sharedGroupDetails';
  10. describe('SharedGroupDetails', function () {
  11. const eventEntry = EventEntryFixture();
  12. const exception = EventStacktraceExceptionFixture().entries[0];
  13. const params = {shareId: 'a'};
  14. const router = RouterFixture({params});
  15. beforeEach(function () {
  16. MockApiClient.addMockResponse({
  17. url: `/organizations/test-org/projects/`,
  18. method: 'GET',
  19. body: [],
  20. });
  21. MockApiClient.addMockResponse({
  22. url: '/organizations/org-slug/shared/issues/a/',
  23. body: GroupFixture({
  24. title: 'ZeroDivisionError',
  25. latestEvent: EventFixture({
  26. entries: [eventEntry, exception],
  27. }),
  28. project: ProjectFixture({organization: OrganizationFixture({slug: 'test-org'})}),
  29. }),
  30. });
  31. MockApiClient.addMockResponse({
  32. url: '/shared/issues/a/',
  33. body: GroupFixture({
  34. title: 'ZeroDivisionError',
  35. latestEvent: EventFixture({
  36. entries: [eventEntry, exception],
  37. }),
  38. project: ProjectFixture({organization: OrganizationFixture({slug: 'test-org'})}),
  39. }),
  40. });
  41. MockApiClient.addMockResponse({
  42. url: `/projects/test-org/project-slug/events/1/actionable-items/`,
  43. body: {
  44. errors: [],
  45. },
  46. });
  47. });
  48. afterEach(function () {
  49. MockApiClient.clearMockResponses();
  50. });
  51. it('renders', async function () {
  52. render(
  53. <SharedGroupDetails
  54. params={params}
  55. route={{}}
  56. router={router}
  57. routes={router.routes}
  58. routeParams={router.params}
  59. location={router.location}
  60. />,
  61. {router}
  62. );
  63. await screen.findByText('Details');
  64. });
  65. it('renders with org slug in path', async function () {
  66. const params_with_slug = {shareId: 'a', orgId: 'test-org'};
  67. const router_with_slug = RouterFixture({params_with_slug});
  68. render(
  69. <SharedGroupDetails
  70. params={params}
  71. route={{}}
  72. router={router_with_slug}
  73. routes={router_with_slug.routes}
  74. routeParams={router_with_slug.params}
  75. location={router_with_slug.location}
  76. />,
  77. {router}
  78. );
  79. await screen.findByText('Details');
  80. await screen.findByTestId('sgh-timestamp');
  81. });
  82. });