diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials.test.tsx index 7b24f6d20a58f..a265b2c998d39 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials.test.tsx @@ -11,7 +11,7 @@ import React from 'react'; import { shallow } from 'enzyme'; import { Credentials } from './credentials'; -import { EuiCopy, EuiPageContentBody } from '@elastic/eui'; +import { EuiCopy, EuiLoadingContent, EuiPageContentBody } from '@elastic/eui'; import { externalUrl } from '../../../shared/enterprise_search_url'; @@ -48,10 +48,11 @@ describe('Credentials', () => { expect(actions.resetCredentials).toHaveBeenCalledTimes(1); }); - it('renders nothing if data is still loading', () => { + it('renders a limited UI if data is still loading', () => { setMockValues({ dataLoading: true }); const wrapper = shallow(); - expect(wrapper.find(EuiPageContentBody)).toHaveLength(0); + expect(wrapper.find('[data-test-subj="CreateAPIKeyButton"]')).toHaveLength(0); + expect(wrapper.find(EuiLoadingContent)).toHaveLength(1); }); it('renders the API endpoint and a button to copy it', () => { diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials.tsx index ae95482e0f855..b9a482ae462d5 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials.tsx @@ -19,6 +19,7 @@ import { EuiButton, EuiPageContentHeader, EuiPageContentHeaderSection, + EuiLoadingContent, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; @@ -41,11 +42,6 @@ export const Credentials: React.FC = () => { }; }, []); - // TODO - // if (dataLoading) { return } - if (dataLoading) { - return null; - } return ( <> { - showCredentialsForm()} - > - {i18n.translate('xpack.enterpriseSearch.appSearch.credentials.createKey', { - defaultMessage: 'Create a key', - })} - + {!dataLoading && ( + showCredentialsForm()} + > + {i18n.translate('xpack.enterpriseSearch.appSearch.credentials.createKey', { + defaultMessage: 'Create a key', + })} + + )} - - - + {!!dataLoading ? : } );