integrationDetailedView.spec.jsx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import {render, screen} from 'sentry-test/reactTestingLibrary';
  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. beforeEach(() => {
  15. Client.clearMockResponses();
  16. mockResponse([
  17. [
  18. `/organizations/${org.slug}/config/integrations/?provider_key=bitbucket`,
  19. {
  20. providers: [
  21. {
  22. canAdd: true,
  23. canDisable: false,
  24. features: ['commits', 'issue-basic'],
  25. key: 'bitbucket',
  26. metadata: {
  27. aspects: {},
  28. author: 'The Sentry Team',
  29. description:
  30. 'Connect your Sentry organization to Bitbucket, enabling the following features:',
  31. features: [],
  32. issue_url:
  33. 'https://github.com/getsentry/sentry/issues/new?template=bug.yml&title=Bitbucket%20Integration:%20&labels=Component%3A%20Integrations',
  34. noun: 'Installation',
  35. source_url:
  36. 'https://github.com/getsentry/sentry/tree/master/src/sentry/integrations/bitbucket',
  37. },
  38. name: 'Bitbucket',
  39. setupDialog: {
  40. height: 600,
  41. url: '/organizations/sentry/integrations/bitbucket/setup/',
  42. width: 600,
  43. },
  44. slug: 'bitbucket',
  45. },
  46. ],
  47. },
  48. ],
  49. [
  50. `/organizations/${org.slug}/integrations/?provider_key=bitbucket&includeConfig=0`,
  51. [
  52. {
  53. accountType: null,
  54. configData: {},
  55. configOrganization: [],
  56. domainName: 'bitbucket.org/%7Bfb715533-bbd7-4666-aa57-01dc93dd9cc0%7D',
  57. 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',
  58. id: '4',
  59. name: '{fb715533-bbd7-4666-aa57-01dc93dd9cc0}',
  60. provider: {
  61. aspects: {},
  62. canAdd: true,
  63. canDisable: false,
  64. features: ['commits', 'issue-basic'],
  65. key: 'bitbucket',
  66. name: 'Bitbucket',
  67. slug: 'bitbucket',
  68. },
  69. status: 'active',
  70. },
  71. ],
  72. ],
  73. ]);
  74. });
  75. it('shows integration name, status, and install button', function () {
  76. render(
  77. <IntegrationDetailedView
  78. params={{integrationSlug: 'bitbucket', orgId: org.slug}}
  79. location={{query: {}}}
  80. />
  81. );
  82. expect(screen.getByText('Bitbucket')).toBeInTheDocument();
  83. expect(screen.getByText('Installed')).toBeInTheDocument();
  84. expect(screen.getByRole('button', {name: 'Add integration'})).toBeEnabled();
  85. });
  86. it('view configurations', function () {
  87. render(
  88. <IntegrationDetailedView
  89. params={{integrationSlug: 'bitbucket', orgId: org.slug}}
  90. location={{query: {tab: 'configurations'}}}
  91. />
  92. );
  93. expect(screen.getByTestId('integration-name')).toHaveTextContent(
  94. '{fb715533-bbd7-4666-aa57-01dc93dd9cc0}'
  95. );
  96. });
  97. });