fleet/frontend/test
Gabe Hernandez a6c8987200
Feature - add search and sort to host table (#341)
* start adding global search filter

* update polyfill setup to use async await for react-table

* update browerslist to sensible defaults

* get global search functionality woring

* more progress on the data table

* get label network calls working in hostdatatable

* get pagination functionality into the HostDataTable

* get search query making network call

* get ordering making query

* make actual  sort order network calls

* disable cpu column sorting

* seperate get table data from get labels

* fix issues with input resetting and got search query working

* get sort working

* ignore vs code editor settings

* improve loading spinner to move inside the table

* improve styling

* add sorting arrows

* remove unused sorting arrow component

* add host query params to labels endpoint

* fix style for query textarea on label hosts

* got new pagination working

* set server data as source of truth for table global filter

* cleanup logs

* clean up pagination styles

* fix up paginationa and no host styles

* add result count to table

* remove logs

* tweak header styles

* fix to sort order

* simplify default sort direction

* keep sort order of server api responses and use in host table

* clean up logs

* Add styles for header cell and pagination

* fix tests for ManageHostPage

* fix tests for HostContainer

* fix lower level action reducer and thunk tests

* fix tests for hosts client

* fix up some host count styling

* added back no hosts start message

* fix linting errors

* remove unused old pagination code

* add back scrollToTop utility on pagination

* remove unused code in managehostpage test

Co-authored-by: Noah Talerman <noahtal@umich.edu>
2021-02-25 12:05:08 +00:00
..
mocks Feature - add search and sort to host table (#341) 2021-02-25 12:05:08 +00:00
envSetup.js Feature - add search and sort to host table (#341) 2021-02-25 12:05:08 +00:00
helpers.jsx Update table schema for osquery 4.4.0 (#2253) 2020-07-07 09:47:50 -07:00
index.js Select targets tests (#1307) 2017-03-03 10:05:03 -05:00
loaderMock.js Upgrade React to version 16 (#1983) 2019-01-14 13:45:28 -08:00
README.md Add Front-end Documentation (#1373) 2017-03-10 17:13:29 -05:00
stubs.js Reveal live query error information in Fleet UI (#224) 2021-01-25 17:08:28 -08:00
target_mock.js Deprecate /api/v1/kolide routes (#297) 2021-02-10 12:13:11 -08:00

Kolide Tests

The test directory contains helper functions, request mocks, and entity stubs for use in test files throughout the application. The test files for components and app functions are located in the same directory as the files they test.

The default export from the test directory includes Helpers, Mocks, and Stubs.

Helpers

import Test from 'test';

const helpers = Test.Helpers;

The helpers file includes functions that make certain test actions easy, such as mounting a connected component, building a mock redux store, and filling in a form input.

Below are a couple particularly useful test helpers.

fillInFormInput

This function is useful when the component renders a form that needs to be filled out. The function takes to parameters, the form input element and the value to be filled in.

Example

reduxMockStore

This function is useful for creating a fake redux store. This store will allow actions to be dispatched, keep a collection of dispatched actions, and hold state.

Example using mockStore.dispatch

Example using mockStore.dispatch

Example mounting a connected component and checking dispatched actions

connectedComponent

The connectedComponent function is useful for mounting connected components in tests (usually Page components). This helper wraps the component in a Provider component and sets a mock store as the redux store for the connected component. It takes 2 parameters, the component class and an options hash. The options has 2 optional keys, mockStore and props. Keep in mind that when mounting a connected component mapStateToProps will run and the component will receive the props assigned in the mapStateToProps function.

Example

Example

Mocks

import Test from 'test';

const mocks = Test.Mocks;

Documentation on request mocks can be found in the Kolide Request Mock Documentation

Stubs

import Test from 'test';

const stubs = Test.Stubs;

The Stubs file contains objects that represent entities used in the Kolide application. These re-usable objects help keep the code DRY.