index.spec.tsx 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. });
  38. afterEach(function () {
  39. MockApiClient.clearMockResponses();
  40. });
  41. it('renders', async function () {
  42. render(
  43. <RouteContext.Provider value={{router, ...router}}>
  44. <SharedGroupDetails
  45. params={params}
  46. api={new MockApiClient()}
  47. route={{}}
  48. router={router}
  49. routes={router.routes}
  50. routeParams={router.params}
  51. location={router.location}
  52. />
  53. </RouteContext.Provider>
  54. );
  55. await waitFor(() => expect(screen.getByText('Details')).toBeInTheDocument());
  56. });
  57. it('renders with org slug in path', async function () {
  58. const params_with_slug = {shareId: 'a', orgId: 'test-org'};
  59. const router_with_slug = RouterFixture({params_with_slug});
  60. render(
  61. <RouteContext.Provider value={{router, ...router}}>
  62. <SharedGroupDetails
  63. params={params}
  64. api={new MockApiClient()}
  65. route={{}}
  66. router={router_with_slug}
  67. routes={router_with_slug.routes}
  68. routeParams={router_with_slug.params}
  69. location={router_with_slug.location}
  70. />
  71. </RouteContext.Provider>
  72. );
  73. await waitFor(() => expect(screen.getByText('Details')).toBeInTheDocument());
  74. });
  75. });