Skip to content

Commit e6eb59c

Browse files
committed
create_engine/CreateEngine -> engine_creation/EngineCreation
1 parent c50b0ac commit e6eb59c

12 files changed

Lines changed: 102 additions & 100 deletions

File tree

x-pack/plugins/enterprise_search/public/applications/app_search/components/create_engine/constants.ts renamed to x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_creation/constants.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,64 +6,64 @@
66

77
import { i18n } from '@kbn/i18n';
88

9-
export const CREATE_ENGINE_TITLE = i18n.translate(
10-
'xpack.enterpriseSearch.appSearch.createEngine.title',
9+
export const ENGINE_CREATION_TITLE = i18n.translate(
10+
'xpack.enterpriseSearch.appSearch.engineCreation.title',
1111
{
1212
defaultMessage: 'Create an Engine',
1313
}
1414
);
1515

16-
export const CREATE_ENGINE_FORM_TITLE = i18n.translate(
17-
'xpack.enterpriseSearch.appSearch.createEngine.form.title',
16+
export const ENGINE_CREATION_FORM_TITLE = i18n.translate(
17+
'xpack.enterpriseSearch.appSearch.engineCreation.form.title',
1818
{
1919
defaultMessage: 'Name your Engine',
2020
}
2121
);
2222

23-
export const CREATE_ENGINE_FORM_ENGINE_NAME_LABEL = i18n.translate(
24-
'xpack.enterpriseSearch.appSearch.createEngine.form.engineName.label',
23+
export const ENGINE_CREATION_FORM_ENGINE_NAME_LABEL = i18n.translate(
24+
'xpack.enterpriseSearch.appSearch.engineCreation.form.engineName.label',
2525
{
2626
defaultMessage: 'Engine Name',
2727
}
2828
);
2929

3030
export const ALLOWED_CHARS_NOTE = i18n.translate(
31-
'xpack.enterpriseSearch.appSearch.createEngine.form.engineName.allowedCharactersNote',
31+
'xpack.enterpriseSearch.appSearch.engineCreation.form.engineName.allowedCharactersNote',
3232
{
3333
defaultMessage: 'Engine names can only contain lowercase letters, numbers, and hyphens',
3434
}
3535
);
3636

3737
export const SANITIZED_NAME_NOTE = i18n.translate(
38-
'xpack.enterpriseSearch.appSearch.createEngine.form.engineName.sanitizedNameNote',
38+
'xpack.enterpriseSearch.appSearch.engineCreation.form.engineName.sanitizedNameNote',
3939
{
4040
defaultMessage: 'Your engine will be named',
4141
}
4242
);
4343

44-
export const CREATE_ENGINE_FORM_ENGINE_NAME_PLACEHOLDER = i18n.translate(
45-
'xpack.enterpriseSearch.appSearch.createEngine.form.engineName.placeholder',
44+
export const ENGINE_CREATION_FORM_ENGINE_NAME_PLACEHOLDER = i18n.translate(
45+
'xpack.enterpriseSearch.appSearch.engineCreation.form.engineName.placeholder',
4646
{
4747
defaultMessage: 'i.e., my-search-engine',
4848
}
4949
);
5050

51-
export const CREATE_ENGINE_FORM_ENGINE_LANGUAGE_LABEL = i18n.translate(
52-
'xpack.enterpriseSearch.appSearch.createEngine.form.engineLanguage.label',
51+
export const ENGINE_CREATION_FORM_ENGINE_LANGUAGE_LABEL = i18n.translate(
52+
'xpack.enterpriseSearch.appSearch.engineCreation.form.engineLanguage.label',
5353
{
5454
defaultMessage: 'Engine Language',
5555
}
5656
);
5757

58-
export const CREATE_ENGINE_FORM_SUBMIT_BUTTON_LABEL = i18n.translate(
59-
'xpack.enterpriseSearch.appSearch.createEngine.form.submitButton.label',
58+
export const ENGINE_CREATION_FORM_SUBMIT_BUTTON_LABEL = i18n.translate(
59+
'xpack.enterpriseSearch.appSearch.engineCreation.form.submitButton.label',
6060
{
6161
defaultMessage: 'Create Engine',
6262
}
6363
);
6464

65-
export const CREATE_ENGINE_SUCCESS_MESSAGE = i18n.translate(
66-
'xpack.enterpriseSearch.appSearch.createEngine.successMessage',
65+
export const ENGINE_CREATION_SUCCESS_MESSAGE = i18n.translate(
66+
'xpack.enterpriseSearch.appSearch.engineCreation.successMessage',
6767
{
6868
defaultMessage: 'Successfully created engine.',
6969
}

x-pack/plugins/enterprise_search/public/applications/app_search/components/create_engine/create_engine.test.tsx renamed to x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_creation/engine_creation.test.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import { shallow } from 'enzyme';
1010
import '../../../__mocks__/shallow_useeffect.mock';
1111
import { setMockValues } from '../../../__mocks__';
1212

13-
import { CreateEngine } from './';
13+
import { EngineCreation } from './';
1414

15-
describe('CreateEngine', () => {
15+
describe('EngineCreation', () => {
1616
const DEFAULT_VALUES = {
1717
name: '',
1818
rawName: '',
@@ -26,46 +26,46 @@ describe('CreateEngine', () => {
2626

2727
it('renders', () => {
2828
setMockValues(DEFAULT_VALUES);
29-
const wrapper = shallow(<CreateEngine />);
30-
expect(wrapper.find('[data-test-subj="CreateEngine"]')).toHaveLength(1);
29+
const wrapper = shallow(<EngineCreation />);
30+
expect(wrapper.find('[data-test-subj="EngineCreation"]')).toHaveLength(1);
3131
});
3232

3333
it('contains a form', () => {
3434
setMockValues(DEFAULT_VALUES);
35-
const wrapper = shallow(<CreateEngine />);
36-
expect(wrapper.find('[data-test-subj="CreateEngineForm"]')).toHaveLength(1);
35+
const wrapper = shallow(<EngineCreation />);
36+
expect(wrapper.find('[data-test-subj="EngineCreationForm"]')).toHaveLength(1);
3737
});
3838

3939
it('contains a name input', () => {
4040
setMockValues(DEFAULT_VALUES);
41-
const wrapper = shallow(<CreateEngine />);
42-
expect(wrapper.find('[data-test-subj="CreateEngineNameInput"]')).toHaveLength(1);
41+
const wrapper = shallow(<EngineCreation />);
42+
expect(wrapper.find('[data-test-subj="EngineCreationNameInput"]')).toHaveLength(1);
4343
});
4444

4545
it('contains a language input', () => {
4646
setMockValues(DEFAULT_VALUES);
47-
const wrapper = shallow(<CreateEngine />);
48-
expect(wrapper.find('[data-test-subj="CreateEngineLanguageInput"]')).toHaveLength(1);
47+
const wrapper = shallow(<EngineCreation />);
48+
expect(wrapper.find('[data-test-subj="EngineCreationLanguageInput"]')).toHaveLength(1);
4949
});
5050

5151
describe('NewEngineSubmitButton', () => {
5252
it('renders', () => {
5353
setMockValues(DEFAULT_VALUES);
54-
const wrapper = shallow(<CreateEngine />);
54+
const wrapper = shallow(<EngineCreation />);
5555
expect(wrapper.find('[data-test-subj="NewEngineSubmitButton"]')).toHaveLength(1);
5656
});
5757

5858
it('is disabled when name is empty', () => {
5959
setMockValues(DEFAULT_VALUES);
60-
const wrapper = shallow(<CreateEngine />);
60+
const wrapper = shallow(<EngineCreation />);
6161
expect(wrapper.find('[data-test-subj="NewEngineSubmitButton"]').prop('disabled')).toEqual(
6262
true
6363
);
6464
});
6565

6666
it('is enabled when name has a value', () => {
6767
setMockValues({ ...DEFAULT_VALUES, name: 'test', rawName: 'test' });
68-
const wrapper = shallow(<CreateEngine />);
68+
const wrapper = shallow(<EngineCreation />);
6969
expect(wrapper.find('[data-test-subj="NewEngineSubmitButton"]').prop('disabled')).toEqual(
7070
false
7171
);

x-pack/plugins/enterprise_search/public/applications/app_search/components/create_engine/create_engine.tsx renamed to x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_creation/engine_creation.tsx

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,49 +27,49 @@ import { SetAppSearchChrome as SetPageChrome } from '../../../shared/kibana_chro
2727
import { FlashMessages } from '../../../shared/flash_messages';
2828
import {
2929
ALLOWED_CHARS_NOTE,
30-
CREATE_ENGINE_FORM_ENGINE_LANGUAGE_LABEL,
31-
CREATE_ENGINE_FORM_ENGINE_NAME_LABEL,
32-
CREATE_ENGINE_FORM_ENGINE_NAME_PLACEHOLDER,
33-
CREATE_ENGINE_FORM_SUBMIT_BUTTON_LABEL,
34-
CREATE_ENGINE_FORM_TITLE,
35-
CREATE_ENGINE_TITLE,
30+
ENGINE_CREATION_FORM_ENGINE_LANGUAGE_LABEL,
31+
ENGINE_CREATION_FORM_ENGINE_NAME_LABEL,
32+
ENGINE_CREATION_FORM_ENGINE_NAME_PLACEHOLDER,
33+
ENGINE_CREATION_FORM_SUBMIT_BUTTON_LABEL,
34+
ENGINE_CREATION_FORM_TITLE,
35+
ENGINE_CREATION_TITLE,
3636
SANITIZED_NAME_NOTE,
3737
SUPPORTED_LANGUAGES,
3838
} from './constants';
39-
import { CreateEngineLogic } from './create_engine_logic';
39+
import { EngineCreationLogic } from './engine_creation_logic';
4040

41-
export const CreateEngine: React.FC = () => {
42-
const { name, rawName, language } = useValues(CreateEngineLogic);
43-
const { setLanguage, setRawName, submitEngine } = useActions(CreateEngineLogic);
41+
export const EngineCreation: React.FC = () => {
42+
const { name, rawName, language } = useValues(EngineCreationLogic);
43+
const { setLanguage, setRawName, submitEngine } = useActions(EngineCreationLogic);
4444

4545
return (
46-
<div data-test-subj="CreateEngine">
47-
<SetPageChrome trail={[CREATE_ENGINE_TITLE]} />
46+
<div data-test-subj="EngineCreation">
47+
<SetPageChrome trail={[ENGINE_CREATION_TITLE]} />
4848
<EuiPageHeader>
4949
<EuiPageHeaderSection>
5050
<EuiTitle size="l">
51-
<h1>{CREATE_ENGINE_TITLE}</h1>
51+
<h1>{ENGINE_CREATION_TITLE}</h1>
5252
</EuiTitle>
5353
</EuiPageHeaderSection>
5454
</EuiPageHeader>
5555
<FlashMessages />
5656
<EuiPanel>
5757
<EuiForm>
5858
<form
59-
data-test-subj="CreateEngineForm"
59+
data-test-subj="EngineCreationForm"
6060
onSubmit={(e) => {
6161
e.preventDefault();
6262
submitEngine();
6363
}}
6464
>
6565
<EuiTitle>
66-
<EuiText>{CREATE_ENGINE_FORM_TITLE}</EuiText>
66+
<EuiText>{ENGINE_CREATION_FORM_TITLE}</EuiText>
6767
</EuiTitle>
6868
<EuiSpacer />
6969
<EuiFlexGroup>
7070
<EuiFlexItem>
7171
<EuiFormRow
72-
label={CREATE_ENGINE_FORM_ENGINE_NAME_LABEL}
72+
label={ENGINE_CREATION_FORM_ENGINE_NAME_LABEL}
7373
helpText={
7474
name.length > 0 && rawName !== name ? (
7575
<>
@@ -87,19 +87,19 @@ export const CreateEngine: React.FC = () => {
8787
onChange={(event) => setRawName(event.currentTarget.value)}
8888
autoComplete="off"
8989
fullWidth={true}
90-
data-test-subj="CreateEngineNameInput"
91-
placeholder={CREATE_ENGINE_FORM_ENGINE_NAME_PLACEHOLDER}
90+
data-test-subj="EngineCreationNameInput"
91+
placeholder={ENGINE_CREATION_FORM_ENGINE_NAME_PLACEHOLDER}
9292
autoFocus={true}
9393
/>
9494
</EuiFormRow>
9595
</EuiFlexItem>
9696
<EuiFlexItem grow={false}>
97-
<EuiFormRow label={CREATE_ENGINE_FORM_ENGINE_LANGUAGE_LABEL}>
97+
<EuiFormRow label={ENGINE_CREATION_FORM_ENGINE_LANGUAGE_LABEL}>
9898
<EuiSelect
9999
name="engine-language"
100100
value={language}
101101
options={SUPPORTED_LANGUAGES}
102-
data-test-subj="CreateEngineLanguageInput"
102+
data-test-subj="EngineCreationLanguageInput"
103103
onChange={(event) => setLanguage(event.target.value)}
104104
/>
105105
</EuiFormRow>
@@ -113,7 +113,7 @@ export const CreateEngine: React.FC = () => {
113113
fill
114114
color="secondary"
115115
>
116-
{CREATE_ENGINE_FORM_SUBMIT_BUTTON_LABEL}
116+
{ENGINE_CREATION_FORM_SUBMIT_BUTTON_LABEL}
117117
</EuiButton>
118118
</form>
119119
</EuiForm>

x-pack/plugins/enterprise_search/public/applications/app_search/components/create_engine/create_engine_logic.test.ts renamed to x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_creation/engine_creation_logic.test.ts

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ import { generatePath } from 'react-router-dom';
1717
import { ENGINE_PATH } from '../../routes';
1818
import { formatApiName } from '../../utils/format_api_name';
1919

20-
import { CREATE_ENGINE_SUCCESS_MESSAGE } from './constants';
21-
import { CreateEngineLogic, DEFAULT_LANGUAGE } from './create_engine_logic';
20+
import { ENGINE_CREATION_SUCCESS_MESSAGE } from './constants';
21+
import { EngineCreationLogic, DEFAULT_LANGUAGE } from './engine_creation_logic';
2222

23-
describe('CreateEngineLogic', () => {
24-
const { mount } = new LogicMounter(CreateEngineLogic);
23+
describe('EngineCreationLogic', () => {
24+
const { mount } = new LogicMounter(EngineCreationLogic);
2525
const { http } = mockHttpValues;
2626
const { navigateToUrl } = mockKibanaValues;
2727
const { setQueuedSuccessMessage, flashAPIErrors } = mockFlashMessageHelpers;
@@ -34,15 +34,15 @@ describe('CreateEngineLogic', () => {
3434

3535
it('has expected default values', () => {
3636
mount();
37-
expect(CreateEngineLogic.values).toEqual(DEFAULT_VALUES);
37+
expect(EngineCreationLogic.values).toEqual(DEFAULT_VALUES);
3838
});
3939

4040
describe('actions', () => {
4141
describe('setLanguage', () => {
4242
it('sets language to the provided value', () => {
4343
mount();
44-
CreateEngineLogic.actions.setLanguage('English');
45-
expect(CreateEngineLogic.values).toEqual({
44+
EngineCreationLogic.actions.setLanguage('English');
45+
expect(EngineCreationLogic.values).toEqual({
4646
...DEFAULT_VALUES,
4747
language: 'English',
4848
});
@@ -55,36 +55,38 @@ describe('CreateEngineLogic', () => {
5555

5656
beforeAll(() => {
5757
mount();
58-
CreateEngineLogic.actions.setRawName(newName);
58+
EngineCreationLogic.actions.setRawName(newName);
5959
});
6060

6161
describe('rawName', () => {
6262
it('should be set to provided value', () => {
63-
expect(CreateEngineLogic.values.rawName).toEqual(newName);
63+
expect(EngineCreationLogic.values.rawName).toEqual(newName);
6464
});
6565
});
6666

6767
describe('name', () => {
6868
it('should be set to a sanitized value', () => {
69-
expect(CreateEngineLogic.values.name).toEqual(sanitizedNewName);
69+
expect(EngineCreationLogic.values.name).toEqual(sanitizedNewName);
7070
});
7171
});
7272
});
7373
});
7474

7575
describe('listeners', () => {
76-
describe('onCreateEngineSuccess', () => {
76+
describe('onEngineCreationSuccess', () => {
7777
beforeAll(() => {
7878
mount({ language: 'English', rawName: 'test' });
79-
CreateEngineLogic.actions.onCreateEngineSuccess();
79+
EngineCreationLogic.actions.onEngineCreationSuccess();
8080
});
8181

8282
it('should set a success message', () => {
83-
expect(setQueuedSuccessMessage).toHaveBeenCalledWith(CREATE_ENGINE_SUCCESS_MESSAGE);
83+
expect(setQueuedSuccessMessage).toHaveBeenCalledWith(ENGINE_CREATION_SUCCESS_MESSAGE);
8484
});
8585

8686
it('should navigate the user to the engine page', () => {
87-
const enginePath = generatePath(ENGINE_PATH, { engineName: CreateEngineLogic.values.name });
87+
const enginePath = generatePath(ENGINE_PATH, {
88+
engineName: EngineCreationLogic.values.name,
89+
});
8890
expect(navigateToUrl).toHaveBeenCalledWith(enginePath);
8991
});
9092
});
@@ -96,24 +98,24 @@ describe('CreateEngineLogic', () => {
9698

9799
it('POSTS to /api/app_search/engines', () => {
98100
const body = JSON.stringify({
99-
name: CreateEngineLogic.values.name,
100-
language: CreateEngineLogic.values.language,
101+
name: EngineCreationLogic.values.name,
102+
language: EngineCreationLogic.values.language,
101103
});
102-
CreateEngineLogic.actions.submitEngine();
104+
EngineCreationLogic.actions.submitEngine();
103105
expect(http.post).toHaveBeenCalledWith('/api/app_search/engines', { body });
104106
});
105107

106-
it('calls onCreateEngineSuccess on valid submission', async () => {
107-
jest.spyOn(CreateEngineLogic.actions, 'onCreateEngineSuccess');
108+
it('calls onEngineCreationSuccess on valid submission', async () => {
109+
jest.spyOn(EngineCreationLogic.actions, 'onEngineCreationSuccess');
108110
http.post.mockReturnValueOnce(Promise.resolve({}));
109-
await CreateEngineLogic.actions.submitEngine();
111+
await EngineCreationLogic.actions.submitEngine();
110112
await nextTick();
111-
expect(CreateEngineLogic.actions.onCreateEngineSuccess).toHaveBeenCalledTimes(1);
113+
expect(EngineCreationLogic.actions.onEngineCreationSuccess).toHaveBeenCalledTimes(1);
112114
});
113115

114116
it('calls flashAPIErrors on API Error', async () => {
115117
http.post.mockReturnValueOnce(Promise.reject());
116-
await CreateEngineLogic.actions.submitEngine();
118+
await EngineCreationLogic.actions.submitEngine();
117119
await nextTick();
118120
expect(flashAPIErrors).toHaveBeenCalledTimes(1);
119121
});

0 commit comments

Comments
 (0)