index.spec.tsx 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. 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. 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. const {container} = 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. expect(container).toSnapshot();
  83. });
  84. });