[Discover] Render the sidebar even if documents fetching failed (#147179)

This is a follow up PR for https://github.com/elastic/kibana/pull/144412
to fix how "Error" case is handled.

Before: the sidebar was stuck in loading state:
<img width="600" alt="Screenshot 2022-12-07 at 13 16 21"
src="https://user-images.githubusercontent.com/1415710/206183995-9079ee4f-6c7c-4a59-ace3-f2c22807a17b.png">

After: the sidebar is rendered:
<img width="600" alt="Screenshot 2022-12-07 at 13 17 06"
src="https://user-images.githubusercontent.com/1415710/206184115-abd08241-e0b6-4fff-b257-fe12be2a0006.png">
This commit is contained in:
Julia Rechkunova 2022-12-08 08:39:38 +01:00 committed by GitHub
parent 94c46eba45
commit 1f0ae32671
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 50 additions and 0 deletions

View file

@ -168,6 +168,16 @@ export function DiscoverSidebarResponsive(props: DiscoverSidebarResponsiveProps)
},
});
break;
case FetchStatus.ERROR:
dispatchSidebarStateAction({
type: DiscoverSidebarReducerActionType.DOCUMENTS_LOADED,
payload: {
dataView: selectedDataViewRef.current,
fieldCounts: {},
isPlainRecord: isPlainRecordType,
},
});
break;
default:
break;
}

View file

@ -510,6 +510,46 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
expect(allFields.includes('_bytes-runtimefield')).to.be(false);
});
it('should render even when retrieving documents failed with an error', async () => {
await PageObjects.header.waitUntilLoadingHasFinished();
await testSubjects.missingOrFail('discoverNoResultsError');
expect(await PageObjects.discover.getSidebarAriaDescription()).to.be(
'53 available fields. 0 empty fields. 3 meta fields.'
);
await PageObjects.discover.addRuntimeField('_invalid-runtimefield', `emit();`);
await PageObjects.header.waitUntilLoadingHasFinished();
// error in fetching documents because of the invalid runtime field
await testSubjects.existOrFail('discoverNoResultsError');
await PageObjects.discover.waitUntilSidebarHasLoaded();
// check that the sidebar is rendered
expect(await PageObjects.discover.getSidebarAriaDescription()).to.be(
'54 available fields. 0 empty fields. 3 meta fields.'
);
let allFields = await PageObjects.discover.getAllFieldNames();
expect(allFields.includes('_invalid-runtimefield')).to.be(true);
await browser.refresh();
await PageObjects.header.waitUntilLoadingHasFinished();
await testSubjects.existOrFail('discoverNoResultsError'); // still has error
// check that the sidebar is rendered event after a refresh
allFields = await PageObjects.discover.getAllFieldNames();
expect(allFields.includes('_invalid-runtimefield')).to.be(true);
await PageObjects.discover.removeField('_invalid-runtimefield');
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.discover.waitUntilSidebarHasLoaded();
await testSubjects.missingOrFail('discoverNoResultsError');
});
it('should work correctly when time range is updated', async function () {
await esArchiver.loadIfNeeded(
'test/functional/fixtures/es_archiver/index_pattern_without_timefield'