From 6c9f4fbe8a47bf187f35c55745c0a635681b0f8c Mon Sep 17 00:00:00 2001 From: John Cowen Date: Thu, 12 Jul 2018 14:46:56 +0100 Subject: [PATCH 1/4] Acceptance test for searching service by tag --- .../components/catalog-filter.feature | 39 +++++++++++++++++++ ui-v2/tests/pages/dc/nodes/show.js | 1 + 2 files changed, 40 insertions(+) diff --git a/ui-v2/tests/acceptance/components/catalog-filter.feature b/ui-v2/tests/acceptance/components/catalog-filter.feature index 962edec41..71900bcfe 100644 --- a/ui-v2/tests/acceptance/components/catalog-filter.feature +++ b/ui-v2/tests/acceptance/components/catalog-filter.feature @@ -87,6 +87,16 @@ Feature: components / catalog-filter --- And I see 1 [Model] model And I see 1 [Model] model with the id "service-0-with-id" + Then I fill in with yaml + --- + s: hard drive + --- + And I see 1 [Model] model with the name "[Model]-1" + Then I fill in with yaml + --- + s: monitor + --- + And I see 2 [Model] models Where: ------------------------------------------------- | Model | Page | Url | @@ -117,3 +127,32 @@ Feature: components / catalog-filter | Model | Page | Url | | nodes | service | /dc-1/services/service-0 | ------------------------------------------------- + Scenario: + Given 1 datacenter model with the value "dc-1" + And 3 service models from yaml + --- + - Tags: ['one', 'two', 'three'] + - Tags: ['two', 'three'] + - Tags: ['three'] + --- + When I visit the services page for yaml + --- + dc: dc-1 + --- + Then the url should be /dc-1/services + Then I see 3 service models + Then I fill in with yaml + --- + s: one + --- + And I see 1 service model with the name "service-0" + Then I fill in with yaml + --- + s: two + --- + And I see 2 service models + Then I fill in with yaml + --- + s: three + --- + And I see 3 service models diff --git a/ui-v2/tests/pages/dc/nodes/show.js b/ui-v2/tests/pages/dc/nodes/show.js index 01bfc7737..db1bdf0db 100644 --- a/ui-v2/tests/pages/dc/nodes/show.js +++ b/ui-v2/tests/pages/dc/nodes/show.js @@ -7,6 +7,7 @@ export default function(visitable, deletable, clickable, attribute, collection, }), services: collection('#services [data-test-tabular-row]', { id: attribute('data-test-service-id', '[data-test-service-id]'), + name: attribute('data-test-service-name', '[data-test-service-name]'), port: attribute('data-test-service-port', '.port'), }), sessions: collection( From f9931309374eef715524a1ce269ecb5032f5f621 Mon Sep 17 00:00:00 2001 From: John Cowen Date: Thu, 12 Jul 2018 14:47:41 +0100 Subject: [PATCH 2/4] Add basic searching by tags using the freetext search near-term --- ui-v2/app/controllers/dc/nodes/show.js | 4 ++++ ui-v2/app/controllers/dc/services/index.js | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ui-v2/app/controllers/dc/nodes/show.js b/ui-v2/app/controllers/dc/nodes/show.js index cec7398db..3b370e146 100644 --- a/ui-v2/app/controllers/dc/nodes/show.js +++ b/ui-v2/app/controllers/dc/nodes/show.js @@ -26,6 +26,10 @@ export default Controller.extend(WithFiltering, { get(item, 'ID') .toLowerCase() .indexOf(term) !== -1 || + (get(item, 'Tags') || []) + .join('') + .toLowerCase() + .indexOf(term) !== -1 || get(item, 'Port') .toString() .toLowerCase() diff --git a/ui-v2/app/controllers/dc/services/index.js b/ui-v2/app/controllers/dc/services/index.js index 283a6c420..2497929e1 100644 --- a/ui-v2/app/controllers/dc/services/index.js +++ b/ui-v2/app/controllers/dc/services/index.js @@ -26,10 +26,16 @@ const widthDeclaration = function(num) { }; export default Controller.extend(WithHealthFiltering, { filter: function(item, { s = '', status = '' }) { + const term = s.toLowerCase(); return ( - get(item, 'Name') + (get(item, 'Name') .toLowerCase() - .indexOf(s.toLowerCase()) !== -1 && item.hasStatus(status) + .indexOf(term) !== -1 || + (get(item, 'Tags') || []) + .join('') + .toLowerCase() + .indexOf(term) !== -1) && + item.hasStatus(status) ); }, totalWidth: computed('{maxPassing,maxWarning,maxCritical}', function() { From f7209e63f14848034cb5c03fa091fe56de912626 Mon Sep 17 00:00:00 2001 From: John Cowen Date: Wed, 18 Jul 2018 18:07:56 +0100 Subject: [PATCH 3/4] ADd some extra tests to pick up on searching by two joined tags --- .../tests/acceptance/components/catalog-filter.feature | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ui-v2/tests/acceptance/components/catalog-filter.feature b/ui-v2/tests/acceptance/components/catalog-filter.feature index 71900bcfe..213eee4c4 100644 --- a/ui-v2/tests/acceptance/components/catalog-filter.feature +++ b/ui-v2/tests/acceptance/components/catalog-filter.feature @@ -97,6 +97,11 @@ Feature: components / catalog-filter s: monitor --- And I see 2 [Model] models + Then I fill in with yaml + --- + s: wallpix + --- + And I see 0 [Model] models Where: ------------------------------------------------- | Model | Page | Url | @@ -156,3 +161,8 @@ Feature: components / catalog-filter s: three --- And I see 3 service models + Then I fill in with yaml + --- + s: wothre + --- + And I see 0 service models From 9ae81696a180de82b5aeae12f76a8af575879b11 Mon Sep 17 00:00:00 2001 From: John Cowen Date: Wed, 18 Jul 2018 18:08:22 +0100 Subject: [PATCH 4/4] Use `some` for the tags search instead of munging and searching --- ui-v2/app/controllers/dc/nodes/show.js | 7 +++---- ui-v2/app/controllers/dc/services/index.js | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/ui-v2/app/controllers/dc/nodes/show.js b/ui-v2/app/controllers/dc/nodes/show.js index 3b370e146..80c4c3287 100644 --- a/ui-v2/app/controllers/dc/nodes/show.js +++ b/ui-v2/app/controllers/dc/nodes/show.js @@ -26,10 +26,9 @@ export default Controller.extend(WithFiltering, { get(item, 'ID') .toLowerCase() .indexOf(term) !== -1 || - (get(item, 'Tags') || []) - .join('') - .toLowerCase() - .indexOf(term) !== -1 || + (get(item, 'Tags') || []).some(function(item) { + return item.toLowerCase().indexOf(term) !== -1; + }) || get(item, 'Port') .toString() .toLowerCase() diff --git a/ui-v2/app/controllers/dc/services/index.js b/ui-v2/app/controllers/dc/services/index.js index 2497929e1..373ca6f30 100644 --- a/ui-v2/app/controllers/dc/services/index.js +++ b/ui-v2/app/controllers/dc/services/index.js @@ -31,10 +31,9 @@ export default Controller.extend(WithHealthFiltering, { (get(item, 'Name') .toLowerCase() .indexOf(term) !== -1 || - (get(item, 'Tags') || []) - .join('') - .toLowerCase() - .indexOf(term) !== -1) && + (get(item, 'Tags') || []).some(function(item) { + return item.toLowerCase().indexOf(term) !== -1; + })) && item.hasStatus(status) ); },