Skip to content

Commit

Permalink
[Discover] Unskip shared links test (elastic#168923)
Browse files Browse the repository at this point in the history
Improves and unskips Discover's shared links tests, and makes them a few seconds faster on top
Flaky test runner (100): https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/3515
  • Loading branch information
kertal authored and benakansara committed Oct 22, 2023
1 parent 0836d3d commit 3d40aa1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 26 deletions.
36 changes: 11 additions & 25 deletions test/functional/apps/discover/group1/_shared_links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,18 @@ 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');
await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional');

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 () => {
Expand Down Expand Up @@ -144,8 +133,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<void>;
before(async function () {
teardown = await setup({ storeStateInSessionStorage: true });
Expand All @@ -168,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 browser.get(currentUrl, false);
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();
});
});
});
Expand Down
6 changes: 5 additions & 1 deletion test/functional/services/toasts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down

0 comments on commit 3d40aa1

Please sign in to comment.