diff --git a/x-pack/plugins/enterprise_search/public/applications/applications/components/search_application/connect/generate_api_key_modal/generate_search_application_api_key_modal.test.tsx b/x-pack/plugins/enterprise_search/public/applications/applications/components/search_application/connect/generate_api_key_modal/generate_search_application_api_key_modal.test.tsx index 1ebd426b8b9c1..1f23866261b5f 100644 --- a/x-pack/plugins/enterprise_search/public/applications/applications/components/search_application/connect/generate_api_key_modal/generate_search_application_api_key_modal.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/applications/components/search_application/connect/generate_api_key_modal/generate_search_application_api_key_modal.test.tsx @@ -9,7 +9,7 @@ import { setMockValues, setMockActions } from '../../../../../__mocks__/kea_logi import React from 'react'; -import { shallow, mount } from 'enzyme'; +import { shallow } from 'enzyme'; import { EuiModal, EuiFieldText, EuiCodeBlock } from '@elastic/eui'; @@ -17,6 +17,8 @@ const mockActions = { makeRequest: jest.fn(), setKeyName: jest.fn() }; const mockValues = { apiKey: '', isLoading: false, isSuccess: false, keyName: '' }; +import { mountWithIntl } from '@kbn/test-jest-helpers'; + import { GenerateSearchApplicationApiKeyModal } from './generate_search_application_api_key_modal'; const onCloseMock = jest.fn(); @@ -50,7 +52,7 @@ describe('GenerateSearchApplicationApiKeyModal', () => { }); it('pre-set the key name with search application name', () => { - mount( + mountWithIntl( (null); useEffect(() => { setKeyName(`${searchApplicationName} read-only API key`); }, [searchApplicationName]); + useEffect(() => { + if (isSuccess) { + copyApiKeyRef.current?.focus(); + } + }, [isSuccess]); + return ( @@ -65,15 +72,24 @@ export const GenerateSearchApplicationApiKeyModal: React.FC< <> - + {!isSuccess ? ( <> - + + } + fullWidth + > ) : ( - {keyName} - + {keyName}, + }} + /> + } + color="success" + iconType="check" + role="alert" + /> {apiKey ? ( ) : (