configureIntegration.spec.tsx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import {OpsgenieIntegrationFixture} from 'sentry-fixture/opsgenieIntegration';
  2. import {OpsgenieIntegrationProviderFixture} from 'sentry-fixture/opsgenieIntegrationProvider';
  3. import {OrganizationFixture} from 'sentry-fixture/organization';
  4. import {RouteComponentPropsFixture} from 'sentry-fixture/routeComponentPropsFixture';
  5. import {
  6. render,
  7. renderGlobalModal,
  8. screen,
  9. userEvent,
  10. } from 'sentry-test/reactTestingLibrary';
  11. import ConfigureIntegration from 'sentry/views/settings/organizationIntegrations/configureIntegration';
  12. describe('OpsgenieMigrationButton', function () {
  13. const org = OrganizationFixture({
  14. access: ['org:integrations', 'org:write'],
  15. });
  16. const integrationId = '1';
  17. it('Migrate Plugin button hits migration endpoint', async function () {
  18. org.features.push('integrations-opsgenie-migration');
  19. MockApiClient.addMockResponse({
  20. url: `/organizations/${org.slug}/config/integrations/`,
  21. body: {
  22. providers: [OpsgenieIntegrationProviderFixture()],
  23. },
  24. });
  25. MockApiClient.addMockResponse({
  26. url: `/organizations/${org.slug}/integrations/${integrationId}/`,
  27. body: OpsgenieIntegrationFixture(),
  28. });
  29. MockApiClient.addMockResponse({
  30. url: `/organizations/${org.slug}/plugins/configs/`,
  31. body: [
  32. {
  33. id: 'opsgenie',
  34. name: 'Opsgenie',
  35. slug: 'opsgenie',
  36. projectList: [
  37. {
  38. projectId: 2,
  39. projectSlug: 'python',
  40. projectName: 'python',
  41. enabled: true,
  42. configured: true,
  43. projectPlatform: 'python',
  44. },
  45. ],
  46. },
  47. ],
  48. });
  49. const onConfirmCall = MockApiClient.addMockResponse({
  50. url: `/organizations/${org.slug}/integrations/${integrationId}/migrate-opsgenie/`,
  51. method: 'PUT',
  52. });
  53. render(
  54. <ConfigureIntegration
  55. {...RouteComponentPropsFixture()}
  56. params={{integrationId, providerKey: 'opsgenie'}}
  57. />,
  58. {organization: org}
  59. );
  60. renderGlobalModal();
  61. expect(await screen.findByRole('button', {name: 'Migrate Plugin'})).toBeEnabled();
  62. await userEvent.click(screen.getByRole('button', {name: 'Migrate Plugin'}));
  63. expect(screen.queryByRole('button', {name: 'Confirm'})).toBeInTheDocument();
  64. await userEvent.click(screen.getByRole('button', {name: 'Confirm'}));
  65. expect(onConfirmCall).toHaveBeenCalled();
  66. });
  67. });