-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Security Solution] Clearing up all jest errors and warnings #91740
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,16 @@ describe('QueryBar ', () => { | |
await waitFor(() => getByTestId('queryInput')); // check for presence of query input | ||
return mount(Component); | ||
}; | ||
let abortSpy: jest.SpyInstance; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is in a few spots. Clears up an error thrown by
|
||
beforeAll(() => { | ||
const mockAbort = new AbortController(); | ||
mockAbort.abort(); | ||
abortSpy = jest.spyOn(window, 'AbortController').mockImplementation(() => mockAbort); | ||
}); | ||
|
||
afterAll(() => { | ||
abortSpy.mockRestore(); | ||
}); | ||
beforeEach(() => { | ||
mockOnChangeQuery.mockClear(); | ||
mockOnSubmitQuery.mockClear(); | ||
|
@@ -264,7 +273,6 @@ describe('QueryBar ', () => { | |
const onChangedQueryRef = searchBarProps.onQueryChange; | ||
const onSubmitQueryRef = searchBarProps.onQuerySubmit; | ||
const onSavedQueryRef = searchBarProps.onSavedQueryUpdated; | ||
|
||
wrapper.setProps({ onSavedQuery: jest.fn() }); | ||
wrapper.update(); | ||
|
||
|
@@ -294,22 +302,21 @@ describe('QueryBar ', () => { | |
onSavedQuery={mockOnSavedQuery} | ||
/> | ||
); | ||
await waitFor(() => { | ||
const isSavedQueryPopoverOpen = () => | ||
wrapper.find('EuiPopover[id="savedQueryPopover"]').prop('isOpen'); | ||
const isSavedQueryPopoverOpen = () => | ||
wrapper.find('EuiPopover[id="savedQueryPopover"]').prop('isOpen'); | ||
|
||
expect(isSavedQueryPopoverOpen()).toBeFalsy(); | ||
expect(isSavedQueryPopoverOpen()).toBeFalsy(); | ||
|
||
wrapper | ||
.find('button[data-test-subj="saved-query-management-popover-button"]') | ||
.simulate('click'); | ||
wrapper | ||
.find('button[data-test-subj="saved-query-management-popover-button"]') | ||
.simulate('click'); | ||
|
||
await waitFor(() => { | ||
expect(isSavedQueryPopoverOpen()).toBeTruthy(); | ||
}); | ||
wrapper.find('button[data-test-subj="saved-query-management-save-button"]').simulate('click'); | ||
|
||
wrapper | ||
.find('button[data-test-subj="saved-query-management-save-button"]') | ||
.simulate('click'); | ||
|
||
await waitFor(() => { | ||
expect(isSavedQueryPopoverOpen()).toBeFalsy(); | ||
}); | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,15 @@ import { useAllExceptionLists } from './use_all_exception_lists'; | |
jest.mock('../../../../../../common/lib/kibana'); | ||
jest.mock('./use_all_exception_lists'); | ||
jest.mock('../../../../../../shared_imports'); | ||
jest.mock('@kbn/i18n/react', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is also present a few times. Here are the errors we clear up:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey, thanks for doing all of this! Just a quick question so I understand a bit better...isn't There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what do you mean implemented in the module? Just mocking this component since we are not responsible for it, we are not testing anything to do with it, and it is causing errors in jest tests. |
||
const originalModule = jest.requireActual('@kbn/i18n/react'); | ||
const FormattedRelative = jest.fn().mockImplementation(() => '20 hours ago'); | ||
|
||
return { | ||
...originalModule, | ||
FormattedRelative, | ||
}; | ||
}); | ||
describe('ExceptionListsTable', () => { | ||
const exceptionList1 = getExceptionListSchemaMock(); | ||
const exceptionList2 = { ...getExceptionListSchemaMock(), list_id: 'not_endpoint_list', id: '2' }; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,11 +9,7 @@ import { cloneDeep, getOr, omit } from 'lodash/fp'; | |
import { Dispatch } from 'redux'; | ||
import ApolloClient from 'apollo-client'; | ||
|
||
import { | ||
mockTimelineResults, | ||
mockTimelineResult, | ||
mockTimelineModel, | ||
} from '../../../common/mock/timeline_results'; | ||
import { mockTimelineResults, mockTimelineResult, mockTimelineModel } from '../../../common/mock'; | ||
import { timelineDefaults } from '../../store/timeline/defaults'; | ||
import { setTimelineRangeDatePicker as dispatchSetTimelineRangeDatePicker } from '../../../common/store/inputs/actions'; | ||
import { | ||
|
@@ -37,7 +33,7 @@ import { | |
formatTimelineResultToModel, | ||
} from './helpers'; | ||
import { OpenTimelineResult, DispatchUpdateTimeline } from './types'; | ||
import { KueryFilterQueryKind } from '../../../common/store/model'; | ||
import { KueryFilterQueryKind } from '../../../common/store'; | ||
import { Note } from '../../../common/lib/note'; | ||
import moment from 'moment'; | ||
import sinon from 'sinon'; | ||
|
@@ -1275,7 +1271,7 @@ describe('helpers', () => { | |
|
||
describe('update a timeline', () => { | ||
const updateIsLoading = jest.fn(); | ||
const updateTimeline = jest.fn(); | ||
const updateTimeline = jest.fn().mockImplementation(() => jest.fn()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. clears the following type error:
|
||
const selectedTimeline = { ...mockSelectedTimeline }; | ||
const apolloClient = { | ||
query: (jest.fn().mockResolvedValue(selectedTimeline) as unknown) as ApolloClient<{}>, | ||
|
@@ -1316,6 +1312,7 @@ describe('helpers', () => { | |
args.duplicate, | ||
args.timelineType | ||
); | ||
|
||
expect(updateTimeline).toBeCalledWith({ | ||
timeline: { | ||
...timeline, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,14 @@ import { createStore, State } from '../../../common/store'; | |
import { DetailsPanel } from './index'; | ||
import { TimelineExpandedDetail, TimelineTabs } from '../../../../common/types/timeline'; | ||
import { FlowTarget } from '../../../../common/search_strategy/security_solution/network'; | ||
jest.mock('react-apollo', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. clears up the following warning:
|
||
const original = jest.requireActual('react-apollo'); | ||
return { | ||
...original, | ||
// eslint-disable-next-line react/display-name | ||
Query: () => <></>, | ||
}; | ||
}); | ||
|
||
describe('Details Panel Component', () => { | ||
const state: State = { ...mockGlobalState }; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clears up 195 instances of the following warning:
Deprecation, no ones fault but @chandlerprall ;)