index.spec.tsx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import {DetailedEventsFixture} from 'sentry-fixture/events';
  2. import {initializeOrg} from 'sentry-test/initializeOrg';
  3. import {
  4. act,
  5. render,
  6. screen,
  7. waitForElementToBeRemoved,
  8. } from 'sentry-test/reactTestingLibrary';
  9. import GroupingStore from 'sentry/stores/groupingStore';
  10. import {GroupMergedView} from 'sentry/views/issueDetails/groupMerged';
  11. jest.mock('sentry/api');
  12. describe('Issues -> Merged View', function () {
  13. const events = DetailedEventsFixture();
  14. const mockData = {
  15. merged: [
  16. {
  17. latestEvent: events[0],
  18. state: 'unlocked',
  19. id: '2c4887696f708c476a81ce4e834c4b02',
  20. },
  21. {
  22. latestEvent: events[1],
  23. state: 'unlocked',
  24. id: 'e05da55328a860b21f62e371f0a7507d',
  25. },
  26. ],
  27. };
  28. beforeEach(function () {
  29. GroupingStore.init();
  30. MockApiClient.clearMockResponses();
  31. MockApiClient.addMockResponse({
  32. url: '/organizations/org-slug/issues/groupId/hashes/?limit=50&query=',
  33. body: mockData.merged,
  34. });
  35. });
  36. it('renders initially with loading component', async function () {
  37. const {organization, project, router, routerContext} = initializeOrg({
  38. project: {
  39. slug: 'projectId',
  40. },
  41. router: {
  42. location: {
  43. query: {},
  44. },
  45. },
  46. });
  47. render(
  48. <GroupMergedView
  49. organization={organization}
  50. project={project}
  51. params={{orgId: 'orgId', groupId: 'groupId'}}
  52. location={router.location}
  53. routeParams={{}}
  54. route={{}}
  55. routes={router.routes}
  56. router={router}
  57. />,
  58. {context: routerContext}
  59. );
  60. expect(screen.getByTestId('loading-indicator')).toBeInTheDocument();
  61. await act(tick);
  62. });
  63. it('renders with mocked data', async function () {
  64. const {organization, project, router, routerContext} = initializeOrg({
  65. project: {
  66. slug: 'projectId',
  67. },
  68. router: {
  69. location: {
  70. query: {},
  71. },
  72. },
  73. });
  74. render(
  75. <GroupMergedView
  76. organization={organization}
  77. project={project}
  78. params={{orgId: 'orgId', groupId: 'groupId'}}
  79. location={router.location}
  80. routeParams={{}}
  81. route={{}}
  82. routes={router.routes}
  83. router={router}
  84. />,
  85. {context: routerContext}
  86. );
  87. await waitForElementToBeRemoved(() => screen.queryByTestId('loading-indicator'));
  88. });
  89. });