mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Console] Fix an error with folds in the editor (#152366)
## Summary Fixes https://github.com/elastic/kibana/issues/151563 There is a combination of the folds in the editor (collapsed lines) and the text that can cause the editor to fail. This PR adds a try/catch clause to the editor, so that the UI can still be used. ### How to use 1. Open Kibana and in your browser's Dev Tools, delete everything from local storage. 2. Add following 2 items back to the local storage: ``` sense:folds [{"start":{"row":1,"column":1},"end":{"row":82,"column":4}}] sense:console_local_text-object_e69f508c-3342-45cf-ae7c-2753548ce8e7 {"id":"e69f508c-3342-45cf-ae7c-2753548ce8e7","createdAt":1675332935410,"updatedAt":1676630754720,"text":"GET _cat/indices"} ``` 3. Navigate to Console in Kibana, make sure the editor works. ### Checklist - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
This commit is contained in:
parent
dadc9c93fc
commit
b3807ba0b9
2 changed files with 29 additions and 7 deletions
|
@ -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
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue