configureIntegration.spec.tsx 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. />,
  57. {organization: org}
  58. );
  59. renderGlobalModal();
  60. expect(await screen.findByRole('button', {name: 'Migrate Plugin'})).toBeEnabled();
  61. await userEvent.click(screen.getByRole('button', {name: 'Migrate Plugin'}));
  62. expect(screen.queryByRole('button', {name: 'Confirm'})).toBeInTheDocument();
  63. await userEvent.click(screen.getByRole('button', {name: 'Confirm'}));
  64. expect(onConfirmCall).toHaveBeenCalled();
  65. });
  66. });