Skip to content

Commit 84dff59

Browse files
committed
[index management] Move tests from FTR to scout (elastic#242825)
## Summary Moving index management tests from FTR to scout. Scout hates it when the data-test-subj value has been used more than once so there are some changes to address that. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Karen Grigoryan <karen.grigoryan@elastic.co> (cherry picked from commit 7423325) # Conflicts: # x-pack/platform/plugins/shared/index_management/__jest__/client_integration/helpers/test_subjects.ts # x-pack/platform/plugins/shared/index_management/moon.yml # x-pack/platform/plugins/shared/index_management/tsconfig.json # x-pack/platform/test/functional/apps/index_management/home_page.ts # x-pack/platform/test/functional/apps/index_management/index_details_page.ts # x-pack/platform/test/functional/apps/index_management/index_template_wizard.ts
1 parent 2b4ac68 commit 84dff59

28 files changed

Lines changed: 768 additions & 512 deletions

File tree

.buildkite/scout_ci_config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ plugins:
33
enabled:
44
- console
55
- discover_enhanced
6+
- index_management
67
- maps
78
- observability_onboarding
89
- painless_lab

x-pack/platform/plugins/shared/index_management/__jest__/client_integration/helpers/test_subjects.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,10 @@ export type TestSubjects =
119119
| 'noIndicesMessage'
120120
| 'clearIndicesSearch'
121121
| 'usingMaxRetention'
122-
| 'componentTemplatesLink';
122+
| 'componentTemplatesLink'
123+
| 'summaryTabBtn'
124+
| 'settingsTabBtn'
125+
| 'mappingsTabBtn'
126+
| 'aliasesTabBtn'
127+
| 'previewTabBtn'
128+
| 'configureFailureStoreButton';

x-pack/platform/plugins/shared/index_management/__jest__/client_integration/home/index_templates_tab.helpers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ const createActions = (testBed: TestBed<TestSubjects>) => {
4343
const selectDetailsTab = async (
4444
tab: 'summary' | 'settings' | 'mappings' | 'aliases' | 'preview'
4545
) => {
46-
const tabs = ['summary', 'settings', 'mappings', 'aliases', 'preview'];
46+
const tabTestDataSubj = `${tab}TabBtn` as TestSubjects;
4747

4848
await act(async () => {
49-
testBed.find('templateDetails.tab').at(tabs.indexOf(tab)).simulate('click');
49+
testBed.find(tabTestDataSubj).simulate('click');
5050
});
5151
testBed.component.update();
5252
};

x-pack/platform/plugins/shared/index_management/__jest__/client_integration/home/index_templates_tab.test.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -623,14 +623,11 @@ describe('Index Templates tab', () => {
623623

624624
await actions.clickTemplateAt(0);
625625

626-
expect(find('templateDetails.tab').length).toBe(5);
627-
expect(find('templateDetails.tab').map((t) => t.text())).toEqual([
628-
'Summary',
629-
'Settings',
630-
'Mappings',
631-
'Aliases',
632-
'Preview',
633-
]);
626+
expect(exists('summaryTabBtn')).toBe(true);
627+
expect(exists('settingsTabBtn')).toBe(true);
628+
expect(exists('mappingsTabBtn')).toBe(true);
629+
expect(exists('aliasesTabBtn')).toBe(true);
630+
expect(exists('previewTabBtn')).toBe(true);
634631

635632
// Summary tab should be initial active tab
636633
expect(exists('summaryTab')).toBe(true);
@@ -670,15 +667,14 @@ describe('Index Templates tab', () => {
670667
isLegacy: true,
671668
});
672669

673-
const { actions, find, exists } = testBed;
670+
const { actions, exists } = testBed;
674671

675672
httpRequestsMockHelpers.setLoadTemplateResponse(
676673
templates[0].name,
677674
templateWithNoOptionalFields
678675
);
679676
await actions.clickTemplateAt(0);
680677

681-
expect(find('templateDetails.tab').length).toBe(5);
682678
expect(exists('summaryTab')).toBe(true);
683679

684680
// Navigate and verify callout message per tab

x-pack/platform/plugins/shared/index_management/__jest__/client_integration/index_template_wizard/template_create.test.tsx

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -390,21 +390,14 @@ describe('<TemplateCreate />', () => {
390390
});
391391

392392
describe('plugin parameters', () => {
393-
const selectMappingsEditorTab = async (
394-
tab: 'fields' | 'runtimeFields' | 'templates' | 'advanced'
395-
) => {
396-
const tabIndex = ['fields', 'runtimeFields', 'templates', 'advanced'].indexOf(tab);
397-
const tabElement = testBed.find('mappingsEditor.formTab').at(tabIndex);
398-
await act(async () => {
399-
tabElement.simulate('click');
400-
});
401-
testBed.component.update();
402-
};
403-
404393
test('should not render the _size parameter if the mapper size plugin is not installed', async () => {
405394
const { exists } = testBed;
406395
// Navigate to the advanced configuration
407-
await selectMappingsEditorTab('advanced');
396+
397+
await act(async () => {
398+
testBed.find('advancedOptionsTab').simulate('click');
399+
});
400+
testBed.component.update();
408401

409402
expect(exists('mappingsEditor.advancedConfiguration.sizeEnabledToggle')).toBe(false);
410403
});
@@ -418,7 +411,10 @@ describe('<TemplateCreate />', () => {
418411
testBed.component.update();
419412
await navigateToMappingsStep();
420413

421-
await selectMappingsEditorTab('advanced');
414+
await act(async () => {
415+
testBed.find('advancedOptionsTab').simulate('click');
416+
});
417+
testBed.component.update();
422418

423419
expect(testBed.exists('mappingsEditor.advancedConfiguration.sizeEnabledToggle')).toBe(
424420
true

x-pack/platform/plugins/shared/index_management/__jest__/client_integration/index_template_wizard/template_form.helpers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,6 @@ export type TestSubjects =
402402
| 'valueDataRetentionField'
403403
| 'formWizardStep-5'
404404
| 'lifecycleValue'
405-
| 'mappingsEditor.formTab'
406405
| 'mappingsEditor.advancedConfiguration.sizeEnabledToggle'
407-
| 'previewIndexTemplate';
406+
| 'previewIndexTemplate'
407+
| 'advancedOptionsTab';

x-pack/platform/plugins/shared/index_management/public/application/components/mappings_editor/__jest__/client_integration/helpers/mappings_editor.helpers.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,9 @@ const createActions = (testBed: TestBed<TestSubjects>) => {
313313
// --- Other ---
314314
const selectTab = async (tab: 'fields' | 'runtimeFields' | 'templates' | 'advanced') => {
315315
const index = ['fields', 'runtimeFields', 'templates', 'advanced'].indexOf(tab);
316+
const dataTestSubjValues = ['fieldsTab', 'runtimeTab', 'templatesTab', 'advancedOptionsTab'];
316317

317-
const tabElement = find('formTab').at(index);
318+
const tabElement = find(dataTestSubjValues[index]);
318319
if (tabElement.length === 0) {
319320
throw new Error(`Tab not found: "${tab}"`);
320321
}

x-pack/platform/plugins/shared/index_management/public/application/components/mappings_editor/__jest__/client_integration/mappings_editor.test.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,10 @@ describe('Mappings editor: core', () => {
165165

166166
test('should have 4 tabs (fields, runtime, template, advanced settings)', () => {
167167
const { find } = testBed;
168-
const tabs = find('formTab').map((wrapper) => wrapper.text());
169-
170-
expect(tabs).toEqual([
171-
'Mapped fields',
172-
'Runtime fields',
173-
'Dynamic templates',
168+
expect(find('fieldsTab').map((wrapper) => wrapper.text())).toEqual(['Mapped fields']);
169+
expect(find('runtimeTab').map((wrapper) => wrapper.text())).toEqual(['Runtime fields']);
170+
expect(find('templatesTab').map((wrapper) => wrapper.text())).toEqual(['Dynamic templates']);
171+
expect(find('advancedOptionsTab').map((wrapper) => wrapper.text())).toEqual([
174172
'Advanced options',
175173
]);
176174
});

x-pack/platform/plugins/shared/index_management/public/application/components/mappings_editor/mappings_editor.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ export const MappingsEditor = React.memo(
184184
<EuiTab
185185
onClick={() => changeTab('fields')}
186186
isSelected={selectedTab === 'fields'}
187-
data-test-subj="formTab"
187+
data-test-subj="fieldsTab"
188188
>
189189
{i18n.translate('xpack.idxMgmt.mappingsEditor.fieldsTabLabel', {
190190
defaultMessage: 'Mapped fields',
@@ -193,7 +193,7 @@ export const MappingsEditor = React.memo(
193193
<EuiTab
194194
onClick={() => changeTab('runtimeFields')}
195195
isSelected={selectedTab === 'runtimeFields'}
196-
data-test-subj="formTab"
196+
data-test-subj="runtimeTab"
197197
>
198198
{i18n.translate('xpack.idxMgmt.mappingsEditor.runtimeFieldsTabLabel', {
199199
defaultMessage: 'Runtime fields',
@@ -202,7 +202,7 @@ export const MappingsEditor = React.memo(
202202
<EuiTab
203203
onClick={() => changeTab('templates')}
204204
isSelected={selectedTab === 'templates'}
205-
data-test-subj="formTab"
205+
data-test-subj="templatesTab"
206206
>
207207
{i18n.translate('xpack.idxMgmt.mappingsEditor.templatesTabLabel', {
208208
defaultMessage: 'Dynamic templates',
@@ -211,7 +211,7 @@ export const MappingsEditor = React.memo(
211211
<EuiTab
212212
onClick={() => changeTab('advanced')}
213213
isSelected={selectedTab === 'advanced'}
214-
data-test-subj="formTab"
214+
data-test-subj="advancedOptionsTab"
215215
>
216216
{i18n.translate('xpack.idxMgmt.mappingsEditor.advancedTabLabel', {
217217
defaultMessage: 'Advanced options',

x-pack/platform/plugins/shared/index_management/public/application/components/no_match/no_match.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,13 @@ export const NoMatch = ({
9494
/>
9595
</p>
9696
}
97-
actions={<CreateIndexButton loadIndices={loadIndices} share={share} />}
97+
actions={
98+
<CreateIndexButton
99+
loadIndices={loadIndices}
100+
share={share}
101+
dataTestSubj="createIndexButtonEmptyList"
102+
/>
103+
}
98104
/>
99105
);
100106
};

0 commit comments

Comments
 (0)