integrationListDirectory.spec.jsx 2.7 KB

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