mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 18:51:07 -04:00
[App Search] Add EuiThemeProvider
to fix crashing bug (#124993)
This commit is contained in:
parent
691315a274
commit
449f8e6738
2 changed files with 28 additions and 22 deletions
|
@ -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);
|
||||
|
|
|
@ -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>
|
||||
);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue