integrationListDirectory.spec.tsx 3.1 KB

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