integrationListDirectory.spec.tsx 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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, routerProps} = 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. {...routerProps}
  35. params={{orgId: org.slug}}
  36. routeParams={{orgId: org.slug}}
  37. hideHeader={false}
  38. />,
  39. {
  40. context: routerContext,
  41. }
  42. );
  43. expect(screen.getByRole('textbox', {name: 'Filter'})).toBeInTheDocument();
  44. [
  45. 'bitbucket',
  46. 'pagerduty',
  47. 'my-headband-washer-289499',
  48. 'sample-doc',
  49. 'clickup',
  50. 'amazon-sqs',
  51. 'la-croix-monitor',
  52. ].map(testId => expect(screen.getByTestId(testId)).toBeInTheDocument());
  53. });
  54. it('does not show legacy plugin that has a First Party Integration if not installed', function () {
  55. render(
  56. <IntegrationListDirectory
  57. {...routerProps}
  58. params={{orgId: org.slug}}
  59. routeParams={{orgId: org.slug}}
  60. hideHeader={false}
  61. />,
  62. {context: routerContext}
  63. );
  64. expect(screen.queryByText('GitHub (Legacy)')).not.toBeInTheDocument();
  65. });
  66. it('shows legacy plugin that has a First Party Integration if installed', function () {
  67. render(
  68. <IntegrationListDirectory
  69. {...routerProps}
  70. params={{orgId: org.slug}}
  71. routeParams={{orgId: org.slug}}
  72. hideHeader={false}
  73. />,
  74. {context: routerContext}
  75. );
  76. expect(screen.getByText('PagerDuty (Legacy)')).toBeInTheDocument();
  77. });
  78. });
  79. });