mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[Discover] Fix blank page when switching between time ranges in SQL mode (#147665)
## Summary This PR fixes an issue where switching to a time range without data, then back to a time range with data would produce a blank page when in SQL mode. Fixes #147618. ### Checklist - [ ] ~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)~ - [ ] ~[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials~ - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] ~Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/))~ - [ ] ~Any UI touched in this PR does not create any new axe failures (run axe in browser: [FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/), [Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))~ - [ ] ~If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)~ - [ ] ~This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))~ - [ ] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers) ### For maintainers - [ ] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
This commit is contained in:
parent
cb39287156
commit
4af51e705d
3 changed files with 45 additions and 2 deletions
|
@ -258,8 +258,12 @@ export const useDiscoverHistogram = ({
|
|||
[field, isPlainRecord, isTimeBased]
|
||||
);
|
||||
|
||||
// Don't render the unified histogram layout until the first search has been requested
|
||||
return searchSessionId
|
||||
// Initialized when the first search has been requested or
|
||||
// when in SQL mode since search sessions are not supported
|
||||
const isInitialized = Boolean(searchSessionId) || isPlainRecord;
|
||||
|
||||
// Don't render the unified histogram layout until initialized
|
||||
return isInitialized
|
||||
? {
|
||||
topPanelHeight,
|
||||
request,
|
||||
|
|
|
@ -90,6 +90,29 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
const cell = await dataGrid.getCellElement(0, 3);
|
||||
expect(await cell.getVisibleText()).to.be('2269');
|
||||
});
|
||||
|
||||
it('should render when switching to a time range with no data, then back to a time range with data', async () => {
|
||||
await PageObjects.discover.selectTextBaseLang('SQL');
|
||||
const testQuery = `SELECT "@tags", geo.dest, count(*) occurred FROM "logstash-*"
|
||||
GROUP BY "@tags", geo.dest
|
||||
HAVING occurred > 20
|
||||
ORDER BY occurred DESC`;
|
||||
await monacoEditor.setCodeEditorValue(testQuery);
|
||||
await testSubjects.click('querySubmitButton');
|
||||
await PageObjects.header.waitUntilLoadingHasFinished();
|
||||
let cell = await dataGrid.getCellElement(0, 3);
|
||||
expect(await cell.getVisibleText()).to.be('2269');
|
||||
await PageObjects.timePicker.setAbsoluteRange(
|
||||
'Sep 19, 2015 @ 06:31:44.000',
|
||||
'Sep 19, 2015 @ 06:31:44.000'
|
||||
);
|
||||
await PageObjects.header.waitUntilLoadingHasFinished();
|
||||
expect(await testSubjects.exists('discoverNoResults')).to.be(true);
|
||||
await PageObjects.timePicker.setDefaultAbsoluteRange();
|
||||
await PageObjects.header.waitUntilLoadingHasFinished();
|
||||
cell = await dataGrid.getCellElement(0, 3);
|
||||
expect(await cell.getVisibleText()).to.be('2269');
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -34,6 +34,9 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
|
|||
await kibanaServer.importExport.load(
|
||||
'x-pack/test/functional/fixtures/kbn_archiver/discover/default'
|
||||
);
|
||||
await kibanaServer.uiSettings.replace({
|
||||
'discover:enableSql': true,
|
||||
});
|
||||
await PageObjects.common.navigateToApp('discover');
|
||||
await PageObjects.timePicker.setDefaultAbsoluteRange();
|
||||
await PageObjects.header.waitUntilLoadingHasFinished();
|
||||
|
@ -128,6 +131,19 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
|
|||
|
||||
expect(searchesCountBeforeRestore).to.be(searchesCountAfterRestore); // no new searches started during restore
|
||||
});
|
||||
|
||||
it('should should clean the search session when navigating to SQL mode, and reinitialize when navigating back', async () => {
|
||||
await PageObjects.common.navigateToApp('discover');
|
||||
await PageObjects.timePicker.setDefaultAbsoluteRange();
|
||||
await PageObjects.header.waitUntilLoadingHasFinished();
|
||||
expect(await searchSessions.exists()).to.be(true);
|
||||
await PageObjects.discover.selectTextBaseLang('SQL');
|
||||
await PageObjects.header.waitUntilLoadingHasFinished();
|
||||
await searchSessions.missingOrFail();
|
||||
await browser.goBack();
|
||||
await PageObjects.header.waitUntilLoadingHasFinished();
|
||||
expect(await searchSessions.exists()).to.be(true);
|
||||
});
|
||||
});
|
||||
|
||||
async function getSearchSessionId(): Promise<string> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue