Skip to content

Commit

Permalink
Fix remaining bug in datagrid
Browse files Browse the repository at this point in the history
  • Loading branch information
wylieconlon committed Feb 19, 2021
1 parent b0e228c commit 10cef85
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,35 @@ describe('Discover grid cell rendering', function () {
`);
});

it('does not collect subfields when the the column is unmapped but part of fields response', () => {
(indexPatternMock.getFieldByName as jest.Mock).mockReturnValueOnce(undefined);
const DiscoverGridCellValue = getRenderCellValueFn(
indexPatternMock,
rowsFieldsWithTopLevelObject,
rowsFieldsWithTopLevelObject.map((row) => indexPatternMock.flattenHit(row)),
true
);
const component = shallow(
<DiscoverGridCellValue
rowIndex={0}
columnId="object.value"
isDetails={false}
isExpanded={false}
isExpandable={true}
setCellProps={jest.fn()}
/>
);
expect(component).toMatchInlineSnapshot(`
<span
dangerouslySetInnerHTML={
Object {
"__html": 100,
}
}
/>
`);
});

it('renders correctly when invalid row is given', () => {
const DiscoverGridCellValue = getRenderCellValueFn(
indexPatternMock,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,13 @@ export const getRenderCellValueFn = (
return <span>-</span>;
}

if (useNewFieldsApi && !field && row && row.fields) {
if (
useNewFieldsApi &&
!field &&
row &&
row.fields &&
!(row.fields as Record<string, unknown[]>)[columnId]
) {
const innerColumns = Object.fromEntries(
Object.entries(row.fields as Record<string, unknown[]>).filter(([key]) => {
return key.indexOf(`${columnId}.`) === 0;
Expand Down

0 comments on commit 10cef85

Please sign in to comment.