-
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.
functional tests and ui updates to endpoint host details
- Loading branch information
Showing
36 changed files
with
623 additions
and
545 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
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
40 changes: 40 additions & 0 deletions
40
x-pack/plugins/endpoint/public/applications/endpoint/store/hosts/action.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,40 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { HostListPagination, ServerApiError } from '../../types'; | ||
import { HostResultList, HostMetadata } from '../../../../../common/types'; | ||
|
||
interface ServerReturnedHostList { | ||
type: 'serverReturnedHostList'; | ||
payload: HostResultList; | ||
} | ||
|
||
interface ServerReturnedHostDetails { | ||
type: 'serverReturnedHostDetails'; | ||
payload: HostMetadata; | ||
} | ||
|
||
interface ServerFailedToReturnHostDetails { | ||
type: 'serverFailedToReturnHostDetails'; | ||
payload: ServerApiError; | ||
} | ||
|
||
interface UserPaginatedHostList { | ||
type: 'userPaginatedHostList'; | ||
payload: HostListPagination; | ||
} | ||
|
||
// Why is FakeActionWithNoPayload here, see: https://github.com/elastic/endpoint-app-team/issues/273 | ||
interface FakeActionWithNoPayload { | ||
type: 'fakeActionWithNoPayLoad'; | ||
} | ||
|
||
export type HostAction = | ||
| ServerReturnedHostList | ||
| ServerReturnedHostDetails | ||
| ServerFailedToReturnHostDetails | ||
| UserPaginatedHostList | ||
| FakeActionWithNoPayload; |
73 changes: 73 additions & 0 deletions
73
x-pack/plugins/endpoint/public/applications/endpoint/store/hosts/index.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,73 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { createStore, Dispatch, Store } from 'redux'; | ||
import { HostAction, hostListReducer } from './index'; | ||
import { HostListState } from '../../types'; | ||
import { listData } from './selectors'; | ||
import { mockHostResultList } from './mock_host_result_list'; | ||
|
||
describe('HostList store concerns', () => { | ||
let store: Store<HostListState>; | ||
let dispatch: Dispatch<HostAction>; | ||
const createTestStore = () => { | ||
store = createStore(hostListReducer); | ||
dispatch = store.dispatch; | ||
}; | ||
|
||
const loadDataToStore = () => { | ||
dispatch({ | ||
type: 'serverReturnedHostList', | ||
payload: mockHostResultList({ request_page_size: 1, request_page_index: 1, total: 10 }), | ||
}); | ||
}; | ||
|
||
describe('# Reducers', () => { | ||
beforeEach(() => { | ||
createTestStore(); | ||
}); | ||
|
||
test('it creates default state', () => { | ||
expect(store.getState()).toEqual({ | ||
hosts: [], | ||
pageSize: 10, | ||
pageIndex: 0, | ||
total: 0, | ||
loading: false, | ||
}); | ||
}); | ||
|
||
test('it handles `serverReturnedHostList', () => { | ||
const payload = mockHostResultList({ | ||
request_page_size: 1, | ||
request_page_index: 1, | ||
total: 10, | ||
}); | ||
dispatch({ | ||
type: 'serverReturnedHostList', | ||
payload, | ||
}); | ||
|
||
const currentState = store.getState(); | ||
expect(currentState.hosts).toEqual(payload.hosts); | ||
expect(currentState.pageSize).toEqual(payload.request_page_size); | ||
expect(currentState.pageIndex).toEqual(payload.request_page_index); | ||
expect(currentState.total).toEqual(payload.total); | ||
}); | ||
}); | ||
|
||
describe('# Selectors', () => { | ||
beforeEach(() => { | ||
createTestStore(); | ||
loadDataToStore(); | ||
}); | ||
|
||
test('it selects `hostListData`', () => { | ||
const currentState = store.getState(); | ||
expect(listData(currentState)).toEqual(currentState.hosts); | ||
}); | ||
}); | ||
}); |
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
Oops, something went wrong.