Skip to content

Commit

Permalink
[Discover] Render the sidebar even if documents fetching failed (#147179
Browse files Browse the repository at this point in the history
)

This is a follow up PR for #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">
  • Loading branch information
jughosta authored Dec 8, 2022
1 parent 94c46eb commit 1f0ae32
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
40 changes: 40 additions & 0 deletions test/functional/apps/discover/group1/_sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 1f0ae32

Please sign in to comment.