Skip to content

Commit

Permalink
Add ability to search nodes listing page with IP Address
Browse files Browse the repository at this point in the history
* Update search field placeholder to display `Search`

* Add an acceptance test to search node listings with node name and IP Address

* Update and add unit tests for filter/search node listing with IP Address
  • Loading branch information
kaxcode committed Feb 4, 2020
1 parent c706089 commit 13ae5c0
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 3 deletions.
3 changes: 3 additions & 0 deletions ui-v2/app/search/filters/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ export default function(filterable) {
const sLower = s.toLowerCase();
return (
get(item, 'Node')
.toLowerCase()
.indexOf(sLower) !== -1 ||
get(item, 'Address')
.toLowerCase()
.indexOf(sLower) !== -1
);
Expand Down
2 changes: 1 addition & 1 deletion ui-v2/app/templates/components/catalog-filter.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{!<form>}}
{{freetext-filter searchable=searchable value=search placeholder="Search by name"}}
{{freetext-filter searchable=searchable value=search placeholder="Search"}}
{{radio-group keyboardAccess=true name="status" value=status items=(array
(hash label='All (Any Status)' value='' )
(hash label='Critical Checks' value='critical')
Expand Down
27 changes: 27 additions & 0 deletions ui-v2/tests/acceptance/dc/nodes/index.feature
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,30 @@ Feature: dc / nodes / index
Then the url should be /dc-1/nodes
Then I see 3 node models
And I see leader on the healthyNodes
Scenario: Searching the nodes with name and IP address
Given 3 node models from yaml
---
- Node: node-01
Address: 10.0.0.0
- Node: node-02
Address: 10.0.0.1
- Node: node-03
Address: 10.0.0.2
---
When I visit the nodes page for yaml
---
dc: dc-1
---
And I see 3 node models
Then I fill in with yaml
---
s: node-01
---
And I see 1 node model
And I see 1 node model with the name "node-01"
Then I fill in with yaml
---
s: 10.0.0.1
---
And I see 1 node model
And I see 1 node model with the name "node-02"
32 changes: 30 additions & 2 deletions ui-v2/tests/unit/search/filters/node-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import { module, test } from 'qunit';

module('Unit | Search | Filter | node', function() {
const filter = getFilter(cb => cb);
test('items are found by properties', function(assert) {
test('items are found by name', function(assert) {
[
{
Node: 'node-HIT',
Address: '10.0.0.0',
},
].forEach(function(item) {
const actual = filter(item, {
Expand All @@ -15,10 +16,24 @@ module('Unit | Search | Filter | node', function() {
assert.ok(actual);
});
});
test('items are not found', function(assert) {
test('items are found by IP address', function(assert) {
[
{
Node: 'node-HIT',
Address: '10.0.0.0',
},
].forEach(function(item) {
const actual = filter(item, {
s: '10',
});
assert.ok(actual);
});
});
test('items are not found by name', function(assert) {
[
{
Node: 'name',
Address: '10.0.0.0',
},
].forEach(function(item) {
const actual = filter(item, {
Expand All @@ -27,4 +42,17 @@ module('Unit | Search | Filter | node', function() {
assert.notOk(actual);
});
});
test('items are not found by IP address', function(assert) {
[
{
Node: 'name',
Address: '10.0.0.0',
},
].forEach(function(item) {
const actual = filter(item, {
s: '9',
});
assert.notOk(actual);
});
});
});

0 comments on commit 13ae5c0

Please sign in to comment.