configureIntegration.spec.tsx 2.1 KB

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