externalIssueActions.spec.jsx 2.6 KB

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