From a76707dfbf0baaa734c2f2211d694497d84feda9 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Tue, 21 Sep 2021 19:11:01 +0200 Subject: [PATCH 1/5] Harden functional test --- .../apps/discover/_indexpattern_without_timefield.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/functional/apps/discover/_indexpattern_without_timefield.ts b/test/functional/apps/discover/_indexpattern_without_timefield.ts index 74713553fa543..804fd01aa897a 100644 --- a/test/functional/apps/discover/_indexpattern_without_timefield.ts +++ b/test/functional/apps/discover/_indexpattern_without_timefield.ts @@ -9,6 +9,7 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { + const retry = getService('retry'); const browser = getService('browser'); const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); @@ -16,8 +17,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const testSubjects = getService('testSubjects'); const PageObjects = getPageObjects(['common', 'timePicker', 'discover']); - // Failing: See https://github.com/elastic/kibana/issues/107057 - describe.skip('indexpattern without timefield', () => { + describe('indexpattern without timefield', () => { before(async () => { await security.testUser.setRoles(['kibana_admin', 'kibana_timefield']); await esArchiver.loadIfNeeded( @@ -71,8 +71,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { if (!(await PageObjects.timePicker.timePickerExists())) { throw new Error('Expected timepicker to exist'); } - // Navigating back to discover + // Navigating back await browser.goBack(); + await retry.waitFor( + 'index pattern to have been switched', + async () => (await textSubjects.getVisibleText('indexPattern-switcher')) === 'without-timefield' + ); + if (await PageObjects.timePicker.timePickerExists()) { throw new Error('Expected timepicker not to exist'); } From 300c1e0403d62d87312a61d816a8ee128237527e Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Wed, 22 Sep 2021 07:19:28 +0200 Subject: [PATCH 2/5] Fix test --- .../apps/discover/_indexpattern_without_timefield.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/functional/apps/discover/_indexpattern_without_timefield.ts b/test/functional/apps/discover/_indexpattern_without_timefield.ts index 804fd01aa897a..0edda5d4fbc8a 100644 --- a/test/functional/apps/discover/_indexpattern_without_timefield.ts +++ b/test/functional/apps/discover/_indexpattern_without_timefield.ts @@ -75,7 +75,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await browser.goBack(); await retry.waitFor( 'index pattern to have been switched', - async () => (await textSubjects.getVisibleText('indexPattern-switcher')) === 'without-timefield' + async () => + (await testSubjects.getVisibleText('indexPattern-switcher')) === 'without-timefield' ); if (await PageObjects.timePicker.timePickerExists()) { From 3986f0e1e1369fa2dd31c158b239b766bd120973 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Wed, 22 Sep 2021 10:54:47 +0200 Subject: [PATCH 3/5] Fix test --- .../apps/discover/_indexpattern_without_timefield.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/functional/apps/discover/_indexpattern_without_timefield.ts b/test/functional/apps/discover/_indexpattern_without_timefield.ts index 0edda5d4fbc8a..f730d727e0c2d 100644 --- a/test/functional/apps/discover/_indexpattern_without_timefield.ts +++ b/test/functional/apps/discover/_indexpattern_without_timefield.ts @@ -74,9 +74,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // Navigating back await browser.goBack(); await retry.waitFor( - 'index pattern to have been switched', + 'index pattern to have been switched back to "without-timefield"', async () => - (await testSubjects.getVisibleText('indexPattern-switcher')) === 'without-timefield' + (await testSubjects.getVisibleText('indexPattern-switch-link')) === 'without-timefield' ); if (await PageObjects.timePicker.timePickerExists()) { From ba2e0b46bd899019150e807328bf0726f79b977e Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Mon, 27 Sep 2021 14:18:37 +0200 Subject: [PATCH 4/5] Update _indexpattern_without_timefield.ts --- .../apps/discover/_indexpattern_without_timefield.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/functional/apps/discover/_indexpattern_without_timefield.ts b/test/functional/apps/discover/_indexpattern_without_timefield.ts index f730d727e0c2d..816261dbdf38e 100644 --- a/test/functional/apps/discover/_indexpattern_without_timefield.ts +++ b/test/functional/apps/discover/_indexpattern_without_timefield.ts @@ -73,8 +73,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { } // Navigating back await browser.goBack(); - await retry.waitFor( + await retry.waitForWithTimeout( 'index pattern to have been switched back to "without-timefield"', + 5000, async () => (await testSubjects.getVisibleText('indexPattern-switch-link')) === 'without-timefield' ); From 0c7844354b025a6eda7afd8b750d3fc0aba50665 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Tue, 28 Sep 2021 07:57:28 +0200 Subject: [PATCH 5/5] Update _indexpattern_without_timefield.ts --- .../apps/discover/_indexpattern_without_timefield.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/functional/apps/discover/_indexpattern_without_timefield.ts b/test/functional/apps/discover/_indexpattern_without_timefield.ts index 816261dbdf38e..81fb4f92ab730 100644 --- a/test/functional/apps/discover/_indexpattern_without_timefield.ts +++ b/test/functional/apps/discover/_indexpattern_without_timefield.ts @@ -57,22 +57,26 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should display a timepicker after switching to an index pattern with timefield', async () => { await PageObjects.discover.selectIndexPattern('with-timefield'); + await PageObjects.discover.waitForDocTableLoadingComplete(); if (!(await PageObjects.timePicker.timePickerExists())) { throw new Error('Expected timepicker to exist'); } }); it('should switch between with and without timefield using the browser back button', async () => { await PageObjects.discover.selectIndexPattern('without-timefield'); + await PageObjects.discover.waitForDocTableLoadingComplete(); if (await PageObjects.timePicker.timePickerExists()) { throw new Error('Expected timepicker not to exist'); } await PageObjects.discover.selectIndexPattern('with-timefield'); + await PageObjects.discover.waitForDocTableLoadingComplete(); if (!(await PageObjects.timePicker.timePickerExists())) { throw new Error('Expected timepicker to exist'); } // Navigating back await browser.goBack(); + await PageObjects.discover.waitForDocTableLoadingComplete(); await retry.waitForWithTimeout( 'index pattern to have been switched back to "without-timefield"', 5000,