index.spec.tsx 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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} = initializeOrg({
  38. router: {
  39. location: {
  40. query: {},
  41. },
  42. },
  43. });
  44. render(
  45. <GroupMergedView
  46. organization={organization}
  47. project={project}
  48. params={{orgId: 'orgId', groupId: 'groupId'}}
  49. location={router.location}
  50. routeParams={{}}
  51. route={{}}
  52. routes={router.routes}
  53. router={router}
  54. />,
  55. {router}
  56. );
  57. expect(screen.getByTestId('loading-indicator')).toBeInTheDocument();
  58. await act(tick);
  59. });
  60. it('renders with mocked data', async function () {
  61. const {organization, project, router} = initializeOrg({
  62. router: {
  63. location: {
  64. query: {},
  65. },
  66. },
  67. });
  68. render(
  69. <GroupMergedView
  70. organization={organization}
  71. project={project}
  72. params={{orgId: 'orgId', groupId: 'groupId'}}
  73. location={router.location}
  74. routeParams={{}}
  75. route={{}}
  76. routes={router.routes}
  77. router={router}
  78. />,
  79. {router}
  80. );
  81. await waitForElementToBeRemoved(() => screen.queryByTestId('loading-indicator'));
  82. });
  83. });