configureIntegration.spec.tsx 2.3 KB

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