1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- import {OpsgenieIntegrationFixture} from 'sentry-fixture/opsgenieIntegration';
- import {OpsgenieIntegrationProviderFixture} from 'sentry-fixture/opsgenieIntegrationProvider';
- import {OrganizationFixture} from 'sentry-fixture/organization';
- import {RouteComponentPropsFixture} from 'sentry-fixture/routeComponentPropsFixture';
- import {
- render,
- renderGlobalModal,
- screen,
- userEvent,
- } from 'sentry-test/reactTestingLibrary';
- import ConfigureIntegration from 'sentry/views/settings/organizationIntegrations/configureIntegration';
- describe('OpsgenieMigrationButton', function () {
- const org = OrganizationFixture({
- access: ['org:integrations', 'org:write'],
- });
- const integrationId = '1';
- it('Migrate Plugin button hits migration endpoint', async function () {
- MockApiClient.addMockResponse({
- url: `/organizations/${org.slug}/config/integrations/`,
- body: {
- providers: [OpsgenieIntegrationProviderFixture()],
- },
- });
- MockApiClient.addMockResponse({
- url: `/organizations/${org.slug}/integrations/${integrationId}/`,
- body: OpsgenieIntegrationFixture(),
- });
- MockApiClient.addMockResponse({
- url: `/organizations/${org.slug}/plugins/configs/`,
- body: [
- {
- id: 'opsgenie',
- name: 'Opsgenie',
- slug: 'opsgenie',
- projectList: [
- {
- projectId: 2,
- projectSlug: 'python',
- projectName: 'python',
- enabled: true,
- configured: true,
- projectPlatform: 'python',
- },
- ],
- },
- ],
- });
- const onConfirmCall = MockApiClient.addMockResponse({
- url: `/organizations/${org.slug}/integrations/${integrationId}/migrate-opsgenie/`,
- method: 'PUT',
- });
- render(
- <ConfigureIntegration
- {...RouteComponentPropsFixture()}
- params={{integrationId, providerKey: 'opsgenie'}}
- />,
- {organization: org}
- );
- renderGlobalModal();
- expect(await screen.findByRole('button', {name: 'Migrate Plugin'})).toBeEnabled();
- await userEvent.click(screen.getByRole('button', {name: 'Migrate Plugin'}));
- expect(screen.queryByRole('button', {name: 'Confirm'})).toBeInTheDocument();
- await userEvent.click(screen.getByRole('button', {name: 'Confirm'}));
- expect(onConfirmCall).toHaveBeenCalled();
- });
- });
|