Skip to content
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] Options to select index patterns #77192

Merged
merged 108 commits into from
Sep 23, 2020
Merged
Changes from 1 commit
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
f630f48
init commit
stephmilovic Aug 6, 2020
a1986df
lots of cleanup
stephmilovic Aug 6, 2020
d51828d
starting on tests... problems
stephmilovic Aug 6, 2020
005e127
Merge branch 'master' into sourcerer
stephmilovic Aug 10, 2020
d4c9421
Ready for review
stephmilovic Aug 10, 2020
78a546a
remove sample data
stephmilovic Aug 10, 2020
5b1b109
remove comment and fix type
stephmilovic Aug 12, 2020
4fb260f
Merge branch 'master' into sourcerer
stephmilovic Aug 12, 2020
a5cac92
pr changes
stephmilovic Aug 12, 2020
f9d18c1
fix type
stephmilovic Aug 12, 2020
204f12c
scratchy
stephmilovic Aug 13, 2020
b1faec2
sourcerer in timeline
stephmilovic Aug 18, 2020
805b5b0
sourcerer in timeline
stephmilovic Aug 18, 2020
eece90e
merge
stephmilovic Aug 20, 2020
daa5c02
wip
stephmilovic Aug 21, 2020
e7f1655
Merge branch 'master' into sourcerer-offshoot
stephmilovic Aug 21, 2020
e9dac14
Merge branch 'master' into sourcerer-in-timeline
stephmilovic Aug 21, 2020
8312030
merge in timeline work
stephmilovic Aug 21, 2020
2cf5297
moving to redux
stephmilovic Aug 21, 2020
a9bac9a
working on types
stephmilovic Aug 21, 2020
9555121
Merge branch 'master' into sourcerer-offshoot
stephmilovic Aug 24, 2020
5ed042a
fixed
stephmilovic Aug 24, 2020
b1d2275
more adjustments, tests fixed
stephmilovic Aug 24, 2020
9a902f8
Merge branch 'master' into sourcerer-offshoot
stephmilovic Aug 25, 2020
7e294cb
FF off
stephmilovic Aug 25, 2020
b3a2d3d
pr ready
stephmilovic Aug 25, 2020
b689637
renaming
stephmilovic Aug 26, 2020
3440a5c
url state working, hoc not working
stephmilovic Aug 26, 2020
88ff613
url state working for timeline and default scope
stephmilovic Aug 26, 2020
d754299
script to build fields for beat doc
XavierM Aug 31, 2020
fa909f2
Merge branch 'sourcerer-offshoot' of github.com:stephmilovic/kibana i…
XavierM Aug 31, 2020
8d0eab5
Merge branch 'master' of github.com:elastic/kibana into sourcerer-off…
XavierM Aug 31, 2020
dcafb63
refactor sourcerer
XavierM Sep 10, 2020
3713ea2
Merge branch 'master' of github.com:elastic/kibana into sourcerer-off…
XavierM Sep 10, 2020
23302a0
refactor host to useSourcerer
XavierM Sep 10, 2020
6040a80
Merge branch 'master' of github.com:elastic/kibana into sourcerer-off…
XavierM Sep 10, 2020
ea0d731
refactor network to useSourcerer
XavierM Sep 10, 2020
4e85306
refactor overview to useSourcerer
XavierM Sep 10, 2020
0ed9ee1
refactor detections to useSourcerer
XavierM Sep 11, 2020
32efc40
wip for timelines to remove all useSource
XavierM Sep 15, 2020
934ba91
Merge branch 'master' of github.com:elastic/kibana into sourcerer-off…
XavierM Sep 15, 2020
04fd00d
wip indexes timeline
XavierM Sep 15, 2020
deb5127
do component tests
stephmilovic Sep 14, 2020
8c219ca
start container tests
stephmilovic Sep 15, 2020
6ca8d08
start container tests
stephmilovic Sep 15, 2020
3518510
update selection widget of index patterns + remove last useWithSource
XavierM Sep 16, 2020
48b6dc4
Merge branch 'sourcerer-offshoot' of github.com:XavierM/kibana into s…
XavierM Sep 16, 2020
9988ba6
Merge branch 'master' of github.com:elastic/kibana into sourcerer-off…
XavierM Sep 16, 2020
03a1c92
add indexeNames in network kpi
XavierM Sep 16, 2020
d17e6e7
fix type errors
stephmilovic Sep 16, 2020
ee13c38
resolve merge
stephmilovic Sep 16, 2020
87e0c20
fix type
stephmilovic Sep 16, 2020
f2aee2c
Merge branch 'master' of github.com:elastic/kibana into sourcerer-off…
XavierM Sep 16, 2020
248d82c
missing merge master
XavierM Sep 16, 2020
7a7969c
get existing index from config file
XavierM Sep 16, 2020
b369a11
fixing broken tests
stephmilovic Sep 16, 2020
d663f42
fixing and merging
stephmilovic Sep 16, 2020
10b8869
add saving button to avoid to many queries to be aborted
XavierM Sep 17, 2020
730833c
reducer timeline tests broke
stephmilovic Sep 17, 2020
9523896
Merge branch 'sourcerer-offshoot' of github.com:XavierM/kibana into s…
stephmilovic Sep 17, 2020
0a319d8
need to rewind
stephmilovic Sep 17, 2020
a21d439
much better
stephmilovic Sep 17, 2020
41feec2
fixed
stephmilovic Sep 17, 2020
d985e8b
timeline saving index names + clean up url state to only manage default
XavierM Sep 17, 2020
f4e351b
Merge branch 'sourcerer-offshoot' of github.com:XavierM/kibana into s…
XavierM Sep 17, 2020
6eba2e6
Merge branch 'master' of github.com:elastic/kibana into sourcerer-off…
XavierM Sep 17, 2020
2d3a388
more test fixing
stephmilovic Sep 17, 2020
a270c62
Merge branch 'sourcerer-offshoot' of github.com:XavierM/kibana into s…
stephmilovic Sep 17, 2020
c7383a7
more test changes
stephmilovic Sep 17, 2020
04b27b9
remove all the useWithSource + deprecated the graphql until we delete…
XavierM Sep 18, 2020
970add9
Merge branch 'sourcerer-offshoot' of github.com:XavierM/kibana into s…
XavierM Sep 18, 2020
c218359
default timeline to all index when creation + filter index patterns t…
XavierM Sep 18, 2020
4f2a3b6
fix types
XavierM Sep 18, 2020
d221c24
test for stateful timeline render
stephmilovic Sep 18, 2020
3e2d0b9
Merge branch 'sourcerer-offshoot' of github.com:XavierM/kibana into s…
stephmilovic Sep 18, 2020
eea000b
we should not have change that
XavierM Sep 18, 2020
1610035
Merge branch 'sourcerer-offshoot' of github.com:XavierM/kibana into s…
XavierM Sep 18, 2020
c55baa1
no chnages + snapshot
XavierM Sep 18, 2020
0e348e2
Merge branch 'master' of github.com:elastic/kibana into sourcerer-off…
XavierM Sep 18, 2020
e5d73df
fix test + bugs from review
XavierM Sep 21, 2020
85bda62
Merge branch 'master' of github.com:elastic/kibana into sourcerer-off…
XavierM Sep 21, 2020
c33db66
fix uncommon processes indexNames
XavierM Sep 21, 2020
2b1122a
review III
XavierM Sep 21, 2020
03a7e18
change design for main page of the sourcerer from design
XavierM Sep 21, 2020
a812f7f
bug fixes when opening old timeline + implementation of new design
XavierM Sep 22, 2020
e7fc42a
fix circular deps
patrykkopycinski Sep 22, 2020
c5e75cb
Merge branch 'master' of github.com:elastic/kibana into sourcerer-off…
patrykkopycinski Sep 22, 2020
573cddc
remove unused attributes for event details
XavierM Sep 22, 2020
31c442f
design cleanup
XavierM Sep 22, 2020
1867c45
Merge branch 'master' into sourcerer-offshoot
stephmilovic Sep 22, 2020
7a66d7c
fix api integration test with the new search strategy
XavierM Sep 23, 2020
460ee5b
add reset + manage accordion state
XavierM Sep 23, 2020
9e6a6fd
fix bugs + types issues
XavierM Sep 23, 2020
a9ba61d
Merge branch 'master' of github.com:elastic/kibana into sourcerer-off…
XavierM Sep 23, 2020
8e84682
cleanup
patrykkopycinski Sep 23, 2020
087d6b5
update docs
patrykkopycinski Sep 23, 2020
5b4e7d1
Merge branch 'master' of github.com:elastic/kibana into sourcerer-off…
patrykkopycinski Sep 23, 2020
886f5fb
review -> remove tooltip when popover is open
XavierM Sep 23, 2020
cb739a2
Merge branch 'sourcerer-offshoot' of github.com:XavierM/kibana into s…
XavierM Sep 23, 2020
9b01f73
Merge branch 'master' of github.com:elastic/kibana into sourcerer-off…
XavierM Sep 23, 2020
e608404
Merge branch 'sourcerer-offshoot' of github.com:XavierM/kibana into s…
stephmilovic Sep 23, 2020
09b3ca7
cypress fixing
stephmilovic Sep 23, 2020
39b6beb
fix for ml_condition_links and url_state cypress tests
stephmilovic Sep 23, 2020
627f825
add cy wait for race condition in pagination tests
stephmilovic Sep 23, 2020
fccef71
merge master
stephmilovic Sep 23, 2020
670e7d4
missing plumbing kpi host
XavierM Sep 23, 2020
71c19e0
Merge branch 'master' of github.com:elastic/kibana into sourcerer-off…
XavierM Sep 23, 2020
f329c94
Merge branch 'sourcerer-offshoot' of github.com:XavierM/kibana into s…
XavierM Sep 23, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
do component tests
  • Loading branch information
