diff --git a/src/OrganizationIntegration/OrganizationIntegrationView/OrganizationIntegrationView.js b/src/OrganizationIntegration/OrganizationIntegrationView/OrganizationIntegrationView.js
index 0f900f7c..7634d867 100644
--- a/src/OrganizationIntegration/OrganizationIntegrationView/OrganizationIntegrationView.js
+++ b/src/OrganizationIntegration/OrganizationIntegrationView/OrganizationIntegrationView.js
@@ -15,7 +15,7 @@ import {
useHistory,
useParams,
useLocation,
-} from 'react-router';
+} from 'react-router-dom';
import { AppIcon } from '@folio/stripes/core';
import {
@@ -312,6 +312,7 @@ const OrganizationIntegrationView = ({ orgId }) => {
{isDuplicateConfirmation && (
}
heading={}
message={(
({
- ...jest.requireActual('react-router'),
+import { getDuplicateTimestamp } from '../utils';
+
+jest.mock('react-router-dom', () => ({
+ ...jest.requireActual('react-router-dom'),
useHistory: jest.fn(),
useParams: jest.fn(),
}));
@@ -43,6 +51,10 @@ jest.mock('../../common/hooks', () => ({
useIntegrationConfig: jest.fn(),
useIntegrationConfigMutation: jest.fn().mockReturnValue({ mutateIntegrationConfig: jest.fn() }),
}));
+jest.mock('../utils', () => ({
+ ...jest.requireActual('../utils'),
+ getDuplicateTimestamp: jest.fn(),
+}));
const queryAllByClass = queryHelpers.queryAllByAttribute.bind(null, 'class');
@@ -54,19 +66,23 @@ const renderOrganizationIntegrationView = (props = defaultProps) => render(
);
describe('OrganizationIntegrationView', () => {
+ const mutateIntegrationConfig = jest.fn();
+
beforeEach(() => {
+ getDuplicateTimestamp.mockReturnValue('01/01/2025');
global.document.createRange = global.document.originalCreateRange;
- useParams.mockClear().mockReturnValue({ id: integrationConfig.id });
- useOrganization.mockClear().mockReturnValue({
+ useParams.mockReturnValue({ id: integrationConfig.id });
+ useOrganization.mockReturnValue({
organization: { id: defaultProps.orgId, accounts: [] },
isLoading: false,
});
- useIntegrationConfigMutation.mockClear().mockReturnValue({ });
- useIntegrationConfig.mockClear().mockReturnValue({ integrationConfig });
+ useIntegrationConfigMutation.mockReturnValue({ mutateIntegrationConfig });
+ useIntegrationConfig.mockReturnValue({ integrationConfig });
});
afterEach(() => {
+ jest.clearAllMocks();
global.document.createRange = global.document.mockCreateRange;
});
@@ -131,6 +147,23 @@ describe('OrganizationIntegrationView', () => {
search: '',
});
});
+
+ it('should duplicate integration config', async () => {
+ const pushMock = jest.fn();
+
+ useHistory.mockReturnValue({ push: pushMock });
+
+ renderOrganizationIntegrationView();
+
+ await user.click(screen.getByTestId('duplicate-integration-action'));
+ await user.click(screen.getByText('ui-organizations.integration.confirmation.confirm'));
+
+ expect(mutateIntegrationConfig).toHaveBeenCalled();
+ expect(pushMock).toHaveBeenCalledWith({
+ pathname: `/organizations/view/${orgId}`,
+ search: '',
+ });
+ });
});
describe('Shortcuts', () => {
diff --git a/src/OrganizationIntegration/OrganizationIntegrationView/__snapshots__/OrganizationIntegrationView.test.js.snap b/src/OrganizationIntegration/OrganizationIntegrationView/__snapshots__/OrganizationIntegrationView.test.js.snap
index 1b32d922..99cb33b5 100644
--- a/src/OrganizationIntegration/OrganizationIntegrationView/__snapshots__/OrganizationIntegrationView.test.js.snap
+++ b/src/OrganizationIntegration/OrganizationIntegrationView/__snapshots__/OrganizationIntegrationView.test.js.snap
@@ -117,6 +117,19 @@ exports[`OrganizationIntegrationView should render correct view structure 1`] =
+