integrationListDirectory.spec.jsx 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import {mountWithTheme} from 'sentry-test/enzyme';
  2. import {initializeOrg} from 'sentry-test/initializeOrg';
  3. import {Client} from 'sentry/api';
  4. import IntegrationListDirectory from 'sentry/views/organizationIntegrations/integrationListDirectory';
  5. const mockResponse = mocks => {
  6. mocks.forEach(([url, body]) =>
  7. Client.addMockResponse({
  8. url,
  9. body,
  10. })
  11. );
  12. };
  13. describe('IntegrationListDirectory', function () {
  14. beforeEach(function () {
  15. Client.clearMockResponses();
  16. });
  17. const {org, routerContext} = initializeOrg();
  18. let wrapper;
  19. describe('Renders view', function () {
  20. beforeEach(() => {
  21. mockResponse([
  22. [`/organizations/${org.slug}/config/integrations/`, TestStubs.ProviderList()],
  23. [
  24. `/organizations/${org.slug}/integrations/`,
  25. [TestStubs.BitbucketIntegrationConfig()],
  26. ],
  27. [`/organizations/${org.slug}/sentry-apps/`, TestStubs.OrgOwnedApps()],
  28. ['/sentry-apps/', TestStubs.PublishedApps()],
  29. ['/doc-integrations/', [TestStubs.DocIntegration()]],
  30. [
  31. `/organizations/${org.slug}/sentry-app-installations/`,
  32. TestStubs.SentryAppInstalls(),
  33. ],
  34. [`/organizations/${org.slug}/plugins/configs/`, TestStubs.PluginListConfig()],
  35. [`/organizations/${org.slug}/repos/?status=unmigratable`, []],
  36. ]);
  37. wrapper = mountWithTheme(
  38. <IntegrationListDirectory params={{orgId: org.slug}} location={{search: ''}} />,
  39. routerContext
  40. );
  41. });
  42. it('shows installed integrations at the top in order of weight', function () {
  43. expect(wrapper.find('SearchBar').exists()).toBeTruthy();
  44. expect(wrapper.find('PanelBody').exists()).toBeTruthy();
  45. expect(wrapper.find('IntegrationRow')).toHaveLength(7);
  46. [
  47. 'bitbucket', // 10
  48. 'pagerduty', // 10
  49. 'my-headband-washer-289499', // 10
  50. 'sample-doc', // 10
  51. 'clickup', // 9
  52. 'amazon-sqs', // 8
  53. 'la-croix-monitor', // 8
  54. ].map((name, index) =>
  55. expect(wrapper.find('IntegrationRow').at(index).props().slug).toEqual(name)
  56. );
  57. });
  58. it('does not show legacy plugin that has a First Party Integration if not installed', function () {
  59. wrapper.find('IntegrationRow').forEach(node => {
  60. expect(node.props().displayName).not.toEqual('Github (Legacy)');
  61. });
  62. });
  63. it('shows legacy plugin that has a First Party Integration if installed', function () {
  64. const legacyPluginRow = wrapper
  65. .find('IntegrationRow')
  66. .filterWhere(node => node.props().displayName === 'PagerDuty (Legacy)');
  67. expect(legacyPluginRow).toHaveLength(1);
  68. });
  69. });
  70. });