index.spec.tsx 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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, waitFor} 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/org-slug/shared/issues/a/',
  18. body: GroupFixture({
  19. title: 'ZeroDivisionError',
  20. latestEvent: EventFixture({
  21. entries: [eventEntry, exception],
  22. }),
  23. project: ProjectFixture({organization: OrganizationFixture({slug: 'test-org'})}),
  24. }),
  25. });
  26. MockApiClient.addMockResponse({
  27. url: '/shared/issues/a/',
  28. body: GroupFixture({
  29. title: 'ZeroDivisionError',
  30. latestEvent: EventFixture({
  31. entries: [eventEntry, exception],
  32. }),
  33. project: ProjectFixture({organization: OrganizationFixture({slug: 'test-org'})}),
  34. }),
  35. });
  36. MockApiClient.addMockResponse({
  37. url: `/projects/test-org/project-slug/events/1/actionable-items/`,
  38. body: {
  39. errors: [],
  40. },
  41. });
  42. });
  43. afterEach(function () {
  44. MockApiClient.clearMockResponses();
  45. });
  46. it('renders', async function () {
  47. render(
  48. <SharedGroupDetails
  49. params={params}
  50. route={{}}
  51. router={router}
  52. routes={router.routes}
  53. routeParams={router.params}
  54. location={router.location}
  55. />,
  56. {router}
  57. );
  58. await waitFor(() => expect(screen.getByText('Details')).toBeInTheDocument());
  59. });
  60. it('renders with org slug in path', async function () {
  61. const params_with_slug = {shareId: 'a', orgId: 'test-org'};
  62. const router_with_slug = RouterFixture({params_with_slug});
  63. render(
  64. <SharedGroupDetails
  65. params={params}
  66. route={{}}
  67. router={router_with_slug}
  68. routes={router_with_slug.routes}
  69. routeParams={router_with_slug.params}
  70. location={router_with_slug.location}
  71. />,
  72. {router}
  73. );
  74. await waitFor(() => expect(screen.getByText('Details')).toBeInTheDocument());
  75. await waitFor(() => expect(screen.getByTestId('sgh-timestamp')).toBeInTheDocument());
  76. });
  77. });