index.spec.tsx 2.2 KB

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