index.spec.tsx 2.3 KB

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