Ensure all tags for a service are listed on the service detail page

This commit is contained in:
John Cowen 2018-06-18 15:38:52 +01:00
parent ce4c312ef2
commit b7a15e6616
7 changed files with 78 additions and 19 deletions

View File

@ -21,6 +21,12 @@ export default Service.extend({
.then(function(item) { .then(function(item) {
const nodes = get(item, 'Nodes'); const nodes = get(item, 'Nodes');
const service = get(nodes, 'firstObject'); const service = get(nodes, 'firstObject');
const tags = nodes
.reduce(function(prev, item) {
return prev.concat(get(item, 'Service.Tags') || []);
}, [])
.uniq();
set(service, 'Tags', tags);
set(service, 'Nodes', nodes); set(service, 'Nodes', nodes);
return service; return service;
}); });

View File

@ -15,11 +15,11 @@
{{/if}} {{/if}}
{{/block-slot}} {{/block-slot}}
{{#block-slot 'content'}} {{#block-slot 'content'}}
{{#if (gt item.Service.Tags.length 0)}} {{#if (gt item.Tags.length 0)}}
<dl> <dl>
<dt>Tags</dt> <dt>Tags</dt>
<dd> <dd data-test-tags>
{{join ', ' item.Service.Tags}} {{join ', ' item.Tags}}
</dd> </dd>
</dl> </dl>
{{/if}} {{/if}}

View File

@ -0,0 +1,22 @@
@setupApplicationTest
Feature: dc / services / show: Show Service
Scenario: Given various service with various tags, all tags are displayed
Given 1 datacenter model with the value "dc1"
And 3 node models
And 1 service model from yaml
---
- Service:
Tags: ['Tag1', 'Tag2']
- Service:
Tags: ['Tag3', 'Tag1']
- Service:
Tags: ['Tag2', 'Tag3']
---
When I visit the service page for yaml
---
dc: dc1
service: service-0
---
Then I see the text "Tag1, Tag2, Tag3" in "[data-test-tags]"
Then ok

View File

@ -0,0 +1,10 @@
import steps from '../../steps';
// step definitions that are shared between features should be moved to the
// tests/acceptance/steps/steps.js file
export default function(assert) {
return steps(assert).then('I should find a file', function() {
assert.ok(true, this.step);
});
}

View File

@ -2,22 +2,30 @@ export default function(type) {
let url = null; let url = null;
switch (type) { switch (type) {
case 'dc': case 'dc':
url = '/v1/catalog/datacenters'; url = ['/v1/catalog/datacenters'];
break; break;
case 'service': case 'service':
url = '/v1/internal/ui/services'; url = ['/v1/internal/ui/services', '/v1/health/service/'];
break; break;
case 'node': case 'node':
url = '/v1/internal/ui/nodes'; url = ['/v1/internal/ui/nodes'];
// url = '/v1/health/service/_';
break; break;
case 'kv': case 'kv':
url = '/v1/kv/'; url = '/v1/kv/';
break; break;
case 'acl': case 'acl':
url = '/v1/acl/list'; url = ['/v1/acl/list'];
// url = '/v1/acl/info/_';
break; break;
} }
return url; return function(actual) {
if (url === null) {
return false;
}
if (typeof url === 'string') {
return url === actual;
}
return url.some(function(item) {
return actual.indexOf(item) === 0;
});
};
} }

View File

@ -1,6 +1,6 @@
/* eslint no-console: "off" */ /* eslint no-console: "off" */
import yadda from './helpers/yadda'; import yadda from './helpers/yadda';
import { currentURL, click, triggerKeyEvent } from '@ember/test-helpers'; import { currentURL, click, triggerKeyEvent, find } from '@ember/test-helpers';
import getDictionary from '@hashicorp/ember-cli-api-double/dictionary'; import getDictionary from '@hashicorp/ember-cli-api-double/dictionary';
import pages from 'consul-ui/tests/pages'; import pages from 'consul-ui/tests/pages';
import api from 'consul-ui/tests/helpers/api'; import api from 'consul-ui/tests/helpers/api';
@ -38,14 +38,14 @@ export default function(assert) {
}, yadda) }, yadda)
) )
// doubles // doubles
.given(['$number $model model', '$number $model models'], function(number, model) { .given(['$number $model model[s]?', '$number $model models'], function(number, model) {
return create(number, model); return create(number, model);
}) })
.given(['$number $model model with the value "$value"'], function(number, model, value) { .given(['$number $model model[s]? with the value "$value"'], function(number, model, value) {
return create(number, model, value); return create(number, model, value);
}) })
.given( .given(
['$number $model model[s]? from yaml\n$yaml', '$number $model model from json\n$json'], ['$number $model model[s]? from yaml\n$yaml', '$number $model model[s]? from json\n$json'],
function(number, model, data) { function(number, model, data) {
return create(number, model, data); return create(number, model, data);
} }
@ -273,6 +273,12 @@ export default function(assert) {
.then(['I see $property'], function(property, component) { .then(['I see $property'], function(property, component) {
assert.ok(currentPage[property], `Expected to see ${property}`); assert.ok(currentPage[property], `Expected to see ${property}`);
}) })
.then(['I see the text "$text" in "$selector"'], function(text, selector) {
assert.ok(
find(selector).textContent.indexOf(text) !== -1,
`Expected to see "${text}" in "${selector}"`
);
})
.then('ok', function() { .then('ok', function() {
assert.ok(true); assert.ok(true);
}) })

View File

@ -70,8 +70,8 @@
"@glimmer/di" "^0.2.0" "@glimmer/di" "^0.2.0"
"@hashicorp/api-double@^1.1.0": "@hashicorp/api-double@^1.1.0":
version "1.1.0" version "1.2.0"
resolved "https://registry.yarnpkg.com/@hashicorp/api-double/-/api-double-1.1.0.tgz#299d3c560090dfe9c335db64d63c3ef0c5da79c4" resolved "https://registry.yarnpkg.com/@hashicorp/api-double/-/api-double-1.2.0.tgz#d2846f79d086ac009673ae755da15301e0f2f7c3"
dependencies: dependencies:
"@gardenhq/o" "^8.0.1" "@gardenhq/o" "^8.0.1"
"@gardenhq/tick-control" "^2.0.0" "@gardenhq/tick-control" "^2.0.0"
@ -5704,7 +5704,14 @@ js-yaml@0.3.x:
version "0.3.7" version "0.3.7"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-0.3.7.tgz#d739d8ee86461e54b354d6a7d7d1f2ad9a167f62" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-0.3.7.tgz#d739d8ee86461e54b354d6a7d7d1f2ad9a167f62"
js-yaml@^3.10.0, js-yaml@^3.11.0, js-yaml@^3.2.5, js-yaml@^3.2.7, js-yaml@^3.6.1, js-yaml@^3.7.0, js-yaml@^3.8.4, js-yaml@^3.9.0, js-yaml@^3.9.1: js-yaml@^3.10.0, js-yaml@^3.11.0, js-yaml@^3.8.4:
version "3.12.0"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.12.0.tgz#eaed656ec8344f10f527c6bfa1b6e2244de167d1"
dependencies:
argparse "^1.0.7"
esprima "^4.0.0"
js-yaml@^3.2.5, js-yaml@^3.2.7, js-yaml@^3.6.1, js-yaml@^3.7.0, js-yaml@^3.9.0, js-yaml@^3.9.1:
version "3.11.0" version "3.11.0"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.11.0.tgz#597c1a8bd57152f26d622ce4117851a51f5ebaef" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.11.0.tgz#597c1a8bd57152f26d622ce4117851a51f5ebaef"
dependencies: dependencies:
@ -6711,8 +6718,8 @@ morgan@^1.8.1:
on-headers "~1.0.1" on-headers "~1.0.1"
mousetrap@^1.6.1: mousetrap@^1.6.1:
version "1.6.1" version "1.6.2"
resolved "https://registry.yarnpkg.com/mousetrap/-/mousetrap-1.6.1.tgz#2a085f5c751294c75e7e81f6ec2545b29cbf42d9" resolved "https://registry.yarnpkg.com/mousetrap/-/mousetrap-1.6.2.tgz#caadd9cf886db0986fb2fee59a82f6bd37527587"
mout@^1.0.0: mout@^1.0.0:
version "1.1.0" version "1.1.0"