diff --git a/frontend/components/queries/QueryResultsTable/QueryResultsTable.jsx b/frontend/components/queries/QueryResultsTable/QueryResultsTable.jsx
index b1898d74ea..5834955a54 100644
--- a/frontend/components/queries/QueryResultsTable/QueryResultsTable.jsx
+++ b/frontend/components/queries/QueryResultsTable/QueryResultsTable.jsx
@@ -64,8 +64,9 @@ class QueryResultsTable extends Component {
}
renderTableHeaderRowData = (column, index) => {
- const { onFilterAttribute, onSetActiveColumn } = this;
+ const filterable = column === 'hostname' ? 'host_hostname' : column;
const { activeColumn, resultsFilter } = this.state;
+ const { onFilterAttribute, onSetActiveColumn } = this;
const filterIconClassName = classnames(`${baseClass}__filter-icon`, {
[`${baseClass}__filter-icon--is-active`]: activeColumn === column,
});
@@ -75,9 +76,9 @@ class QueryResultsTable extends Component {
{column}
);
diff --git a/frontend/components/queries/QueryResultsTable/QueryResultsTable.tests.jsx b/frontend/components/queries/QueryResultsTable/QueryResultsTable.tests.jsx
index beb371d18d..0102d23b53 100644
--- a/frontend/components/queries/QueryResultsTable/QueryResultsTable.tests.jsx
+++ b/frontend/components/queries/QueryResultsTable/QueryResultsTable.tests.jsx
@@ -3,6 +3,7 @@ import expect, { createSpy, restoreSpies } from 'expect';
import { keys } from 'lodash';
import { mount } from 'enzyme';
+import { fillInFormInput } from 'test/helpers';
import QueryResultsTable from 'components/queries/QueryResultsTable';
const host = {
@@ -44,6 +45,7 @@ const campaignWithQueryResults = {
...campaignWithNoQueryResults,
query_results: [
{ host_hostname: 'dfoihgsx', cwd: '/', directory: '/root' },
+ { host_hostname: 'abc123', cwd: '/', directory: '/root' },
],
};
@@ -85,6 +87,16 @@ describe('QueryResultsTable - component', () => {
});
});
+ it('filters by hostname', () => {
+ const hostnameInputFilter = componentWithQueryResults.find('InputField').find({ name: 'hostname' });
+
+ expect(componentWithQueryResults.find('QueryResultsRow').length).toEqual(2);
+
+ fillInFormInput(hostnameInputFilter, 'abc123');
+
+ expect(componentWithQueryResults.find('QueryResultsRow').length).toEqual(1);
+ });
+
it('calls the onExportQueryResults prop when the export button is clicked', () => {
const spy = createSpy();
const component = mount();