integrationListDirectory.spec.tsx 3.1 KB

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