integrationListDirectory.spec.jsx 2.5 KB

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