diff --git a/ui/packages/consul-peerings/app/components/consul/peer/list/test-support.js b/ui/packages/consul-peerings/app/components/consul/peer/list/test-support.js new file mode 100644 index 0000000000..531bffc7bd --- /dev/null +++ b/ui/packages/consul-peerings/app/components/consul/peer/list/test-support.js @@ -0,0 +1,14 @@ +export const selectors = { + $: '.consul-peer-list', + collection: { + $: '[data-test-list-row]', + peer: { + $: 'li' + }, + } +}; +export default (collection, isPresent) => () => { + return collection(`${selectors.$} ${selectors.collection.$}`, { + peer: isPresent(selectors.collection.peer.$), + }); +}; diff --git a/ui/packages/consul-ui/config/environment.js b/ui/packages/consul-ui/config/environment.js index 4bd0967996..f8b11e8041 100644 --- a/ui/packages/consul-ui/config/environment.js +++ b/ui/packages/consul-ui/config/environment.js @@ -84,6 +84,7 @@ module.exports = function(environment, $ = process.env) { SSOEnabled: false, PeeringEnabled: false, PartitionsEnabled: false, + HCPEnabled: false, LocalDatacenter: env('CONSUL_DATACENTER_LOCAL', 'dc1'), PrimaryDatacenter: env('CONSUL_DATACENTER_PRIMARY', 'dc1'), APIPrefix: env('CONSUL_API_PREFIX', '') @@ -110,6 +111,7 @@ module.exports = function(environment, $ = process.env) { // in testing peering feature is on by default PeeringEnabled: env('CONSUL_PEERINGS_ENABLED', true), PartitionsEnabled: env('CONSUL_PARTITIONS_ENABLED', false), + HCPEnabled: env('CONSUL_HCP_ENABLED', false), LocalDatacenter: env('CONSUL_DATACENTER_LOCAL', 'dc1'), PrimaryDatacenter: env('CONSUL_DATACENTER_PRIMARY', 'dc1'), APIPrefix: env('CONSUL_API_PREFIX', '') @@ -163,6 +165,7 @@ module.exports = function(environment, $ = process.env) { SSOEnabled: env('CONSUL_SSO_ENABLED', true), PeeringEnabled: env('CONSUL_PEERINGS_ENABLED', true), PartitionsEnabled: env('CONSUL_PARTITIONS_ENABLED', true), + HCPEnabled: env('CONSUL_HCP_ENABLED', false), LocalDatacenter: env('CONSUL_DATACENTER_LOCAL', 'dc1'), PrimaryDatacenter: env('CONSUL_DATACENTER_PRIMARY', 'dc1'), APIPrefix: env('CONSUL_API_PREFIX', '') diff --git a/ui/packages/consul-ui/lib/startup/templates/body.html.js b/ui/packages/consul-ui/lib/startup/templates/body.html.js index b4c46266ee..af0cdc5b4a 100644 --- a/ui/packages/consul-ui/lib/startup/templates/body.html.js +++ b/ui/packages/consul-ui/lib/startup/templates/body.html.js @@ -79,22 +79,37 @@ ${ ( function(get, obj) { Object.entries(obj).forEach(([key, value]) => { - if(get(key) || (key === 'CONSUL_NSPACES_ENABLE' && ${ + if(value.default || get(key) || (key === 'CONSUL_NSPACES_ENABLE' && ${ env('CONSUL_NSPACES_ENABLED') === '1' ? `true` : `false` })) { - document.write(\`\\x3Cscript src="${rootURL}assets/\${value}/services.js">\\x3C/script>\`); - document.write(\`\\x3Cscript src="${rootURL}assets/\${value}/routes.js">\\x3C/script>\`); + document.write(\`\\x3Cscript src="${rootURL}assets/\${value.name}/services.js">\\x3C/script>\`); + document.write(\`\\x3Cscript src="${rootURL}assets/\${value.name}/routes.js">\\x3C/script>\`); } }); } )( key => document.cookie.split('; ').find(item => item.startsWith(\`\${key}=\`)), { - 'CONSUL_ACLS_ENABLE': 'consul-acls', - 'CONSUL_PEERINGS_ENABLE': 'consul-peerings', - 'CONSUL_PARTITIONS_ENABLE': 'consul-partitions', - 'CONSUL_NSPACES_ENABLE': 'consul-nspaces', - 'CONSUL_HCP_ENABLE': 'consul-hcp' + 'CONSUL_ACLS_ENABLE': { + name: 'consul-acls', + default: ${config.operatorConfig.ACLsEnabled} + }, + 'CONSUL_PEERINGS_ENABLE': { + name: 'consul-peerings', + default: ${config.operatorConfig.PeeringEnabled} + }, + 'CONSUL_PARTITIONS_ENABLE': { + name: 'consul-partitions', + default: ${config.operatorConfig.PartitionsEnabled} + }, + 'CONSUL_NSPACES_ENABLE': { + name: 'consul-nspaces', + default: ${config.operatorConfig.NamespacesEnabled} + }, + 'CONSUL_HCP_ENABLE': { + name: 'consul-hcp', + default: ${config.operatorConfig.HCPEnabled} + } } ); diff --git a/ui/packages/consul-ui/node-tests/config/environment.js b/ui/packages/consul-ui/node-tests/config/environment.js index 286fb741db..7a45f6d8d0 100644 --- a/ui/packages/consul-ui/node-tests/config/environment.js +++ b/ui/packages/consul-ui/node-tests/config/environment.js @@ -24,6 +24,7 @@ test( SSOEnabled: false, PartitionsEnabled: false, PeeringEnabled: true, + HCPEnabled: false, LocalDatacenter: 'dc1', PrimaryDatacenter: 'dc1', APIPrefix: '', @@ -41,6 +42,7 @@ test( SSOEnabled: false, PartitionsEnabled: false, PeeringEnabled: true, + HCPEnabled: false, LocalDatacenter: 'dc1', PrimaryDatacenter: 'dc1', APIPrefix: '', @@ -58,6 +60,7 @@ test( SSOEnabled: true, PartitionsEnabled: false, PeeringEnabled: true, + HCPEnabled: false, LocalDatacenter: 'dc1', PrimaryDatacenter: 'dc1', APIPrefix: '', @@ -72,6 +75,7 @@ test( SSOEnabled: true, PartitionsEnabled: true, PeeringEnabled: true, + HCPEnabled: false, LocalDatacenter: 'dc1', PrimaryDatacenter: 'dc1', APIPrefix: '', diff --git a/ui/packages/consul-ui/tests/acceptance/dc/peers/index.feature b/ui/packages/consul-ui/tests/acceptance/dc/peers/index.feature new file mode 100644 index 0000000000..e8d5d4a951 --- /dev/null +++ b/ui/packages/consul-ui/tests/acceptance/dc/peers/index.feature @@ -0,0 +1,19 @@ +@setupApplicationTest +Feature: dc / peers / index: Peers List + Background: + And 1 datacenter model with the value "dc-1" + And 3 peer models from yaml + --- + - Name: a-peer + - Name: b-peer + - Name: z-peer + --- + When I visit the peers page for yaml + --- + dc: dc-1 + --- + Then the url should be /dc-1/peers + And the title should be "Peers - Consul" + Scenario: + Then I see 3 peer models + diff --git a/ui/packages/consul-ui/tests/acceptance/steps/dc/peers/index-steps.js b/ui/packages/consul-ui/tests/acceptance/steps/dc/peers/index-steps.js new file mode 100644 index 0000000000..f67e6f8de4 --- /dev/null +++ b/ui/packages/consul-ui/tests/acceptance/steps/dc/peers/index-steps.js @@ -0,0 +1,11 @@ +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); + }); +} diff --git a/ui/packages/consul-ui/tests/helpers/set-cookies.js b/ui/packages/consul-ui/tests/helpers/set-cookies.js index 1a02c4a10d..e5b41e4d28 100644 --- a/ui/packages/consul-ui/tests/helpers/set-cookies.js +++ b/ui/packages/consul-ui/tests/helpers/set-cookies.js @@ -52,6 +52,9 @@ export default function(type, value, doc = document) { case 'nspace': key = 'CONSUL_NSPACE_COUNT'; break; + case 'peer': + key = 'CONSUL_PEER_COUNT'; + break; } if (key) { obj[key] = value; diff --git a/ui/packages/consul-ui/tests/helpers/type-to-url.js b/ui/packages/consul-ui/tests/helpers/type-to-url.js index 1e88556ad1..7ef00fcb2d 100644 --- a/ui/packages/consul-ui/tests/helpers/type-to-url.js +++ b/ui/packages/consul-ui/tests/helpers/type-to-url.js @@ -46,6 +46,9 @@ export default function(type) { case 'nspace': requests = ['/v1/namespaces', '/v1/namespace/']; break; + case 'peer': + requests = ['/v1/peers', '/v1/peer/']; + break; case 'topology': requests = ['/v1/internal/ui/service-topology']; break; diff --git a/ui/packages/consul-ui/tests/pages.js b/ui/packages/consul-ui/tests/pages.js index e2b9600d60..eb52ff53dd 100644 --- a/ui/packages/consul-ui/tests/pages.js +++ b/ui/packages/consul-ui/tests/pages.js @@ -46,6 +46,7 @@ import consulPolicyListFactory from 'consul-ui/components/consul/policy/list/pag import consulAuthMethodListFactory from 'consul-ui/components/consul/auth-method/list/pageobject'; import consulIntentionListFactory from 'consul-ui/components/consul/intention/list/pageobject'; import consulNspaceListFactory from 'consul-ui/components/consul/nspace/list/pageobject'; +import consulPeerListFactory from 'consul-ui/components/consul/peer/list/test-support'; import consulKvListFactory from 'consul-ui/components/consul/kv/list/pageobject'; // pages @@ -73,6 +74,7 @@ import intentions from 'consul-ui/tests/pages/dc/intentions/index'; import intention from 'consul-ui/tests/pages/dc/intentions/edit'; import nspaces from 'consul-ui/tests/pages/dc/nspaces/index'; import nspace from 'consul-ui/tests/pages/dc/nspaces/edit'; +import peers from 'consul-ui/tests/pages/dc/peers/index'; // utils const deletable = createDeletable(clickable); @@ -109,6 +111,10 @@ const consulNspaceList = consulNspaceListFactory( text, morePopoverMenu ); +const consulPeerList = consulPeerListFactory( + collection, + isPresent +); const consulKvList = consulKvListFactory(collection, clickable, attribute, deletable); const consulTokenList = consulTokenListFactory( collection, @@ -230,6 +236,7 @@ export default { nspace: create( nspace(visitable, submitable, deletable, cancelable, policySelector, roleSelector) ), + peers: create(peers(visitable, creatable, consulPeerList, popoverSelect)), settings: create(settings(visitable, submitable, isPresent)), routingConfig: create(routingConfig(visitable, text)), }; diff --git a/ui/packages/consul-ui/tests/pages/dc/peers/index.js b/ui/packages/consul-ui/tests/pages/dc/peers/index.js new file mode 100644 index 0000000000..74802943ce --- /dev/null +++ b/ui/packages/consul-ui/tests/pages/dc/peers/index.js @@ -0,0 +1,7 @@ +export default function(visitable, creatable, items, popoverSelect) { + return creatable({ + visit: visitable('/:dc/peers'), + peers: items(), + sort: popoverSelect('[data-test-sort-control]'), + }); +}