-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Enterprise Search] fix: show/hide ent-search cards based on access (#…
…168890) ## Summary When refactoring the Enterprise Search overview page we inadvertently removed the access and admin checks for app search and workplace search product cards. This fix re-adds those checks.
- Loading branch information
1 parent
d0a3aa7
commit f6a1858
Showing
7 changed files
with
203 additions
and
31 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
...prise_search_overview/components/product_selector/enterprise_search_product_card.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,59 @@ | ||
/* | ||
* 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 { setMockValues } from '../../../__mocks__/kea_logic'; | ||
|
||
import React from 'react'; | ||
|
||
import { mount } from 'enzyme'; | ||
|
||
import { AppSearchProductCard } from './app_search_product_card'; | ||
import { EnterpriseSearchProductCard } from './enterprise_search_product_card'; | ||
import { WorkplaceSearchProductCard } from './workplace_search_product_card'; | ||
|
||
describe('EnterpriseSearchProductCard', () => { | ||
beforeEach(() => { | ||
setMockValues({ config: { canDeployEntSearch: true, host: 'localhost' } }); | ||
}); | ||
|
||
it('renders both services with access', () => { | ||
const wrapper = mount( | ||
<EnterpriseSearchProductCard | ||
hasAppSearchAccess | ||
hasWorkplaceSearchAccess | ||
isWorkplaceSearchAdmin | ||
/> | ||
); | ||
|
||
expect(wrapper.find(AppSearchProductCard)).toHaveLength(1); | ||
expect(wrapper.find(WorkplaceSearchProductCard)).toHaveLength(1); | ||
}); | ||
it('can render just app search', () => { | ||
const wrapper = mount( | ||
<EnterpriseSearchProductCard | ||
hasAppSearchAccess | ||
hasWorkplaceSearchAccess={false} | ||
isWorkplaceSearchAdmin={false} | ||
/> | ||
); | ||
|
||
expect(wrapper.find(AppSearchProductCard)).toHaveLength(1); | ||
expect(wrapper.find(WorkplaceSearchProductCard)).toHaveLength(0); | ||
}); | ||
it('can render just workplace search', () => { | ||
const wrapper = mount( | ||
<EnterpriseSearchProductCard | ||
hasAppSearchAccess={false} | ||
hasWorkplaceSearchAccess | ||
isWorkplaceSearchAdmin | ||
/> | ||
); | ||
|
||
expect(wrapper.find(AppSearchProductCard)).toHaveLength(0); | ||
expect(wrapper.find(WorkplaceSearchProductCard)).toHaveLength(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
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
34 changes: 34 additions & 0 deletions
34
...rprise_search_overview/components/product_selector/workplace_search_product_card.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,34 @@ | ||
/* | ||
* 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 React from 'react'; | ||
|
||
import { shallow } from 'enzyme'; | ||
|
||
import { WORKPLACE_SEARCH_PLUGIN } from '../../../../../common/constants'; | ||
import { ProductCard } from '../product_card'; | ||
|
||
import { WorkplaceSearchProductCard } from './workplace_search_product_card'; | ||
|
||
describe('WorkplaceSearchProductCard', () => { | ||
it('renders with url when admin', () => { | ||
const wrapper = shallow( | ||
<WorkplaceSearchProductCard hasBorder hasShadow isWorkplaceSearchAdmin /> | ||
); | ||
|
||
expect(wrapper.find(ProductCard)).toHaveLength(1); | ||
expect(wrapper.find(ProductCard).prop('url')).toEqual(WORKPLACE_SEARCH_PLUGIN.URL); | ||
}); | ||
it('renders with non-admin url when not admin', () => { | ||
const wrapper = shallow( | ||
<WorkplaceSearchProductCard hasBorder hasShadow isWorkplaceSearchAdmin={false} /> | ||
); | ||
|
||
expect(wrapper.find(ProductCard)).toHaveLength(1); | ||
expect(wrapper.find(ProductCard).prop('url')).toEqual(WORKPLACE_SEARCH_PLUGIN.NON_ADMIN_URL); | ||
}); | ||
}); |
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