index.spec.tsx 2.3 KB

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