From a31888169e568b8ed0a4586850207ef85bc1f1fb Mon Sep 17 00:00:00 2001 From: John Dorlus Date: Thu, 2 Jul 2020 18:54:13 -0400 Subject: [PATCH] Fixed assertion in hybrid index pattern test to iterate through indices (#70130) (#70540) * Fixed assertion to check through all indices before making assertion. * Restored yarn.lock file. * Removed only from describe. * Fixed linting issue. * Fixed nits that were in the PR conversation. Co-authored-by: Elastic Machine Co-authored-by: Elastic Machine --- test/functional/page_objects/settings_page.ts | 7 +++++++ .../apps/rollup_job/hybrid_index_pattern.js | 11 +++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/test/functional/page_objects/settings_page.ts b/test/functional/page_objects/settings_page.ts index fb40b946d7fa3..4b80647c8749d 100644 --- a/test/functional/page_objects/settings_page.ts +++ b/test/functional/page_objects/settings_page.ts @@ -303,6 +303,13 @@ export function SettingsPageProvider({ getService, getPageObjects }: FtrProvider ); } + async getAllIndexPatternNames() { + const indexPatterns = await this.getIndexPatternList(); + return await mapAsync(indexPatterns, async (index) => { + return await index.getVisibleText(); + }); + } + async isIndexPatternListEmpty() { await testSubjects.existOrFail('indexPatternTable', { timeout: 5000 }); const indexPatternList = await this.getIndexPatternList(); diff --git a/x-pack/test/functional/apps/rollup_job/hybrid_index_pattern.js b/x-pack/test/functional/apps/rollup_job/hybrid_index_pattern.js index ea98df7163596..d6ed6ce13391e 100644 --- a/x-pack/test/functional/apps/rollup_job/hybrid_index_pattern.js +++ b/x-pack/test/functional/apps/rollup_job/hybrid_index_pattern.js @@ -81,10 +81,13 @@ export default function ({ getService, getPageObjects }) { await PageObjects.settings.createIndexPattern(rollupIndexPatternName, '@timestamp', false); await PageObjects.settings.clickKibanaIndexPatterns(); - const indexPattern = (await PageObjects.settings.getIndexPatternList()).pop(); - const indexPatternText = await indexPattern.getVisibleText(); - expect(indexPatternText).to.contain(rollupIndexPatternName); - expect(indexPatternText).to.contain('Rollup'); + const indexPatternNames = await PageObjects.settings.getAllIndexPatternNames(); + //The assertion is going to check that the string has the right name and that the text Rollup + //is included (since there is a Rollup tag). + const filteredIndexPatternNames = indexPatternNames.filter( + (i) => i.includes(rollupIndexPatternName) && i.includes('Rollup') + ); + expect(filteredIndexPatternNames.length).to.be(1); }); after(async () => {