From 1d62ae5efc710e47fa5c217b10c1e8ef19fedf3c Mon Sep 17 00:00:00 2001 From: Lukas Olson Date: Mon, 28 Oct 2024 03:44:21 +0100 Subject: [PATCH] [8.16] Fix search session filter functional test (#193812) (#197503) # Backport This will backport the following commits from `main` to `8.16`: - [Fix search session filter functional test (#193812)](https://github.com/elastic/kibana/pull/193812) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) --- .../test_suites/data_plugin/session.ts | 32 +++++++++++++++---- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/test/plugin_functional/test_suites/data_plugin/session.ts b/test/plugin_functional/test_suites/data_plugin/session.ts index d69a7529a19ad..773664da7510e 100644 --- a/test/plugin_functional/test_suites/data_plugin/session.ts +++ b/test/plugin_functional/test_suites/data_plugin/session.ts @@ -23,27 +23,33 @@ export default function ({ getService, getPageObjects }: PluginFunctionalProvide const toasts = getService('toasts'); const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); + const retry = getService('retry'); + const browser = getService('browser'); const getSessionIds = async () => { const sessionsBtn = await testSubjects.find('showSessionsButton'); await sessionsBtn.click(); const toast = await toasts.getElementByIndex(1); const sessionIds = await toast.getVisibleText(); + await toasts.dismissAll(); return sessionIds.split(','); }; - // Failing: See https://github.com/elastic/kibana/issues/192510 - describe.skip('Session management', function describeSessionManagementTests() { + const clearSessionIds = async () => { + await testSubjects.click('clearSessionsButton'); + await toasts.dismissAll(); + }; + + describe('Session management', function describeSessionManagementTests() { describe('Discover', () => { before(async () => { await common.navigateToApp('discover'); - await testSubjects.click('clearSessionsButton'); + await clearSessionIds(); await header.waitUntilLoadingHasFinished(); }); afterEach(async () => { - await testSubjects.click('clearSessionsButton'); - await toasts.dismissAll(); + await clearSessionIds(); }); it('Starts on index pattern select', async () => { @@ -92,8 +98,7 @@ export default function ({ getService, getPageObjects }: PluginFunctionalProvide }); afterEach(async () => { - await testSubjects.click('clearSessionsButton'); - await toasts.dismissAll(); + await clearSessionIds(); }); after(async () => { @@ -114,6 +119,19 @@ export default function ({ getService, getPageObjects }: PluginFunctionalProvide }); it('starts a session on filter change', async () => { + // For some reason, when loading the dashboard, sometimes the filter doesn't show up, so we + // refresh until it shows up + await retry.try( + async () => { + const hasFilter = await filterBar.hasFilter('animal', 'dog'); + if (!hasFilter) throw new Error('filter not found'); + }, + async () => { + await browser.refresh(); + await header.waitUntilLoadingHasFinished(); + await clearSessionIds(); + } + ); await filterBar.removeFilter('animal'); const sessionIds = await getSessionIds(); expect(sessionIds.length).to.be(1);