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.
[Enterprise Search] Search indices empty states (elastic#131337)
* Bind Search Indices empty state with Mock data * Add Logic tests * Change title on empty state to match with designs * Hide title correctly on empty state * Review changes Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
- Loading branch information
1 parent
57e04d7
commit 0d61e45
Showing
11 changed files
with
369 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ | |
*/ | ||
|
||
export { searchIndices } from './search_indices.mock'; | ||
export { searchEngines } from './search_engines.mock'; |
18 changes: 18 additions & 0 deletions
18
...ise_search/public/applications/enterprise_search_content/__mocks__/search_engines.mock.ts
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,18 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { Engine } from '../../app_search/components/engine/types'; | ||
|
||
// TODO populate them | ||
export const searchEngines = [ | ||
{ name: 'My First Search Engine' }, | ||
{ name: 'Another Search Engine' }, | ||
{ name: 'Dharma Initiative Research' }, | ||
{ name: 'Flight 815 Customer Feedback' }, | ||
{ name: 'The Swan Station Manuals' }, | ||
{ name: 'The Hydra Station Manuals' }, | ||
] as Engine[]; |
96 changes: 96 additions & 0 deletions
96
.../applications/enterprise_search_content/components/search_indices/search_indices.test.tsx
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,96 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import '../../../__mocks__/shallow_useeffect.mock'; | ||
import { setMockValues, setMockActions } from '../../../__mocks__/kea_logic'; | ||
import { searchIndices, searchEngines } from '../../__mocks__'; | ||
|
||
import React from 'react'; | ||
|
||
import { shallow } from 'enzyme'; | ||
|
||
import { EuiBasicTable } from '@elastic/eui'; | ||
|
||
import { AddContentEmptyPrompt } from '../../../shared/add_content_empty_prompt'; | ||
import { ElasticsearchResources } from '../../../shared/elasticsearch_resources'; | ||
import { GettingStartedSteps } from '../../../shared/getting_started_steps'; | ||
|
||
import { SearchIndices } from './search_indices'; | ||
|
||
const mockActions = { | ||
initPage: jest.fn(), | ||
}; | ||
|
||
describe('SearchIndices', () => { | ||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
describe('Empty state', () => { | ||
it('renders when both Search Indices and Search Engines empty', () => { | ||
setMockValues({ | ||
searchIndices: [], | ||
searchEngines: [], | ||
}); | ||
setMockActions(mockActions); | ||
const wrapper = shallow(<SearchIndices />); | ||
|
||
expect(wrapper.find(AddContentEmptyPrompt)).toHaveLength(1); | ||
expect(wrapper.find(EuiBasicTable)).toHaveLength(0); | ||
|
||
expect(wrapper.find(GettingStartedSteps)).toHaveLength(1); | ||
expect(wrapper.find(ElasticsearchResources)).toHaveLength(1); | ||
}); | ||
|
||
it('renders complete empty state when only Search Indices empty', () => { | ||
setMockValues({ | ||
searchIndices: [], | ||
searchEngines, | ||
}); | ||
setMockActions(mockActions); | ||
const wrapper = shallow(<SearchIndices />); | ||
|
||
expect(wrapper.find(AddContentEmptyPrompt)).toHaveLength(1); | ||
expect(wrapper.find(EuiBasicTable)).toHaveLength(0); | ||
|
||
expect(wrapper.find(GettingStartedSteps)).toHaveLength(1); | ||
expect(wrapper.find(ElasticsearchResources)).toHaveLength(1); | ||
}); | ||
|
||
it('renders when only Search Engines empty', () => { | ||
setMockValues({ | ||
searchIndices, | ||
searchEngines: [], | ||
}); | ||
setMockActions(mockActions); | ||
const wrapper = shallow(<SearchIndices />); | ||
|
||
expect(wrapper.find(AddContentEmptyPrompt)).toHaveLength(0); | ||
expect(wrapper.find(EuiBasicTable)).toHaveLength(1); | ||
|
||
expect(wrapper.find(GettingStartedSteps)).toHaveLength(1); | ||
expect(wrapper.find(ElasticsearchResources)).toHaveLength(1); | ||
}); | ||
}); | ||
|
||
it('renders with Data', () => { | ||
setMockValues({ | ||
searchIndices, | ||
searchEngines, | ||
}); | ||
setMockActions(mockActions); | ||
|
||
const wrapper = shallow(<SearchIndices />); | ||
|
||
expect(wrapper.find(AddContentEmptyPrompt)).toHaveLength(0); | ||
expect(wrapper.find(EuiBasicTable)).toHaveLength(1); | ||
|
||
expect(wrapper.find(GettingStartedSteps)).toHaveLength(0); | ||
expect(wrapper.find(ElasticsearchResources)).toHaveLength(0); | ||
|
||
expect(mockActions.initPage).toHaveBeenCalledTimes(1); | ||
}); | ||
}); |
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
55 changes: 55 additions & 0 deletions
55
...ications/enterprise_search_content/components/search_indices/search_indices_logic.test.ts
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,55 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { LogicMounter } from '../../../__mocks__/kea_logic'; | ||
import { searchIndices, searchEngines } from '../../__mocks__'; | ||
|
||
import { SearchIndicesLogic } from './search_indices_logic'; | ||
|
||
describe('SearchIndicesLogic', () => { | ||
const { mount } = new LogicMounter(SearchIndicesLogic); | ||
|
||
const DEFAULT_VALUES = { | ||
searchEngines: [], | ||
searchIndices: [], | ||
}; | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
mount(); | ||
}); | ||
|
||
it('has expected default values', () => { | ||
expect(SearchIndicesLogic.values).toEqual(DEFAULT_VALUES); | ||
}); | ||
|
||
describe('actions', () => { | ||
describe('searchIndicesLoadSuccess', () => { | ||
it('should set searchIndices', () => { | ||
SearchIndicesLogic.actions.searchIndicesLoadSuccess(searchIndices); | ||
expect(SearchIndicesLogic.values).toEqual({ | ||
...DEFAULT_VALUES, | ||
searchIndices, | ||
}); | ||
}); | ||
}); | ||
describe('searchEnginesLoadSuccess', () => { | ||
it('should set searchEngines', () => { | ||
SearchIndicesLogic.actions.searchEnginesLoadSuccess(searchEngines); | ||
expect(SearchIndicesLogic.values).toEqual({ | ||
...DEFAULT_VALUES, | ||
searchEngines, | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
describe.skip('listeners', () => { | ||
describe('loadSearchEngines', () => {}); | ||
describe('loadSearchIndices', () => {}); | ||
}); | ||
}); |
Oops, something went wrong.