From ba9a7c409c34d8b24af822476238f38e59daa9b8 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Mon, 16 Oct 2023 10:15:16 +0200 Subject: [PATCH 1/2] Unskip shared links test --- test/functional/apps/discover/group1/_shared_links.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/functional/apps/discover/group1/_shared_links.ts b/test/functional/apps/discover/group1/_shared_links.ts index e8f79ea1b427a..bb417023147a7 100644 --- a/test/functional/apps/discover/group1/_shared_links.ts +++ b/test/functional/apps/discover/group1/_shared_links.ts @@ -144,8 +144,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); }); - // FLAKY: https://github.com/elastic/kibana/issues/167405 - describe.skip('shared links with state in sessionStorage', async () => { + describe('shared links with state in sessionStorage', async () => { let teardown: () => Promise; before(async function () { teardown = await setup({ storeStateInSessionStorage: true }); @@ -182,8 +181,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it("sharing hashed url shouldn't crash the app", async () => { const currentUrl = await browser.getCurrentUrl(); await browser.clearSessionStorage(); - await browser.get(currentUrl, false); await retry.waitFor('discover to open', async () => { + await browser.get(currentUrl, false); const resolvedUrl = await browser.getCurrentUrl(); expect(resolvedUrl).to.match(/discover/); const { message } = await toasts.getErrorToast(); From b59be489842a062d9803236393b284795f11703b Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Mon, 16 Oct 2023 13:58:10 +0200 Subject: [PATCH 2/2] Improve test --- .../apps/discover/group1/_shared_links.ts | 31 ++++++------------- test/functional/services/toasts.ts | 6 +++- 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/test/functional/apps/discover/group1/_shared_links.ts b/test/functional/apps/discover/group1/_shared_links.ts index bb417023147a7..c6269cabfda98 100644 --- a/test/functional/apps/discover/group1/_shared_links.ts +++ b/test/functional/apps/discover/group1/_shared_links.ts @@ -33,11 +33,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { baseUrl = baseUrl.replace(':80', '').replace(':443', ''); log.debug('New baseUrl = ' + baseUrl); - // delete .kibana index and update configDoc - await kibanaServer.uiSettings.replace({ - defaultIndex: 'logstash-*', - }); - log.debug('load kibana index with default index pattern'); await kibanaServer.savedObjects.clean({ types: ['search', 'index-pattern'] }); await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover.json'); @@ -45,17 +40,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.uiSettings.replace({ 'state:storeInSessionStorage': storeStateInSessionStorage, + defaultIndex: 'logstash-*', }); + await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); - log.debug('discover'); await PageObjects.common.navigateToApp('discover'); - - await PageObjects.timePicker.setDefaultAbsoluteRange(); - - // After hiding the time picker, we need to wait for - // the refresh button to hide before clicking the share button - await PageObjects.common.sleep(1000); - await PageObjects.share.clickShareTopNavButton(); return async () => { @@ -167,31 +156,29 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await browser.clearSessionStorage(); await browser.get(actualUrl, false); - await retry.waitFor('shortUrl resolves and opens', async () => { + await retry.try(async () => { const resolvedUrl = await browser.getCurrentUrl(); expect(resolvedUrl).to.match(/discover/); const resolvedTime = await PageObjects.timePicker.getTimeConfig(); expect(resolvedTime.start).to.equal(actualTime.start); expect(resolvedTime.end).to.equal(actualTime.end); - await toasts.dismissAllToasts(); - return true; }); + await toasts.dismissAllToasts(); }); it("sharing hashed url shouldn't crash the app", async () => { const currentUrl = await browser.getCurrentUrl(); - await browser.clearSessionStorage(); - await retry.waitFor('discover to open', async () => { + await retry.try(async () => { + await browser.clearSessionStorage(); await browser.get(currentUrl, false); const resolvedUrl = await browser.getCurrentUrl(); expect(resolvedUrl).to.match(/discover/); - const { message } = await toasts.getErrorToast(); - expect(message).to.contain( + const { title } = await toasts.getErrorToast(1, true); + expect(title).to.contain( 'Unable to completely restore the URL, be sure to use the share functionality.' ); - await toasts.dismissAllToasts(); - return true; }); + await toasts.dismissAllToasts(); }); }); }); diff --git a/test/functional/services/toasts.ts b/test/functional/services/toasts.ts index ea105eb82fa93..a4d3b2dd3e457 100644 --- a/test/functional/services/toasts.ts +++ b/test/functional/services/toasts.ts @@ -19,12 +19,16 @@ export class ToastsService extends FtrService { * an additional button, that should not be part of the message. * * @param index The index of the toast (1-based, NOT 0-based!) of the toast. Use first by default. + * @param titleOnly If this is true, only the title of the error message is returned. There are error messages that only contain a title, no message. * @returns The title and message of the specified error toast.https://github.com/elastic/kibana/issues/17087 */ - public async getErrorToast(index: number = 1) { + public async getErrorToast(index: number = 1, titleOnly: boolean = false) { const toast = await this.getToastElement(index); const titleElement = await this.testSubjects.findDescendant('euiToastHeader', toast); const title: string = await titleElement.getVisibleText(); + if (titleOnly) { + return { title }; + } const messageElement = await this.testSubjects.findDescendant('errorToastMessage', toast); const message: string = await messageElement.getVisibleText(); return { title, message };