integrationListDirectory.spec.tsx 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import {
  2. BitbucketIntegrationConfig,
  3. OrgOwnedApps,
  4. PluginListConfig,
  5. ProviderList,
  6. PublishedApps,
  7. SentryAppInstalls,
  8. } from 'sentry-fixture/integrationListDirectory';
  9. import {initializeOrg} from 'sentry-test/initializeOrg';
  10. import {render, screen} from 'sentry-test/reactTestingLibrary';
  11. import IntegrationListDirectory from 'sentry/views/settings/organizationIntegrations/integrationListDirectory';
  12. const mockResponse = mocks => {
  13. mocks.forEach(([url, body]) => MockApiClient.addMockResponse({url, body}));
  14. };
  15. describe('IntegrationListDirectory', function () {
  16. beforeEach(function () {
  17. MockApiClient.clearMockResponses();
  18. });
  19. const {organization: org, routerContext, routerProps} = initializeOrg();
  20. describe('Renders view', function () {
  21. beforeEach(() => {
  22. mockResponse([
  23. [`/organizations/${org.slug}/config/integrations/`, ProviderList()],
  24. [`/organizations/${org.slug}/integrations/`, [BitbucketIntegrationConfig()]],
  25. [`/organizations/${org.slug}/sentry-apps/`, OrgOwnedApps()],
  26. ['/sentry-apps/', PublishedApps()],
  27. ['/doc-integrations/', [TestStubs.DocIntegration()]],
  28. [`/organizations/${org.slug}/sentry-app-installations/`, SentryAppInstalls()],
  29. [`/organizations/${org.slug}/plugins/configs/`, PluginListConfig()],
  30. [`/organizations/${org.slug}/repos/?status=unmigratable`, []],
  31. ]);
  32. });
  33. it('shows installed integrations at the top in order of weight', function () {
  34. render(
  35. <IntegrationListDirectory
  36. {...routerProps}
  37. params={{orgId: org.slug}}
  38. routeParams={{orgId: org.slug}}
  39. hideHeader={false}
  40. />,
  41. {
  42. context: routerContext,
  43. }
  44. );
  45. expect(screen.getByRole('textbox', {name: 'Filter'})).toBeInTheDocument();
  46. [
  47. 'bitbucket',
  48. 'pagerduty',
  49. 'my-headband-washer-289499',
  50. 'sample-doc',
  51. 'clickup',
  52. 'amazon-sqs',
  53. 'la-croix-monitor',
  54. ].map(testId => expect(screen.getByTestId(testId)).toBeInTheDocument());
  55. });
  56. it('does not show legacy plugin that has a First Party Integration if not installed', function () {
  57. render(
  58. <IntegrationListDirectory
  59. {...routerProps}
  60. params={{orgId: org.slug}}
  61. routeParams={{orgId: org.slug}}
  62. hideHeader={false}
  63. />,
  64. {context: routerContext}
  65. );
  66. expect(screen.queryByText('GitHub (Legacy)')).not.toBeInTheDocument();
  67. });
  68. it('shows legacy plugin that has a First Party Integration if installed', function () {
  69. render(
  70. <IntegrationListDirectory
  71. {...routerProps}
  72. params={{orgId: org.slug}}
  73. routeParams={{orgId: org.slug}}
  74. hideHeader={false}
  75. />,
  76. {context: routerContext}
  77. );
  78. expect(screen.getByText('PagerDuty (Legacy)')).toBeInTheDocument();
  79. });
  80. });
  81. });