externalIssueActions.spec.jsx 2.7 KB

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