forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
React/EUI-ify indexed fields table (elastic#16695) (elastic#17068)
* React/EUI-ifying indexed fields table
- Loading branch information
Showing
24 changed files
with
940 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
...ex_pattern/indexed_fields_table/__tests__/__snapshots__/indexed_fields_table.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`IndexedFieldsTable should filter based on the query bar 1`] = ` | ||
<div> | ||
<Table | ||
editField={[Function]} | ||
indexPattern={ | ||
Object { | ||
"getNonScriptedFields": [Function], | ||
} | ||
} | ||
items={ | ||
Array [ | ||
Object { | ||
"displayName": "Elastic", | ||
"excluded": false, | ||
"format": undefined, | ||
"indexPattern": undefined, | ||
"name": "Elastic", | ||
"routes": undefined, | ||
"searchable": true, | ||
}, | ||
] | ||
} | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`IndexedFieldsTable should filter based on the type filter 1`] = ` | ||
<div> | ||
<Table | ||
editField={[Function]} | ||
indexPattern={ | ||
Object { | ||
"getNonScriptedFields": [Function], | ||
} | ||
} | ||
items={ | ||
Array [ | ||
Object { | ||
"displayName": "timestamp", | ||
"excluded": false, | ||
"format": undefined, | ||
"indexPattern": undefined, | ||
"name": "timestamp", | ||
"routes": undefined, | ||
"type": "date", | ||
}, | ||
] | ||
} | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`IndexedFieldsTable should render normally 1`] = ` | ||
<div> | ||
<Table | ||
editField={[Function]} | ||
indexPattern={ | ||
Object { | ||
"getNonScriptedFields": [Function], | ||
} | ||
} | ||
items={ | ||
Array [ | ||
Object { | ||
"displayName": "Elastic", | ||
"excluded": false, | ||
"format": undefined, | ||
"indexPattern": undefined, | ||
"name": "Elastic", | ||
"routes": undefined, | ||
"searchable": true, | ||
}, | ||
Object { | ||
"displayName": "timestamp", | ||
"excluded": false, | ||
"format": undefined, | ||
"indexPattern": undefined, | ||
"name": "timestamp", | ||
"routes": undefined, | ||
"type": "date", | ||
}, | ||
Object { | ||
"displayName": "conflictingField", | ||
"excluded": false, | ||
"format": undefined, | ||
"indexPattern": undefined, | ||
"name": "conflictingField", | ||
"routes": undefined, | ||
"type": "conflict", | ||
}, | ||
] | ||
} | ||
/> | ||
</div> | ||
`; |
85 changes: 85 additions & 0 deletions
85
...ns/indices/edit_index_pattern/indexed_fields_table/__tests__/indexed_fields_table.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
|
||
import { IndexedFieldsTable } from '../indexed_fields_table'; | ||
|
||
jest.mock('@elastic/eui', () => ({ | ||
EuiFlexGroup: 'eui-flex-group', | ||
EuiFlexItem: 'eui-flex-item', | ||
EuiIcon: 'eui-icon', | ||
EuiInMemoryTable: 'eui-in-memory-table', | ||
TooltipTrigger: 'tooltip-trigger' | ||
})); | ||
|
||
jest.mock('../components/table', () => ({ | ||
// Note: this seems to fix React complaining about non lowercase attributes | ||
Table: () => { | ||
return 'table'; | ||
} | ||
})); | ||
|
||
const helpers = { | ||
redirectToRoute: () => {}, | ||
}; | ||
|
||
const fields = [ | ||
{ name: 'Elastic', displayName: 'Elastic', searchable: true }, | ||
{ name: 'timestamp', displayName: 'timestamp', type: 'date' }, | ||
{ name: 'conflictingField', displayName: 'conflictingField', type: 'conflict' }, | ||
]; | ||
|
||
const indexPattern = { | ||
getNonScriptedFields: () => fields, | ||
}; | ||
|
||
describe('IndexedFieldsTable', () => { | ||
it('should render normally', async () => { | ||
const component = shallow( | ||
<IndexedFieldsTable | ||
fields={fields} | ||
indexPattern={indexPattern} | ||
helpers={helpers} | ||
fieldWildcardMatcher={() => {}} | ||
/> | ||
); | ||
|
||
await new Promise(resolve => process.nextTick(resolve)); | ||
component.update(); | ||
|
||
expect(component).toMatchSnapshot(); | ||
}); | ||
|
||
it('should filter based on the query bar', async () => { | ||
const component = shallow( | ||
<IndexedFieldsTable | ||
fields={fields} | ||
indexPattern={indexPattern} | ||
helpers={helpers} | ||
fieldWildcardMatcher={() => {}} | ||
/> | ||
); | ||
|
||
await new Promise(resolve => process.nextTick(resolve)); | ||
component.setProps({ fieldFilter: 'Elast' }); | ||
component.update(); | ||
|
||
expect(component).toMatchSnapshot(); | ||
}); | ||
|
||
it('should filter based on the type filter', async () => { | ||
const component = shallow( | ||
<IndexedFieldsTable | ||
fields={fields} | ||
indexPattern={indexPattern} | ||
helpers={helpers} | ||
fieldWildcardMatcher={() => {}} | ||
/> | ||
); | ||
|
||
await new Promise(resolve => process.nextTick(resolve)); | ||
component.setProps({ indexedFieldTypeFilter: 'date' }); | ||
component.update(); | ||
|
||
expect(component).toMatchSnapshot(); | ||
}); | ||
}); |
Oops, something went wrong.