From ef55d8c1c0abed5433e8dcb09ded3e8904391141 Mon Sep 17 00:00:00 2001 From: Ignacio Rivas Date: Mon, 18 Dec 2023 16:03:13 +0100 Subject: [PATCH] [8.12] [Index Management] Fix index templates flaky tests (#172949) (#173479) Closes https://github.com/elastic/kibana/issues/172831 Closes https://github.com/elastic/kibana/issues/172832 # Backport This will backport the following commits from `main` to `8.12`: - [[Index Management] Fix index templates flaky tests (#172949)](https://github.com/elastic/kibana/pull/172949) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) --- .../public/forms/form_wizard/form_wizard.tsx | 1 + .../index_management/index_templates.ts | 24 +++++++++---------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/plugins/es_ui_shared/public/forms/form_wizard/form_wizard.tsx b/src/plugins/es_ui_shared/public/forms/form_wizard/form_wizard.tsx index 5f4561d3c8b1f..7961142d923ff 100644 --- a/src/plugins/es_ui_shared/public/forms/form_wizard/form_wizard.tsx +++ b/src/plugins/es_ui_shared/public/forms/form_wizard/form_wizard.tsx @@ -94,6 +94,7 @@ export function FormWizard navigateToStep(index), }; }); diff --git a/x-pack/test_serverless/functional/test_suites/common/management/index_management/index_templates.ts b/x-pack/test_serverless/functional/test_suites/common/management/index_management/index_templates.ts index d615087f476ef..791d3c313b7ab 100644 --- a/x-pack/test_serverless/functional/test_suites/common/management/index_management/index_templates.ts +++ b/x-pack/test_serverless/functional/test_suites/common/management/index_management/index_templates.ts @@ -13,16 +13,14 @@ import type { WebElementWrapper } from '../../../../../../../test/functional/ser export default ({ getPageObjects, getService }: FtrProviderContext) => { const pageObjects = getPageObjects(['svlCommonPage', 'common', 'indexManagement', 'header']); const browser = getService('browser'); - const security = getService('security'); const testSubjects = getService('testSubjects'); const es = getService('es'); + const retry = getService('retry'); const TEST_TEMPLATE = 'a_test_template'; describe('Index Templates', function () { before(async () => { - await security.testUser.setRoles(['index_management_user']); - // Navigate to the index management page await pageObjects.svlCommonPage.login(); }); @@ -53,7 +51,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { }); after(async () => { - await es.indices.deleteIndexTemplate({ name: TEST_TEMPLATE }); + await es.indices.deleteIndexTemplate({ name: TEST_TEMPLATE }, { ignore: [404] }); }); it('Displays the test template in the list of templates', async () => { @@ -77,25 +75,25 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { }); describe('Create index template', () => { + const TEST_TEMPLATE_NAME = `test_template_${Math.random()}`; + after(async () => { - await es.indices.deleteIndexTemplate({ name: TEST_TEMPLATE }); + await es.indices.deleteIndexTemplate({ name: TEST_TEMPLATE_NAME }, { ignore: [404] }); }); it('Creates index template', async () => { await testSubjects.click('createTemplateButton'); - await testSubjects.setValue('nameField', TEST_TEMPLATE); + await testSubjects.setValue('nameField', TEST_TEMPLATE_NAME); await testSubjects.setValue('indexPatternsField', 'test*'); - // Finish wizard flow - await testSubjects.click('nextButton'); - await testSubjects.click('nextButton'); - await testSubjects.click('nextButton'); - await testSubjects.click('nextButton'); - await testSubjects.click('nextButton'); + // Click form summary step and then the submit button + await testSubjects.click('formWizardStep-5'); await testSubjects.click('nextButton'); - expect(await testSubjects.getVisibleText('title')).to.contain(TEST_TEMPLATE); + await retry.try(async () => { + expect(await testSubjects.getVisibleText('stepTitle')).to.contain(TEST_TEMPLATE_NAME); + }); }); }); });