stephmilovic committed Sep 15, 2020
commit deb51277e842c79d9c8356564154ab1e402a6f2e
Original file line number Diff line number Diff line change
@@ -4,100 +4,177 @@
* you may not use this file except in compliance with the Elastic License.
*/

// import React from 'react';
// import { mount } from 'enzyme';
// import { SourcererScopeName } from '../../store/sourcerer/model';
// import { mockPatterns, mockSourcererScope } from '../../containers/sourcerer/mocks';
// import { MaybeSourcerer } from './index';
// import * as i18n from './translations';
// import { ADD_INDEX_PATH } from '../../../../common/constants';
import React from 'react';
import { mount } from 'enzyme';
import { SourcererScopeName } from '../../store/sourcerer/model';
import { SourcererComponent } from './index';
import * as i18n from './translations';
import { ADD_INDEX_PATH, DEFAULT_INDEX_PATTERN } from '../../../../common/constants';
import { sourcererActions, sourcererModel } from '../../store/sourcerer';
import {
apolloClientObservable,
createSecuritySolutionStorageMock,
kibanaObservable,
mockGlobalState,
SUB_PLUGINS_REDUCER,
TestProviders,
} from '../../mock';
import { createStore, State } from '../../store';

// const updateSourcererScopeIndices = jest.fn();
// const mockManageSource = {
// activeSourcererScopeId: SourcererScopeName.default,
// kibanaIndexPatterns: mockPatterns,
// getSourcererScopeById: jest.fn().mockReturnValue(mockSourcererScope(SourcererScopeName.default)),
// initializeSourcererScope: jest.fn(),
// isIndexPatternsLoading: false,
// setActiveSourcererScopeId: jest.fn(),
// updateSourcererScopeIndices,
// };
// jest.mock('../../containers/sourcerer', () => {
// const original = jest.requireActual('../../containers/sourcerer');
const mockDispatch = jest.fn();
jest.mock('react-redux', () => {
const original = jest.requireActual('react-redux');

// return {
// ...original,
// useSourcererContext: () => mockManageSource,
// };
// });
return {
...original,
useDispatch: () => mockDispatch,
};
});

