groupMergedView.spec.jsx 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import * as PropTypes from 'prop-types';
  2. import {mountWithTheme} from 'sentry-test/enzyme';
  3. import {Client} from 'sentry/api';
  4. import GroupingStore from 'sentry/stores/groupingStore';
  5. import {GroupMergedView} from 'sentry/views/organizationGroupDetails/groupMerged';
  6. jest.mock('sentry/api');
  7. describe('Issues -> Merged View', function () {
  8. const events = TestStubs.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. const context = {
  24. group: {
  25. id: 'id',
  26. tags: [],
  27. },
  28. };
  29. beforeAll(function () {
  30. Client.addMockResponse({
  31. url: '/issues/groupId/hashes/?limit=50&query=',
  32. body: mockData.merged,
  33. });
  34. });
  35. beforeEach(() => {
  36. GroupingStore.init();
  37. });
  38. afterEach(() => {
  39. GroupingStore.teardown();
  40. });
  41. it('renders initially with loading component', function () {
  42. const wrapper = mountWithTheme(
  43. <GroupMergedView
  44. project={TestStubs.Project({slug: 'projectId'})}
  45. params={{orgId: 'orgId', projectId: 'projectId', groupId: 'groupId'}}
  46. location={{query: {}}}
  47. />,
  48. TestStubs.routerContext()
  49. );
  50. expect(wrapper.find('LoadingIndicator')).toHaveLength(1);
  51. });
  52. it('renders with mocked data', async function () {
  53. const wrapper = mountWithTheme(
  54. <GroupMergedView
  55. project={TestStubs.Project({slug: 'projectId'})}
  56. params={{orgId: 'orgId', projectId: 'projectId', groupId: 'groupId'}}
  57. location={{query: {}}}
  58. />,
  59. {
  60. ...TestStubs.routerContext([
  61. {
  62. group: context,
  63. },
  64. {
  65. group: PropTypes.object,
  66. },
  67. ]),
  68. }
  69. );
  70. await tick();
  71. await tick();
  72. wrapper.update();
  73. expect(wrapper.find('LoadingIndicator')).toHaveLength(0);
  74. expect(wrapper).toSnapshot();
  75. });
  76. });