index.spec.tsx 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. api={new MockApiClient()}
  51. route={{}}
  52. router={router}
  53. routes={router.routes}
  54. routeParams={router.params}
  55. location={router.location}
  56. />,
  57. {router}
  58. );
  59. await waitFor(() => expect(screen.getByText('Details')).toBeInTheDocument());
  60. });
  61. it('renders with org slug in path', async function () {
  62. const params_with_slug = {shareId: 'a', orgId: 'test-org'};
  63. const router_with_slug = RouterFixture({params_with_slug});
  64. render(
  65. <SharedGroupDetails
  66. params={params}
  67. api={new MockApiClient()}
  68. route={{}}
  69. router={router_with_slug}
  70. routes={router_with_slug.routes}
  71. routeParams={router_with_slug.params}
  72. location={router_with_slug.location}
  73. />,
  74. {router}
  75. );
  76. await waitFor(() => expect(screen.getByText('Details')).toBeInTheDocument());
  77. });
  78. });