groupMergedView.spec.jsx 1.9 KB

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