PageRenderTime 52ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/js/spec/views/organizationIntegrations/integrationDetailedView.spec.jsx

https://github.com/getsentry/sentry
JSX | 110 lines | 101 code | 9 blank | 0 comment | 0 complexity | 765f610cd930f85d1e806c4b45ce205b MD5 | raw file
Possible License(s): Apache-2.0, BSD-3-Clause
  1. import {mountWithTheme} from 'sentry-test/enzyme';
  2. import {Client} from 'sentry/api';
  3. import IntegrationDetailedView from 'sentry/views/organizationIntegrations/integrationDetailedView';
  4. const mockResponse = mocks => {
  5. mocks.forEach(([url, body]) =>
  6. Client.addMockResponse({
  7. url,
  8. body,
  9. })
  10. );
  11. };
  12. describe('IntegrationDetailedView', function () {
  13. const org = TestStubs.Organization();
  14. const routerContext = TestStubs.routerContext();
  15. let wrapper;
  16. beforeEach(() => {
  17. Client.clearMockResponses();
  18. mockResponse([
  19. [
  20. `/organizations/${org.slug}/config/integrations/?provider_key=bitbucket`,
  21. {
  22. providers: [
  23. {
  24. canAdd: true,
  25. canDisable: false,
  26. features: ['commits', 'issue-basic'],
  27. key: 'bitbucket',
  28. metadata: {
  29. aspects: {},
  30. author: 'The Sentry Team',
  31. description:
  32. 'Connect your Sentry organization to Bitbucket, enabling the following features:',
  33. features: [],
  34. issue_url:
  35. 'https://github.com/getsentry/sentry/issues/new?template=bug.yml&title=Bitbucket%20Integration:%20&labels=Component%3A%20Integrations',
  36. noun: 'Installation',
  37. source_url:
  38. 'https://github.com/getsentry/sentry/tree/master/src/sentry/integrations/bitbucket',
  39. },
  40. name: 'Bitbucket',
  41. setupDialog: {
  42. height: 600,
  43. url: '/organizations/sentry/integrations/bitbucket/setup/',
  44. width: 600,
  45. },
  46. slug: 'bitbucket',
  47. },
  48. ],
  49. },
  50. ],
  51. [
  52. `/organizations/${org.slug}/integrations/?provider_key=bitbucket&includeConfig=0`,
  53. [
  54. {
  55. accountType: null,
  56. configData: {},
  57. configOrganization: [],
  58. domainName: 'bitbucket.org/%7Bfb715533-bbd7-4666-aa57-01dc93dd9cc0%7D',
  59. icon: 'https://secure.gravatar.com/avatar/8b4cb68e40b74c90427d8262256bd1c8?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FNN-0.png',
  60. id: '4',
  61. name: '{fb715533-bbd7-4666-aa57-01dc93dd9cc0}',
  62. provider: {
  63. aspects: {},
  64. canAdd: true,
  65. canDisable: false,
  66. features: ['commits', 'issue-basic'],
  67. key: 'bitbucket',
  68. name: 'Bitbucket',
  69. slug: 'bitbucket',
  70. },
  71. status: 'active',
  72. },
  73. ],
  74. ],
  75. ]);
  76. wrapper = mountWithTheme(
  77. <IntegrationDetailedView
  78. params={{integrationSlug: 'bitbucket', orgId: org.slug}}
  79. location={{query: {}}}
  80. />,
  81. routerContext
  82. );
  83. });
  84. it('shows the Integration name and install status', async function () {
  85. expect(wrapper.find('Name').props().children).toEqual('Bitbucket');
  86. expect(wrapper.find('IntegrationStatus').props().status).toEqual('Installed');
  87. });
  88. it('shows the Add Installation button', async function () {
  89. expect(wrapper.find('AddIntegrationButton').props().disabled).toEqual(false);
  90. });
  91. it('view configurations', async function () {
  92. wrapper = mountWithTheme(
  93. <IntegrationDetailedView
  94. params={{integrationSlug: 'bitbucket', orgId: org.slug}}
  95. location={{query: {tab: 'configurations'}}}
  96. />,
  97. routerContext
  98. );
  99. expect(wrapper.find('InstallWrapper')).toHaveLength(1);
  100. });
  101. });