From 64f5effcb7e74bd2218a0a6ae880676ff107bf48 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Sun, 6 Oct 2024 22:02:47 -0500 Subject: [PATCH 01/12] use simulate by name for saved index templates --- .../simulate_template/simulate_template.tsx | 19 ++++++---- .../template_details/tabs/tab_preview.tsx | 7 ++-- .../template_details_content.tsx | 2 +- .../public/application/services/api.ts | 18 +++++++-- .../api/templates/register_simulate_route.ts | 37 +++++++++++++------ 5 files changed, 56 insertions(+), 27 deletions(-) diff --git a/x-pack/plugins/index_management/public/application/components/index_templates/simulate_template/simulate_template.tsx b/x-pack/plugins/index_management/public/application/components/index_templates/simulate_template/simulate_template.tsx index ed22baae580cc..fd1df7ba44697 100644 --- a/x-pack/plugins/index_management/public/application/components/index_templates/simulate_template/simulate_template.tsx +++ b/x-pack/plugins/index_management/public/application/components/index_templates/simulate_template/simulate_template.tsx @@ -23,22 +23,25 @@ export interface Filters { } interface Props { - template: { [key: string]: any }; + template?: { [key: string]: any }; filters?: Filters; + templateName?: string; } -export const SimulateTemplate = React.memo(({ template, filters }: Props) => { +export const SimulateTemplate = React.memo(({ template, filters, templateName }: Props) => { const [templatePreview, setTemplatePreview] = useState('{}'); const updatePreview = useCallback(async () => { - if (!template || Object.keys(template).length === 0) { + if (!templateName && (!template || Object.keys(template).length === 0)) { return; } - const indexTemplate = serializeTemplate( - stripEmptyFields(template, { types: ['string'] }) as TemplateDeserialized - ); - const { data, error } = await simulateIndexTemplate(indexTemplate); + const indexTemplate = templateName + ? undefined + : serializeTemplate( + stripEmptyFields(template, { types: ['string'] }) as TemplateDeserialized + ); + const { data, error } = await simulateIndexTemplate({ template: indexTemplate, templateName }); let filteredTemplate = data; if (data) { @@ -67,7 +70,7 @@ export const SimulateTemplate = React.memo(({ template, filters }: Props) => { } setTemplatePreview(JSON.stringify(filteredTemplate ?? error, null, 2)); - }, [template, filters]); + }, [template, filters, templateName]); useEffect(() => { updatePreview(); diff --git a/x-pack/plugins/index_management/public/application/sections/home/template_list/template_details/tabs/tab_preview.tsx b/x-pack/plugins/index_management/public/application/sections/home/template_list/template_details/tabs/tab_preview.tsx index 38f4a8b4f787b..02df1f6e1c682 100644 --- a/x-pack/plugins/index_management/public/application/sections/home/template_list/template_details/tabs/tab_preview.tsx +++ b/x-pack/plugins/index_management/public/application/sections/home/template_list/template_details/tabs/tab_preview.tsx @@ -8,14 +8,13 @@ import React from 'react'; import { FormattedMessage } from '@kbn/i18n-react'; import { EuiText, EuiSpacer } from '@elastic/eui'; -import { TemplateDeserialized } from '../../../../../../../common'; import { SimulateTemplate } from '../../../../../components/index_templates'; interface Props { - templateDetails: TemplateDeserialized; + templateName: string; } -export const TabPreview = ({ templateDetails }: Props) => { +export const TabPreview = ({ templateName }: Props) => { return (
@@ -29,7 +28,7 @@ export const TabPreview = ({ templateDetails }: Props) => { - +
); }; diff --git a/x-pack/plugins/index_management/public/application/sections/home/template_list/template_details/template_details_content.tsx b/x-pack/plugins/index_management/public/application/sections/home/template_list/template_details/template_details_content.tsx index d2156d1aa958e..75446c0c05f2d 100644 --- a/x-pack/plugins/index_management/public/application/sections/home/template_list/template_details/template_details_content.tsx +++ b/x-pack/plugins/index_management/public/application/sections/home/template_list/template_details/template_details_content.tsx @@ -171,7 +171,7 @@ export const TemplateDetailsContent = ({ [SETTINGS_TAB_ID]: , [MAPPINGS_TAB_ID]: , [ALIASES_TAB_ID]: , - [PREVIEW_TAB_ID]: , + [PREVIEW_TAB_ID]: , }; const tabContent = tabToComponentMap[activeTab]; diff --git a/x-pack/plugins/index_management/public/application/services/api.ts b/x-pack/plugins/index_management/public/application/services/api.ts index 08baa49713573..9f03007014c4f 100644 --- a/x-pack/plugins/index_management/public/application/services/api.ts +++ b/x-pack/plugins/index_management/public/application/services/api.ts @@ -319,11 +319,23 @@ export async function updateTemplate(template: TemplateDeserialized) { return result; } -export function simulateIndexTemplate(template: { [key: string]: any }) { +export function simulateIndexTemplate({ + template, + templateName, +}: { + template?: { [key: string]: any }; + templateName?: string; +}) { + const path = templateName + ? `${API_BASE_PATH}/index_templates/simulate/${templateName}` + : `${API_BASE_PATH}/index_templates/simulate`; + + const body = templateName ? undefined : JSON.stringify(template); + return sendRequest({ - path: `${API_BASE_PATH}/index_templates/simulate`, + path, method: 'post', - body: JSON.stringify(template), + body, }).then((result) => { uiMetricService.trackMetric(METRIC_TYPE.COUNT, UIM_TEMPLATE_SIMULATE); return result; diff --git a/x-pack/plugins/index_management/server/routes/api/templates/register_simulate_route.ts b/x-pack/plugins/index_management/server/routes/api/templates/register_simulate_route.ts index 3dc6201f0831c..3506a6a830a74 100644 --- a/x-pack/plugins/index_management/server/routes/api/templates/register_simulate_route.ts +++ b/x-pack/plugins/index_management/server/routes/api/templates/register_simulate_route.ts @@ -15,23 +15,38 @@ const bodySchema = schema.object({}, { unknowns: 'allow' }); export function registerSimulateRoute({ router, lib: { handleEsError } }: RouteDependencies) { router.post( { - path: addBasePath('/index_templates/simulate'), - validate: { body: bodySchema }, + path: addBasePath('/index_templates/simulate/{templateName?}'), + validate: { + body: schema.nullable(bodySchema), + params: schema.object({ templateName: schema.maybe(schema.string()) }), + }, }, async (context, request, response) => { const { client } = (await context.core).elasticsearch; const template = request.body as TypeOf; + // eslint-disable-next-line @typescript-eslint/naming-convention + const index_patterns = ['a_fake_index_pattern_that_wont_match_any_indices']; + const templateName = request.params.templateName; + + const params: estypes.IndicesSimulateTemplateRequest = templateName + ? { + name: templateName, + body: { + index_patterns, + }, + } + : { + body: { + ...template, + // Until ES fixes a bug on their side we need to send a fake index pattern + // that won't match any indices. + // Issue: https://github.com/elastic/elasticsearch/issues/59152 + index_patterns, + }, + }; try { - const templatePreview = await client.asCurrentUser.indices.simulateTemplate({ - body: { - ...template, - // Until ES fixes a bug on their side we need to send a fake index pattern - // that won't match any indices. - // Issue: https://github.com/elastic/elasticsearch/issues/59152 - index_patterns: ['a_fake_index_pattern_that_wont_match_any_indices'], - }, - } as estypes.IndicesSimulateTemplateRequest); + const templatePreview = await client.asCurrentUser.indices.simulateTemplate(params); return response.ok({ body: templatePreview }); } catch (error) { From b82eb045aaa5ad148cde1f43a7a73c14bffcfde2 Mon Sep 17 00:00:00 2001 From: Matthew Kime Date: Sun, 3 Nov 2024 17:05:04 -0600 Subject: [PATCH 02/12] fix test --- .../__jest__/client_integration/helpers/http_requests.ts | 7 +++++++ .../client_integration/home/index_templates_tab.test.ts | 4 +++- .../server/routes/api/templates/register_simulate_route.ts | 6 +++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/index_management/__jest__/client_integration/helpers/http_requests.ts b/x-pack/plugins/index_management/__jest__/client_integration/helpers/http_requests.ts index 8bd8672b8fbba..79daba4c73867 100644 --- a/x-pack/plugins/index_management/__jest__/client_integration/helpers/http_requests.ts +++ b/x-pack/plugins/index_management/__jest__/client_integration/helpers/http_requests.ts @@ -147,6 +147,12 @@ const registerHttpRequestMockHelpers = ( const setSimulateTemplateResponse = (response?: HttpResponse, error?: ResponseError) => mockResponse('POST', `${API_BASE_PATH}/index_templates/simulate`, response, error); + const setSimulateTemplateByNameResponse = ( + name: string, + response?: HttpResponse, + error?: ResponseError + ) => mockResponse('POST', `${API_BASE_PATH}/index_templates/simulate/${name}`, response, error); + const setLoadComponentTemplatesResponse = (response?: HttpResponse, error?: ResponseError) => mockResponse('GET', `${API_BASE_PATH}/component_templates`, response, error); @@ -229,6 +235,7 @@ const registerHttpRequestMockHelpers = ( setLoadIndexStatsResponse, setUpdateIndexSettingsResponse, setSimulateTemplateResponse, + setSimulateTemplateByNameResponse, setLoadComponentTemplatesResponse, setLoadNodesPluginsResponse, setLoadTelemetryResponse, diff --git a/x-pack/plugins/index_management/__jest__/client_integration/home/index_templates_tab.test.ts b/x-pack/plugins/index_management/__jest__/client_integration/home/index_templates_tab.test.ts index 615b8df18f905..ea536becfccac 100644 --- a/x-pack/plugins/index_management/__jest__/client_integration/home/index_templates_tab.test.ts +++ b/x-pack/plugins/index_management/__jest__/client_integration/home/index_templates_tab.test.ts @@ -617,7 +617,9 @@ describe('Index Templates tab', () => { const { find, actions, exists } = testBed; httpRequestsMockHelpers.setLoadTemplateResponse(templates[0].name, template); - httpRequestsMockHelpers.setSimulateTemplateResponse({ simulateTemplate: 'response' }); + httpRequestsMockHelpers.setSimulateTemplateByNameResponse(templates[0].name, { + simulateTemplate: 'response', + }); await actions.clickTemplateAt(0); diff --git a/x-pack/plugins/index_management/server/routes/api/templates/register_simulate_route.ts b/x-pack/plugins/index_management/server/routes/api/templates/register_simulate_route.ts index 3506a6a830a74..60e2cfbf8a53a 100644 --- a/x-pack/plugins/index_management/server/routes/api/templates/register_simulate_route.ts +++ b/x-pack/plugins/index_management/server/routes/api/templates/register_simulate_route.ts @@ -24,6 +24,9 @@ export function registerSimulateRoute({ router, lib: { handleEsError } }: RouteD async (context, request, response) => { const { client } = (await context.core).elasticsearch; const template = request.body as TypeOf; + // Until ES fixes a bug on their side we need to send a fake index pattern + // that won't match any indices. + // Issue: https://github.com/elastic/elasticsearch/issues/59152 // eslint-disable-next-line @typescript-eslint/naming-convention const index_patterns = ['a_fake_index_pattern_that_wont_match_any_indices']; const templateName = request.params.templateName; @@ -38,9 +41,6 @@ export function registerSimulateRoute({ router, lib: { handleEsError } }: RouteD : { body: { ...template, - // Until ES fixes a bug on their side we need to send a fake index pattern - // that won't match any indices. - // Issue: https://github.com/elastic/elasticsearch/issues/59152 index_patterns, }, }; From 3edfc1f6807768dd600766a564a3945d74d4b3d0 Mon Sep 17 00:00:00 2001 From: Matthew Kime Date: Sun, 3 Nov 2024 19:18:40 -0600 Subject: [PATCH 03/12] add tests --- .../index_management/lib/templates.api.ts | 7 +++ .../management/index_management/templates.ts | 13 ++++ .../index_management/index_template_wizard.ts | 61 +++++++++++++++++++ 3 files changed, 81 insertions(+) diff --git a/x-pack/test/api_integration/apis/management/index_management/lib/templates.api.ts b/x-pack/test/api_integration/apis/management/index_management/lib/templates.api.ts index bae578e6c0490..21585d9f699ac 100644 --- a/x-pack/test/api_integration/apis/management/index_management/lib/templates.api.ts +++ b/x-pack/test/api_integration/apis/management/index_management/lib/templates.api.ts @@ -53,6 +53,12 @@ export function templatesApi(getService: FtrProviderContext['getService']) { .set('kbn-xsrf', 'xxx') .send(payload); + const simulateTemplateByName = (name: string) => + supertest + .post(`${API_BASE_PATH}/index_templates/simulate/${name}`) + .set('kbn-xsrf', 'xxx') + .send(); + return { getAllTemplates, getOneTemplate, @@ -61,5 +67,6 @@ export function templatesApi(getService: FtrProviderContext['getService']) { deleteTemplates, cleanUpTemplates, simulateTemplate, + simulateTemplateByName, }; } diff --git a/x-pack/test/api_integration/apis/management/index_management/templates.ts b/x-pack/test/api_integration/apis/management/index_management/templates.ts index 66d6f34baa644..1fe7e022bfc9a 100644 --- a/x-pack/test/api_integration/apis/management/index_management/templates.ts +++ b/x-pack/test/api_integration/apis/management/index_management/templates.ts @@ -24,6 +24,7 @@ export default function ({ getService }: FtrProviderContext) { updateTemplate, cleanUpTemplates, simulateTemplate, + simulateTemplateByName, } = templatesApi(getService); describe('index templates', () => { @@ -452,6 +453,18 @@ export default function ({ getService }: FtrProviderContext) { const { body } = await simulateTemplate(payload).expect(200); expect(body.template).to.be.ok(); }); + + it('should simulate an index template by name', async () => { + const templateName = `template-${getRandomString()}`; + const payload = getTemplatePayload(templateName, [getRandomString()]); + + await createTemplate(payload).expect(200); + + await simulateTemplateByName(templateName).expect(200); + + // cleanup + await deleteTemplates([{ name: templateName }]); + }); }); }); } diff --git a/x-pack/test/functional/apps/index_management/index_template_wizard.ts b/x-pack/test/functional/apps/index_management/index_template_wizard.ts index cf6f1bf6a44a1..d3b5a6a1b2264 100644 --- a/x-pack/test/functional/apps/index_management/index_template_wizard.ts +++ b/x-pack/test/functional/apps/index_management/index_template_wizard.ts @@ -107,6 +107,67 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { }); }); + // https://github.com/elastic/kibana/pull/195174 + it('can preview index template that matches a_fake_index_pattern_that_wont_match_any_indices', async () => { + // Click Create Template button + await testSubjects.click('createTemplateButton'); + const pageTitleText = await testSubjects.getVisibleText('pageTitle'); + expect(pageTitleText).to.be('Create template'); + + const stepTitle1 = await testSubjects.getVisibleText('stepTitle'); + expect(stepTitle1).to.be('Logistics'); + + // Fill out required fields + await testSubjects.setValue('nameField', 'a*'); + await testSubjects.setValue('indexPatternsField', 'a*'); + + // Click Next button + await pageObjects.indexManagement.clickNextButton(); + + // Verify empty prompt + const emptyPrompt = await testSubjects.exists('emptyPrompt'); + expect(emptyPrompt).to.be(true); + + // Click Next button + await pageObjects.indexManagement.clickNextButton(); + + // Verify step title + const stepTitle2 = await testSubjects.getVisibleText('stepTitle'); + expect(stepTitle2).to.be('Index settings (optional)'); + + // Click Next button + await pageObjects.indexManagement.clickNextButton(); + + // Verify step title + const stepTitle3 = await testSubjects.getVisibleText('stepTitle'); + expect(stepTitle3).to.be('Mappings (optional)'); + + // Click Next button + await pageObjects.indexManagement.clickNextButton(); + + // Verify step title + const stepTitle4 = await testSubjects.getVisibleText('stepTitle'); + expect(stepTitle4).to.be('Aliases (optional)'); + + // Click Next button + await pageObjects.indexManagement.clickNextButton(); + + // Verify step title + const stepTitle = await testSubjects.getVisibleText('stepTitle'); + expect(stepTitle).to.be("Review details for 'test-index-template'"); + + // Verify that summary exists + const summaryTabContent = await testSubjects.exists('summaryTabContent'); + expect(summaryTabContent).to.be(true); + + // Verify that index mode is set to "Standard" + expect(await testSubjects.exists('indexModeTitle')).to.be(true); + expect(await testSubjects.getVisibleText('indexModeValue')).to.be('Standard'); + + // Click Create template + await pageObjects.indexManagement.clickNextButton(); + }); + describe('Mappings step', () => { beforeEach(async () => { await pageObjects.common.navigateToApp('indexManagement'); From 86a6e538f0432bbd7b8f8b9b1f2a277034d3083b Mon Sep 17 00:00:00 2001 From: Matthew Kime Date: Sun, 3 Nov 2024 21:09:13 -0600 Subject: [PATCH 04/12] Update index_template_wizard.ts --- .../functional/apps/index_management/index_template_wizard.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/test/functional/apps/index_management/index_template_wizard.ts b/x-pack/test/functional/apps/index_management/index_template_wizard.ts index d3b5a6a1b2264..17edd8bff7368 100644 --- a/x-pack/test/functional/apps/index_management/index_template_wizard.ts +++ b/x-pack/test/functional/apps/index_management/index_template_wizard.ts @@ -118,7 +118,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { expect(stepTitle1).to.be('Logistics'); // Fill out required fields - await testSubjects.setValue('nameField', 'a*'); + await testSubjects.setValue('nameField', 'a-star'); await testSubjects.setValue('indexPatternsField', 'a*'); // Click Next button From 83aad42b049ce084af311a3cc666ef2f4932e5d7 Mon Sep 17 00:00:00 2001 From: Matthew Kime Date: Sun, 3 Nov 2024 22:24:34 -0600 Subject: [PATCH 05/12] Update index_template_wizard.ts --- .../functional/apps/index_management/index_template_wizard.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/test/functional/apps/index_management/index_template_wizard.ts b/x-pack/test/functional/apps/index_management/index_template_wizard.ts index 17edd8bff7368..4b66a5509abde 100644 --- a/x-pack/test/functional/apps/index_management/index_template_wizard.ts +++ b/x-pack/test/functional/apps/index_management/index_template_wizard.ts @@ -154,7 +154,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { // Verify step title const stepTitle = await testSubjects.getVisibleText('stepTitle'); - expect(stepTitle).to.be("Review details for 'test-index-template'"); + expect(stepTitle).to.be("Review details for 'a-star'"); // Verify that summary exists const summaryTabContent = await testSubjects.exists('summaryTabContent'); From 30ceeb5a54afd49a6b546faa8d60b67e309ae5c0 Mon Sep 17 00:00:00 2001 From: Matthew Kime Date: Mon, 4 Nov 2024 18:00:08 -0600 Subject: [PATCH 06/12] fix functional test --- .../functional/apps/index_management/index_template_wizard.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/x-pack/test/functional/apps/index_management/index_template_wizard.ts b/x-pack/test/functional/apps/index_management/index_template_wizard.ts index d3b5a6a1b2264..dcf6739955cd2 100644 --- a/x-pack/test/functional/apps/index_management/index_template_wizard.ts +++ b/x-pack/test/functional/apps/index_management/index_template_wizard.ts @@ -166,6 +166,9 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { // Click Create template await pageObjects.indexManagement.clickNextButton(); + // todo more here + + await testSubjects.click('closeDetailsButton'); }); describe('Mappings step', () => { From 0e2e6357e1c377b7ee8a80b8b73b27f49a425374 Mon Sep 17 00:00:00 2001 From: Matthew Kime Date: Mon, 4 Nov 2024 20:38:36 -0600 Subject: [PATCH 07/12] set priority so subsequent tests work --- .../functional/apps/index_management/index_template_wizard.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/x-pack/test/functional/apps/index_management/index_template_wizard.ts b/x-pack/test/functional/apps/index_management/index_template_wizard.ts index b7b8cad267001..7b633762cb21f 100644 --- a/x-pack/test/functional/apps/index_management/index_template_wizard.ts +++ b/x-pack/test/functional/apps/index_management/index_template_wizard.ts @@ -120,6 +120,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { // Fill out required fields await testSubjects.setValue('nameField', 'a-star'); await testSubjects.setValue('indexPatternsField', 'a*'); + await testSubjects.setValue('priorityField', '1000'); // Click Next button await pageObjects.indexManagement.clickNextButton(); From 354445e103b345d91fb8a6087f33aae902f6a647 Mon Sep 17 00:00:00 2001 From: Matthew Kime Date: Mon, 11 Nov 2024 22:31:23 -0600 Subject: [PATCH 08/12] add test --- .../functional/apps/index_management/index_template_wizard.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/test/functional/apps/index_management/index_template_wizard.ts b/x-pack/test/functional/apps/index_management/index_template_wizard.ts index 7b633762cb21f..0a787646ce36e 100644 --- a/x-pack/test/functional/apps/index_management/index_template_wizard.ts +++ b/x-pack/test/functional/apps/index_management/index_template_wizard.ts @@ -169,7 +169,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await pageObjects.indexManagement.clickNextButton(); // todo more here - await testSubjects.click('closeDetailsButton'); + await testSubjects.click('closeDetailsButtonz'); }); describe('Mappings step', () => { From e402c65dca4e331834d1dc4d7e6962dcaf0fe0f2 Mon Sep 17 00:00:00 2001 From: Matthew Kime Date: Tue, 12 Nov 2024 09:33:24 -0600 Subject: [PATCH 09/12] add test --- .../template_details/template_details_content.tsx | 2 +- .../functional/apps/index_management/index_template_wizard.ts | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/index_management/public/application/sections/home/template_list/template_details/template_details_content.tsx b/x-pack/plugins/index_management/public/application/sections/home/template_list/template_details/template_details_content.tsx index 75446c0c05f2d..ca8cb1baaf0a3 100644 --- a/x-pack/plugins/index_management/public/application/sections/home/template_list/template_details/template_details_content.tsx +++ b/x-pack/plugins/index_management/public/application/sections/home/template_list/template_details/template_details_content.tsx @@ -216,7 +216,7 @@ export const TemplateDetailsContent = ({ }} isSelected={tab.id === activeTab} key={tab.id} - data-test-subj="tab" + data-test-subj={`tab-${tab.id}`} > {tab.name} diff --git a/x-pack/test/functional/apps/index_management/index_template_wizard.ts b/x-pack/test/functional/apps/index_management/index_template_wizard.ts index 0a787646ce36e..d4a996faeea41 100644 --- a/x-pack/test/functional/apps/index_management/index_template_wizard.ts +++ b/x-pack/test/functional/apps/index_management/index_template_wizard.ts @@ -167,6 +167,9 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { // Click Create template await pageObjects.indexManagement.clickNextButton(); + + await testSubjects.click('tab-preview'); + // const templatePreview = await testSubjects.getVisibleText('simulateTemplatePreview'); // todo more here await testSubjects.click('closeDetailsButtonz'); From 09e5196a609f1ea1aeff531e8e3969dd1d8bc74f Mon Sep 17 00:00:00 2001 From: Matthew Kime Date: Tue, 12 Nov 2024 11:23:54 -0600 Subject: [PATCH 10/12] add test --- .../apps/index_management/index_template_wizard.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/x-pack/test/functional/apps/index_management/index_template_wizard.ts b/x-pack/test/functional/apps/index_management/index_template_wizard.ts index d4a996faeea41..8426093f0bd08 100644 --- a/x-pack/test/functional/apps/index_management/index_template_wizard.ts +++ b/x-pack/test/functional/apps/index_management/index_template_wizard.ts @@ -168,11 +168,13 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { // Click Create template await pageObjects.indexManagement.clickNextButton(); - await testSubjects.click('tab-preview'); - // const templatePreview = await testSubjects.getVisibleText('simulateTemplatePreview'); - // todo more here + // Click preview tab, we know its the last one + const tabs = await testSubjects.findAll('tab'); + tabs[tabs.length - 1].click(); + const templatePreview = await testSubjects.getVisibleText('simulateTemplatePreview'); + expect(templatePreview).to.not.contain('error'); - await testSubjects.click('closeDetailsButtonz'); + await testSubjects.click('closeDetailsButton'); }); describe('Mappings step', () => { From 57513983dad6b04175999bf9a209f7b697a2a536 Mon Sep 17 00:00:00 2001 From: Matthew Kime Date: Tue, 12 Nov 2024 13:13:03 -0600 Subject: [PATCH 11/12] add test --- .../functional/apps/index_management/index_template_wizard.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/test/functional/apps/index_management/index_template_wizard.ts b/x-pack/test/functional/apps/index_management/index_template_wizard.ts index 8426093f0bd08..581a0b2761644 100644 --- a/x-pack/test/functional/apps/index_management/index_template_wizard.ts +++ b/x-pack/test/functional/apps/index_management/index_template_wizard.ts @@ -170,7 +170,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { // Click preview tab, we know its the last one const tabs = await testSubjects.findAll('tab'); - tabs[tabs.length - 1].click(); + await tabs[tabs.length - 1].click(); const templatePreview = await testSubjects.getVisibleText('simulateTemplatePreview'); expect(templatePreview).to.not.contain('error'); From da5a52aaf807b0c6c1ef06b60da1ca07f9c44f88 Mon Sep 17 00:00:00 2001 From: Matthew Kime Date: Tue, 12 Nov 2024 15:40:54 -0600 Subject: [PATCH 12/12] add test --- .../template_list/template_details/template_details_content.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/index_management/public/application/sections/home/template_list/template_details/template_details_content.tsx b/x-pack/plugins/index_management/public/application/sections/home/template_list/template_details/template_details_content.tsx index ca8cb1baaf0a3..75446c0c05f2d 100644 --- a/x-pack/plugins/index_management/public/application/sections/home/template_list/template_details/template_details_content.tsx +++ b/x-pack/plugins/index_management/public/application/sections/home/template_list/template_details/template_details_content.tsx @@ -216,7 +216,7 @@ export const TemplateDetailsContent = ({ }} isSelected={tab.id === activeTab} key={tab.id} - data-test-subj={`tab-${tab.id}`} + data-test-subj="tab" > {tab.name}