index.spec.tsx 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import {Event as EventFixture} from 'sentry-fixture/event';
  2. import {Organization} from 'sentry-fixture/organization';
  3. import {Project as ProjectFixture} from 'sentry-fixture/project';
  4. import {render} from 'sentry-test/reactTestingLibrary';
  5. import {RouteContext} from 'sentry/views/routeContext';
  6. import SharedGroupDetails from 'sentry/views/sharedGroupDetails';
  7. describe('SharedGroupDetails', function () {
  8. const eventEntry = TestStubs.EventEntry();
  9. const exception = TestStubs.EventStacktraceException().entries[0];
  10. const params = {shareId: 'a'};
  11. const router = TestStubs.router({params});
  12. beforeEach(function () {
  13. MockApiClient.addMockResponse({
  14. url: '/organizations/org-slug/shared/issues/a/',
  15. body: TestStubs.Group({
  16. title: 'ZeroDivisionError',
  17. latestEvent: EventFixture({
  18. entries: [eventEntry, exception],
  19. }),
  20. project: ProjectFixture({organization: Organization({slug: 'test-org'})}),
  21. }),
  22. });
  23. MockApiClient.addMockResponse({
  24. url: '/shared/issues/a/',
  25. body: TestStubs.Group({
  26. title: 'ZeroDivisionError',
  27. latestEvent: EventFixture({
  28. entries: [eventEntry, exception],
  29. }),
  30. project: ProjectFixture({organization: Organization({slug: 'test-org'})}),
  31. }),
  32. });
  33. });
  34. afterEach(function () {
  35. MockApiClient.clearMockResponses();
  36. });
  37. it('renders', function () {
  38. render(
  39. <RouteContext.Provider value={{router, ...router}}>
  40. <SharedGroupDetails
  41. params={params}
  42. api={new MockApiClient()}
  43. route={{}}
  44. router={router}
  45. routes={router.routes}
  46. routeParams={router.params}
  47. location={router.location}
  48. />
  49. </RouteContext.Provider>
  50. );
  51. });
  52. it('renders with org slug in path', function () {
  53. const params_with_slug = {shareId: 'a', orgId: 'test-org'};
  54. const router_with_slug = TestStubs.router({params_with_slug});
  55. render(
  56. <RouteContext.Provider value={{router, ...router}}>
  57. <SharedGroupDetails
  58. params={params}
  59. api={new MockApiClient()}
  60. route={{}}
  61. router={router_with_slug}
  62. routes={router_with_slug.routes}
  63. routeParams={router_with_slug.params}
  64. location={router_with_slug.location}
  65. />
  66. </RouteContext.Provider>
  67. );
  68. });
  69. });