[App Search] Add EuiThemeProvider to fix crashing bug (#124993)

This commit is contained in:
Scotty Bollinger 2022-02-09 08:54:30 -06:00 committed by GitHub
parent 691315a274
commit 449f8e6738
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 22 deletions

View file

@ -9,18 +9,17 @@ import React from 'react';
import { shallow } from 'enzyme';
import { LogStream } from '../../../../../infra/public';
import { EntSearchLogStream } from './';
describe('EntSearchLogStream', () => {
const mockDateNow = jest.spyOn(global.Date, 'now').mockReturnValue(160000000);
describe('renders with default props', () => {
const wrapper = shallow(<EntSearchLogStream />);
/** As a result of the theme provider being added, we have to extract the child component to correctly assert */
const wrapper = shallow(shallow(<EntSearchLogStream />).prop('children'));
it('renders a LogStream component', () => {
expect(wrapper.type()).toEqual(LogStream);
it('renders a LogStream (wrapped in React.Suspense) component', () => {
expect(wrapper.type()).toEqual(React.Suspense);
});
it('renders with the enterprise search log source ID', () => {
@ -36,7 +35,9 @@ describe('EntSearchLogStream', () => {
describe('renders custom props', () => {
it('overrides the default props', () => {
const wrapper = shallow(
<EntSearchLogStream sourceId="test" startTimestamp={1} endTimestamp={2} />
shallow(<EntSearchLogStream sourceId="test" startTimestamp={1} endTimestamp={2} />).prop(
'children'
)
);
expect(wrapper.prop('sourceId')).toEqual('test');
@ -45,7 +46,7 @@ describe('EntSearchLogStream', () => {
});
it('allows passing a custom hoursAgo that modifies the default start timestamp', () => {
const wrapper = shallow(<EntSearchLogStream hoursAgo={1} />);
const wrapper = shallow(shallow(<EntSearchLogStream hoursAgo={1} />).prop('children'));
expect(wrapper.prop('startTimestamp')).toEqual(156400000);
expect(wrapper.prop('endTimestamp')).toEqual(160000000);
@ -53,15 +54,17 @@ describe('EntSearchLogStream', () => {
it('allows passing any prop that the LogStream component takes', () => {
const wrapper = shallow(
<EntSearchLogStream
height={500}
highlight="some-log-id"
columns={[
{ type: 'timestamp', header: 'Timestamp' },
{ type: 'field', field: 'log.level', header: 'Log level', width: 300 },
]}
filters={[]}
/>
shallow(
<EntSearchLogStream
height={500}
highlight="some-log-id"
columns={[
{ type: 'timestamp', header: 'Timestamp' },
{ type: 'field', field: 'log.level', header: 'Log level', width: 300 },
]}
filters={[]}
/>
).prop('children')
);
expect(wrapper.prop('height')).toEqual(500);

View file

@ -7,6 +7,7 @@
import React from 'react';
import { EuiThemeProvider } from '../../../../../../../src/plugins/kibana_react/common';
import { LogStream, LogStreamProps } from '../../../../../infra/public';
import { LOGS_SOURCE_ID } from '../../../../common/constants';
@ -37,11 +38,13 @@ export const EntSearchLogStream: React.FC<Props> = ({
if (!startTimestamp) startTimestamp = endTimestamp - hoursAgo * 60 * 60 * 1000;
return (
<LogStream
sourceId={LOGS_SOURCE_ID}
startTimestamp={startTimestamp}
endTimestamp={endTimestamp}
{...props}
/>
<EuiThemeProvider>
<LogStream
sourceId={LOGS_SOURCE_ID}
startTimestamp={startTimestamp}
endTimestamp={endTimestamp}
{...props}
/>
</EuiThemeProvider>
);
};