diff --git a/src/plugins/console/public/application/models/legacy_core_editor/legacy_core_editor.ts b/src/plugins/console/public/application/models/legacy_core_editor/legacy_core_editor.ts index f8e411fabbb55..7cb07fbd31ea7 100644 --- a/src/plugins/console/public/application/models/legacy_core_editor/legacy_core_editor.ts +++ b/src/plugins/console/public/application/models/legacy_core_editor/legacy_core_editor.ts @@ -500,7 +500,11 @@ export class LegacyCoreEditor implements CoreEditor { addFoldsAtRanges(foldRanges: Range[]) { const session = this.editor.getSession(); foldRanges.forEach((range) => { - session.addFold('...', _AceRange.fromPoints(range.start, range.end)); + try { + session.addFold('...', _AceRange.fromPoints(range.start, range.end)); + } catch (e) { + // ignore the error if a fold fails + } }); } } diff --git a/test/functional/apps/console/_console.ts b/test/functional/apps/console/_console.ts index d7a591efca014..091ad8ee5a2e8 100644 --- a/test/functional/apps/console/_console.ts +++ b/test/functional/apps/console/_console.ts @@ -36,14 +36,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { log.debug('navigateTo console'); await PageObjects.common.navigateToApp('console'); }); + beforeEach(async () => { + await PageObjects.console.closeHelpIfExists(); + }); it('should show the default request', async () => { - // collapse the help pane because we only get the VISIBLE TEXT, not the part that is scrolled - // on IE11, the dialog that says 'Your browser does not meet the security requirements for Kibana.' - // blocks the close help button for several seconds so just retry until we can click it. - await retry.try(async () => { - await PageObjects.console.collapseHelp(); - }); await retry.try(async () => { const actualRequest = await PageObjects.console.getRequest(); log.debug(actualRequest); @@ -182,6 +179,27 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await PageObjects.header.waitUntilLoadingHasFinished(); expect(await PageObjects.console.hasFolds()).to.be(false); }); + + it(`doesn't fail if a fold fails`, async () => { + // for more details, see https://github.com/elastic/kibana/issues/151563 + await browser.clearLocalStorage(); + await browser.setLocalStorageItem( + 'sense:folds', + '[{"start":{"row":1,"column":1},"end":{"row":82,"column":4}}]' + ); + await browser.setLocalStorageItem( + 'sense:console_local_text-object_95a511b6-b6e1-4ea6-9344-428bf5183d88', + '{"id":"95a511b6-b6e1-4ea6-9344-428bf5183d88","createdAt":1677592109975,"updatedAt":1677592148666,"text":"GET _cat/indices"}' + ); + await browser.refresh(); + + await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.console.closeHelpIfExists(); + const request = await PageObjects.console.getRequest(); + // the request is restored from the local storage value + expect(request).to.eql('GET _cat/indices'); + await browser.clearLocalStorage(); + }); }); }); }