index.spec.tsx 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 {RouteContext} from 'sentry/views/routeContext';
  10. import SharedGroupDetails from 'sentry/views/sharedGroupDetails';
  11. describe('SharedGroupDetails', function () {
  12. const eventEntry = EventEntryFixture();
  13. const exception = EventStacktraceExceptionFixture().entries[0];
  14. const params = {shareId: 'a'};
  15. const router = RouterFixture({params});
  16. beforeEach(function () {
  17. MockApiClient.addMockResponse({
  18. url: '/organizations/org-slug/shared/issues/a/',
  19. body: GroupFixture({
  20. title: 'ZeroDivisionError',
  21. latestEvent: EventFixture({
  22. entries: [eventEntry, exception],
  23. }),
  24. project: ProjectFixture({organization: OrganizationFixture({slug: 'test-org'})}),
  25. }),
  26. });
  27. MockApiClient.addMockResponse({
  28. url: '/shared/issues/a/',
  29. body: GroupFixture({
  30. title: 'ZeroDivisionError',
  31. latestEvent: EventFixture({
  32. entries: [eventEntry, exception],
  33. }),
  34. project: ProjectFixture({organization: OrganizationFixture({slug: 'test-org'})}),
  35. }),
  36. });
  37. MockApiClient.addMockResponse({
  38. url: `/projects/test-org/project-slug/events/1/actionable-items/`,
  39. body: {
  40. errors: [],
  41. },
  42. });
  43. });
  44. afterEach(function () {
  45. MockApiClient.clearMockResponses();
  46. });
  47. it('renders', async function () {
  48. render(
  49. <RouteContext.Provider value={{router, ...router}}>
  50. <SharedGroupDetails
  51. params={params}
  52. api={new MockApiClient()}
  53. route={{}}
  54. router={router}
  55. routes={router.routes}
  56. routeParams={router.params}
  57. location={router.location}
  58. />
  59. </RouteContext.Provider>
  60. );
  61. await waitFor(() => expect(screen.getByText('Details')).toBeInTheDocument());
  62. });
  63. it('renders with org slug in path', async function () {
  64. const params_with_slug = {shareId: 'a', orgId: 'test-org'};
  65. const router_with_slug = RouterFixture({params_with_slug});
  66. render(
  67. <RouteContext.Provider value={{router, ...router}}>
  68. <SharedGroupDetails
  69. params={params}
  70. api={new MockApiClient()}
  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. </RouteContext.Provider>
  78. );
  79. await waitFor(() => expect(screen.getByText('Details')).toBeInTheDocument());
  80. });
  81. });