externalIssueActions.spec.jsx 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import {mountWithTheme} from 'sentry-test/enzyme';
  2. import ExternalIssueActions from 'app/components/group/externalIssueActions';
  3. describe('ExternalIssueActions', function () {
  4. const group = TestStubs.Group();
  5. describe('with no external issues linked', function () {
  6. const integration = TestStubs.GitHubIntegration({externalIssues: []});
  7. const configurations = [integration];
  8. const wrapper = mountWithTheme(
  9. <ExternalIssueActions
  10. key="github"
  11. group={group}
  12. configurations={configurations}
  13. onChange={() => {}}
  14. />,
  15. TestStubs.routerContext()
  16. );
  17. // console.log(configurations);
  18. it('renders', function () {
  19. expect(wrapper).toSnapshot();
  20. });
  21. it('renders Link GitHub Issue when no issues currently linked', function () {
  22. expect(wrapper.find('IntegrationLink a').text()).toEqual('Link GitHub Issue');
  23. });
  24. it('should not have `+` icon', function () {
  25. const container = wrapper.find('IssueSyncListElementContainer').first();
  26. expect(container.contains('StyledIcon')).toBe(false);
  27. });
  28. describe('opens modal', function () {
  29. MockApiClient.addMockResponse({
  30. url: '/groups/1/integrations/1/?action=create',
  31. body: {createIssueConfig: []},
  32. });
  33. it('opens when clicking text', function () {
  34. wrapper.find('IntegrationLink a').simulate('click');
  35. expect(wrapper.find('Hovercard').first().prop('header')).toEqual(
  36. 'Linked GitHub Integration'
  37. );
  38. });
  39. });
  40. });
  41. describe('with an external issue linked', function () {
  42. const externalIssues = [
  43. {
  44. id: 100,
  45. url: 'https://github.com/MeredithAnya/testing/issues/2',
  46. key: 'getsentry/sentry#2',
  47. },
  48. ];
  49. const integration = TestStubs.GitHubIntegration({externalIssues});
  50. const configurations = [integration];
  51. const wrapper = mountWithTheme(
  52. <ExternalIssueActions
  53. key="github"
  54. group={group}
  55. configurations={configurations}
  56. onChange={() => {}}
  57. />,
  58. TestStubs.routerContext()
  59. );
  60. it('renders', function () {
  61. expect(wrapper.find('IssueSyncElement')).toHaveLength(0);
  62. });
  63. it('renders Link GitHub Issue when no issues currently linked', function () {
  64. expect(wrapper.find('IntegrationLink a').text()).toEqual('getsentry/sentry#2');
  65. });
  66. describe('deletes linked issue', function () {
  67. const mockDelete = MockApiClient.addMockResponse({
  68. url: '/groups/1/integrations/1/?externalIssue=100',
  69. method: 'DELETE',
  70. });
  71. it('deletes when clicking x', function () {
  72. wrapper.find('StyledIcon').simulate('click');
  73. expect(mockDelete).toHaveBeenCalled();
  74. });
  75. });
  76. });
  77. });