// const mockOptions = [
// {
// label: 'apm-*-transaction*',
// key: 'apm-*-transaction*-0',
// value: 'apm-*-transaction*',
// checked: 'on',
// },
// { label: 'auditbeat-*', key: 'auditbeat-*-1', value: 'auditbeat-*', checked: 'on' },
// { label: 'endgame-*', key: 'endgame-*-2', value: 'endgame-*', checked: 'on' },
// { label: 'filebeat-*', key: 'filebeat-*-3', value: 'filebeat-*', checked: 'on' },
// { label: 'logs-*', key: 'logs-*-4', value: 'logs-*', checked: 'on' },
// { label: 'packetbeat-*', key: 'packetbeat-*-5', value: 'packetbeat-*', checked: 'on' },
// { label: 'winlogbeat-*', key: 'winlogbeat-*-6', value: 'winlogbeat-*', checked: 'on' },
// { label: 'journalbeat-*', key: 'journalbeat-*-0', value: 'journalbeat-*' },
// ];
const mockOptions = [
{
label: 'apm-*-transaction*',
key: 'apm-*-transaction*-0',
value: 'apm-*-transaction*',
checked: 'on',
},
{ label: 'auditbeat-*', key: 'auditbeat-*-1', value: 'auditbeat-*', checked: 'on' },
{ label: 'endgame-*', key: 'endgame-*-2', value: 'endgame-*', checked: 'on' },
{ label: 'filebeat-*', key: 'filebeat-*-3', value: 'filebeat-*', checked: 'on' },
{ label: 'logs-*', key: 'logs-*-4', value: 'logs-*', checked: 'on' },
{ label: 'packetbeat-*', key: 'packetbeat-*-5', value: 'packetbeat-*', checked: 'on' },
{ label: 'winlogbeat-*', key: 'winlogbeat-*-6', value: 'winlogbeat-*', checked: 'on' },
];

