Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Discover] Unskip shared links test #168923

Merged
merged 3 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setting this time range by UISettings is always a bit faster than doing it via UI


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);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no more reason to sleep!


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