Merge pull request #4241 from hashicorp/bugfix/gh-4203-multi-tags

[BUGFIX] Ensure all tags for a service are listed on the service detail page
This commit is contained in:
John Cowen 2018-06-20 09:17:40 +01:00 committed by GitHub
commit cdd9556d15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 78 additions and 19 deletions

View File

@ -21,6 +21,12 @@ export default Service.extend({
.then(function(item) {
const nodes = get(item, 'Nodes');
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);
return service;
});

View File

@ -15,11 +15,11 @@
{{/if}}
{{/block-slot}}
{{#block-slot 'content'}}
{{#if (gt item.Service.Tags.length 0)}}
{{#if (gt item.Tags.length 0)}}
<dl>
<dt>Tags</dt>
<dd>
{{join ', ' item.Service.Tags}}
<dd data-test-tags>
{{join ', ' item.Tags}}
</dd>
</dl>
{{/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;
switch (type) {
case 'dc':
url = '/v1/catalog/datacenters';
url = ['/v1/catalog/datacenters'];
break;
case 'service':
url = '/v1/internal/ui/services';
url = ['/v1/internal/ui/services', '/v1/health/service/'];
break;
case 'node':
url = '/v1/internal/ui/nodes';
// url = '/v1/health/service/_';
url = ['/v1/internal/ui/nodes'];
break;
case 'kv':
url = '/v1/kv/';
break;
case 'acl':
url = '/v1/acl/list';
// url = '/v1/acl/info/_';
url = ['/v1/acl/list'];
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" */
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 pages from 'consul-ui/tests/pages';
import api from 'consul-ui/tests/helpers/api';
@ -38,14 +38,14 @@ export default function(assert) {
}, yadda)
)
// 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);
})
.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);
})
.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) {
return create(number, model, data);
}
@ -277,6 +277,12 @@ export default function(assert) {
.then(['I see $property'], function(property, component) {
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}"`
);
})
// TODO: Think of better language
// TODO: These should be mergeable
.then(['"$selector" has the "$class" class'], function(selector, cls) {

View File

@ -70,8 +70,8 @@
"@glimmer/di" "^0.2.0"
"@hashicorp/api-double@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@hashicorp/api-double/-/api-double-1.1.0.tgz#299d3c560090dfe9c335db64d63c3ef0c5da79c4"
version "1.2.0"
resolved "https://registry.yarnpkg.com/@hashicorp/api-double/-/api-double-1.2.0.tgz#d2846f79d086ac009673ae755da15301e0f2f7c3"
dependencies:
"@gardenhq/o" "^8.0.1"
"@gardenhq/tick-control" "^2.0.0"
@ -5704,7 +5704,14 @@ js-yaml@0.3.x:
version "0.3.7"
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"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.11.0.tgz#597c1a8bd57152f26d622ce4117851a51f5ebaef"
dependencies:
@ -6711,8 +6718,8 @@ morgan@^1.8.1:
on-headers "~1.0.1"
mousetrap@^1.6.1:
version "1.6.1"
resolved "https://registry.yarnpkg.com/mousetrap/-/mousetrap-1.6.1.tgz#2a085f5c751294c75e7e81f6ec2545b29cbf42d9"
version "1.6.2"
resolved "https://registry.yarnpkg.com/mousetrap/-/mousetrap-1.6.2.tgz#caadd9cf886db0986fb2fee59a82f6bd37527587"
mout@^1.0.0:
version "1.1.0"