// describe('Sourcerer component', () => {
// // Using props callback instead of simulating clicks,
// // because EuiSelectable uses a virtualized list, which isn't easily testable via test subjects
// it('Mounts with correct options selected and disabled', () => {
// const wrapper = mount(<MaybeSourcerer />);
// wrapper.find(`[data-test-subj="sourcerer-trigger"]`).first().simulate('click');
// expect(
// wrapper.find(`[data-test-subj="indexPattern-switcher"]`).first().prop('options')
// ).toEqual(mockOptions);
// });
// it('onChange calls updateSourcererScopeIndices', () => {
// const wrapper = mount(<MaybeSourcerer />);
// wrapper.find(`[data-test-subj="sourcerer-trigger"]`).first().simulate('click');
const defaultProps = {
scope: sourcererModel.SourcererScopeName.default,
};
describe('Sourcerer component', () => {
beforeEach(() => {
jest.clearAllMocks();
jest.restoreAllMocks();
});
const state: State = mockGlobalState;
const { storage } = createSecuritySolutionStorageMock();
let store = createStore(
state,
SUB_PLUGINS_REDUCER,
apolloClientObservable,
kibanaObservable,
storage
);

// const switcherOnChange = wrapper
// .find(`[data-test-subj="indexPattern-switcher"]`)
// .first()
// .prop('onChange');
// // @ts-ignore
// switcherOnChange([mockOptions[0], mockOptions[1]]);
// expect(updateSourcererScopeIndices).toHaveBeenCalledWith(SourcererScopeName.default, [
// mockOptions[0].value,
// mockOptions[1].value,
// ]);
// });
// it('Disabled options have icon tooltip', () => {
// const wrapper = mount(<MaybeSourcerer />);
// wrapper.find(`[data-test-subj="sourcerer-trigger"]`).first().simulate('click');
// // @ts-ignore
// const Rendered = wrapper
// .find(`[data-test-subj="indexPattern-switcher"]`)
// .first()
// .prop('renderOption')(
// {
// label: 'blobbeat-*',
// key: 'blobbeat-*-1',
// value: 'blobbeat-*',
// disabled: true,
// checked: undefined,
// },
// ''
// );
// expect(Rendered.props.children[1].props.content).toEqual(i18n.DISABLED_INDEX_PATTERNS);
// });
beforeEach(() => {
store = createStore(
state,
SUB_PLUGINS_REDUCER,
apolloClientObservable,
kibanaObservable,
storage
);
});

// it('Button links to index path', () => {
// const wrapper = mount(<MaybeSourcerer />);
// wrapper.find(`[data-test-subj="sourcerer-trigger"]`).first().simulate('click');
// Using props callback instead of simulating clicks,
// because EuiSelectable uses a virtualized list, which isn't easily testable via test subjects
it('Mounts with all options selected', () => {
const wrapper = mount(
<TestProviders store={store}>
<SourcererComponent {...defaultProps} />
</TestProviders>
);
wrapper.find(`[data-test-subj="sourcerer-trigger"]`).first().simulate('click');
expect(
wrapper.find(`[data-test-subj="indexPattern-switcher"]`).first().prop('options')
).toEqual(mockOptions);
});
it('Mounts with some options selected', () => {
const state2 = {
...mockGlobalState,
sourcerer: {
...mockGlobalState.sourcerer,
sourcererScopes: {
...mockGlobalState.sourcerer.sourcererScopes,
[SourcererScopeName.default]: {
...mockGlobalState.sourcerer.sourcererScopes[SourcererScopeName.default],
loading: false,
selectedPatterns: [DEFAULT_INDEX_PATTERN[0]],
},
},
},
};

// expect(wrapper.find(`[data-test-subj="add-index"]`).first().prop('href')).toEqual(
// ADD_INDEX_PATH
// );
// });
// });
store = createStore(
state2,
SUB_PLUGINS_REDUCER,
apolloClientObservable,
kibanaObservable,
storage
);
const wrapper = mount(
<TestProviders store={store}>
<SourcererComponent {...defaultProps} />
</TestProviders>
);
wrapper.find(`[data-test-subj="sourcerer-trigger"]`).first().simulate('click');
expect(
wrapper.find(`[data-test-subj="indexPattern-switcher"]`).first().prop('options')
).toEqual(mockOptions.map((o, i) => (i === 0 ? o : { ...o, checked: undefined })));
});
it('onChange calls updateSourcererScopeIndices', () => {
const wrapper = mount(
<TestProviders store={store}>
<SourcererComponent {...defaultProps} />
</TestProviders>
);
wrapper.find(`[data-test-subj="sourcerer-trigger"]`).first().simulate('click');

const switcherOnChange = wrapper
.find(`[data-test-subj="indexPattern-switcher"]`)
.first()
.prop('onChange');
// @ts-ignore
switcherOnChange([mockOptions[0], mockOptions[1]]);
expect(mockDispatch).toHaveBeenCalledWith(
sourcererActions.setSelectedIndexPatterns({
id: SourcererScopeName.default,
selectedPatterns: [mockOptions[0].value, mockOptions[1].value],
})
);
});
it('Disabled options have icon tooltip', () => {
const wrapper = mount(
<TestProviders store={store}>
<SourcererComponent {...defaultProps} />
</TestProviders>
);
wrapper.find(`[data-test-subj="sourcerer-trigger"]`).first().simulate('click');
// @ts-ignore
const Rendered = wrapper
.find(`[data-test-subj="indexPattern-switcher"]`)
.first()
.prop('renderOption')(
{
label: 'blobbeat-*',
key: 'blobbeat-*-1',
value: 'blobbeat-*',
disabled: true,
checked: undefined,
},
''
);
expect(Rendered.props.children[1].props.content).toEqual(i18n.DISABLED_INDEX_PATTERNS);
});

it('Button links to index path', () => {
const wrapper = mount(
<TestProviders store={store}>
<SourcererComponent {...defaultProps} />
</TestProviders>
);
wrapper.find(`[data-test-subj="sourcerer-trigger"]`).first().simulate('click');

expect(wrapper.find(`[data-test-subj="add-index"]`).first().prop('href')).toEqual(
ADD_INDEX_PATH
);
});
});
Original file line number Diff line number Diff line change
@@ -15,12 +15,12 @@ export interface SourcererScopeSelector {
}

export const getSourcererScopeSelector = () => {
const getkibanaIndexPatternsSelector = sourcererSelectors.kibanaIndexPatternsSelector();
const getKibanaIndexPatternsSelector = sourcererSelectors.kibanaIndexPatternsSelector();
const getScopesSelector = sourcererSelectors.scopesSelector();
const getAllIndexPatternsSelector = sourcererSelectors.allIndexPatternsSelector();

const mapStateToProps = (state: State, scopeId: SourcererScopeName): SourcererScopeSelector => {
const kibanaIndexPatterns = getkibanaIndexPatternsSelector(state);
const kibanaIndexPatterns = getKibanaIndexPatternsSelector(state);
const scope = getScopesSelector(state)[scopeId];
const allExistingIndexPatterns = getAllIndexPatternsSelector(state);

Loading