integrationListDirectory.spec.tsx 2.9 KB

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