groupMergedView.spec.tsx 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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/organizationGroupDetails/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. beforeAll(function () {
  23. MockApiClient.addMockResponse({
  24. url: '/issues/groupId/hashes/?limit=50&query=',
  25. body: mockData.merged,
  26. });
  27. });
  28. beforeEach(() => {
  29. GroupingStore.init();
  30. });
  31. it('renders initially with loading component', function () {
  32. const {organization, project, router, routerContext} = initializeOrg({
  33. ...initializeOrg(),
  34. project: {
  35. ...initializeOrg().project,
  36. slug: 'projectId',
  37. },
  38. router: {
  39. ...initializeOrg().router,
  40. location: {
  41. query: {},
  42. },
  43. },
  44. });
  45. render(
  46. <GroupMergedView
  47. organization={organization}
  48. project={project}
  49. params={{orgId: 'orgId', groupId: 'groupId'}}
  50. location={router.location}
  51. routeParams={{}}
  52. route={{}}
  53. routes={router.routes}
  54. router={router}
  55. />,
  56. {context: routerContext}
  57. );
  58. expect(screen.getByTestId('loading-indicator')).toBeInTheDocument();
  59. });
  60. it('renders with mocked data', async function () {
  61. const {organization, project, router, routerContext} = initializeOrg({
  62. ...initializeOrg(),
  63. project: {
  64. ...initializeOrg().project,
  65. slug: 'projectId',
  66. },
  67. router: {
  68. ...initializeOrg().router,
  69. location: {
  70. query: {},
  71. },
  72. },
  73. });
  74. const {container} = 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.getByTestId('loading-indicator'));
  88. expect(container).toSnapshot();
  89. });
  90. });