integrationListDirectory.spec.tsx 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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', async 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(await screen.findByRole('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', async 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(await screen.findByRole('textbox', {name: 'Filter'})).toBeInTheDocument();
  74. expect(screen.queryByText('GitHub (Legacy)')).not.toBeInTheDocument();
  75. });
  76. it('shows legacy plugin that has a First Party Integration if installed', async function () {
  77. render(
  78. <IntegrationListDirectory
  79. {...routerProps}
  80. params={{orgId: org.slug}}
  81. routeParams={{orgId: org.slug}}
  82. hideHeader={false}
  83. />,
  84. {context: routerContext}
  85. );
  86. expect(await screen.findByText('PagerDuty (Legacy)')).toBeInTheDocument();
  87. });
  88. });
  89. });