Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const SearchBar = memo<SearchBarProps>(({ defaultValue = '', onSearch, pl
const handleOnSearch = useCallback(() => onSearch(query), [query, onSearch]);

return (
<EuiFlexGroup direction="row" alignItems="center" gutterSize="l">
<EuiFlexGroup data-test-subj="searchBar" direction="row" alignItems="center" gutterSize="l">
<EuiFlexItem>
<EuiFieldSearch
defaultValue={defaultValue}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,15 @@ describe('When on the Trusted Apps Page', () => {

it('should display a Add Trusted App button', async () => {
const { getByTestId } = await renderWithListData();
const addButton = await getByTestId('trustedAppsListAddButton');
const addButton = getByTestId('trustedAppsListAddButton');
expect(addButton.textContent).toBe('Add Trusted Application');
});

it('should display the searchbar', async () => {
const renderResult = await renderWithListData();
expect(await renderResult.findByTestId('searchBar')).not.toBeNull();
});

describe('and the Grid view is being displayed', () => {
describe('and the edit trusted app button is clicked', () => {
let renderResult: ReturnType<AppContextTestRender['render']>;
Expand Down Expand Up @@ -555,7 +560,7 @@ describe('When on the Trusted Apps Page', () => {
// to test the UI behaviours while the API call is in flight
coreStart.http.post.mockImplementation(
// @ts-ignore
async (path: string, options: HttpFetchOptions) => {
async (_, options: HttpFetchOptions) => {
return new Promise((resolve, reject) => {
httpPostBody = options.body as string;
resolveHttpPost = resolve;
Expand Down Expand Up @@ -861,6 +866,14 @@ describe('When on the Trusted Apps Page', () => {

expect(await renderResult.findByTestId('trustedAppEmptyState')).not.toBeNull();
});

it('should not display the searchbar', async () => {
const renderResult = render();
await act(async () => {
await waitForAction('trustedAppsExistStateChanged');
});
expect(renderResult.queryByTestId('searchBar')).toBeNull();
});
});

describe('and the search is dispatched', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,34 +96,36 @@ export const TrustedAppsPage = memo(() => {
/>
)}

<SearchBar
defaultValue={location.filter}
onSearch={handleOnSearch}
placeholder={SEARCH_TRUSTED_APP_PLACEHOLDER}
/>
{doEntriesExist ? (
<EuiFlexGroup
direction="column"
gutterSize="none"
data-test-subj="trustedAppsListPageContent"
>
<EuiSpacer size="m" />
<EuiFlexItem grow={false}>
<ControlPanel
totalItemCount={totalItemsCount}
currentViewType={location.view_type}
onViewTypeChange={handleViewTypeChange}
/>

<>
<SearchBar
defaultValue={location.filter}
onSearch={handleOnSearch}
placeholder={SEARCH_TRUSTED_APP_PLACEHOLDER}
/>
<EuiFlexGroup
direction="column"
gutterSize="none"
data-test-subj="trustedAppsListPageContent"
>
<EuiSpacer size="m" />
</EuiFlexItem>
<EuiFlexItem>
<EuiHorizontalRule margin="none" />

{location.view_type === 'grid' && <TrustedAppsGrid />}
{location.view_type === 'list' && <TrustedAppsList />}
</EuiFlexItem>
</EuiFlexGroup>
<EuiFlexItem grow={false}>
<ControlPanel
totalItemCount={totalItemsCount}
currentViewType={location.view_type}
onViewTypeChange={handleViewTypeChange}
/>

<EuiSpacer size="m" />
</EuiFlexItem>
<EuiFlexItem>
<EuiHorizontalRule margin="none" />

{location.view_type === 'grid' && <TrustedAppsGrid />}
{location.view_type === 'list' && <TrustedAppsList />}
</EuiFlexItem>
</EuiFlexGroup>
</>
) : (
<EmptyState onAdd={handleAddButtonClick} isAddDisabled={showCreateFlyout} />
)}
Expand Down