ui: Pass through default environment settings when when booting dev/test (#14519)

* ui: Add initial peering listing acceptance tests (#14522)
This commit is contained in:
John Cowen 2022-09-12 11:22:06 +01:00 committed by GitHub
parent 2df2276ffa
commit 9f14171f6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 94 additions and 8 deletions

View File

@ -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.$),
});
};

View File

@ -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', '')

View File

@ -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}
}
}
);
</script>

View File

@ -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: '',

View File

@ -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

View File

@ -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);
});
}

View File

@ -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;

View File

@ -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;

View File

@ -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)),
};

View File

@ -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]'),
});
}