From d66f5a6364fe8da4cf3a4369f3392181aa6afede Mon Sep 17 00:00:00 2001 From: John Cowen Date: Wed, 29 Jun 2022 19:07:39 +0100 Subject: [PATCH] ui: Fix up peer ENT tests (#13633) * ui: Add missing @nspaces * Reorder peerings to be before any optionals * Merge params instead of overwriting * Reorder int tests --- ui/packages/consul-ui/app/adapters/node.js | 2 +- ui/packages/consul-ui/app/adapters/service.js | 2 +- .../consul-ui/app/locations/fsm-with-optional.js | 10 +++++----- .../consul-ui/tests/acceptance/dc/nodes/index.feature | 2 +- .../tests/acceptance/dc/services/list.feature | 2 +- .../consul-ui/tests/integration/adapters/node-test.js | 4 ++-- .../tests/integration/adapters/service-test.js | 4 ++-- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/ui/packages/consul-ui/app/adapters/node.js b/ui/packages/consul-ui/app/adapters/node.js index e9520ba5dc..6df3b3b026 100644 --- a/ui/packages/consul-ui/app/adapters/node.js +++ b/ui/packages/consul-ui/app/adapters/node.js @@ -29,10 +29,10 @@ export default class NodeAdapter extends Adapter { X-Request-ID: ${uri} ${{ + ...this.peeringQuery, ns, partition, index, - ...this.peeringQuery, }} `; } diff --git a/ui/packages/consul-ui/app/adapters/service.js b/ui/packages/consul-ui/app/adapters/service.js index a804270340..d0dda48e46 100644 --- a/ui/packages/consul-ui/app/adapters/service.js +++ b/ui/packages/consul-ui/app/adapters/service.js @@ -33,10 +33,10 @@ export default class ServiceAdapter extends Adapter { X-Request-ID: ${uri} ${{ + ...this.peeringQuery, ns, partition, index, - ...this.peeringQuery, }} `; } diff --git a/ui/packages/consul-ui/app/locations/fsm-with-optional.js b/ui/packages/consul-ui/app/locations/fsm-with-optional.js index 5b43868e9a..de2975fe44 100644 --- a/ui/packages/consul-ui/app/locations/fsm-with-optional.js +++ b/ui/packages/consul-ui/app/locations/fsm-with-optional.js @@ -301,11 +301,11 @@ export default class FSMWithOptionalLocation { if (withOptional) { const temp = url.split('/'); - if (Object.keys(optional || {}).length === 0) { - optional = undefined; - } - optional = Object.values(optional || this.optional || {}); - optional = optional.filter(item => Boolean(item)).map(item => item.value || item, []); + optional = { + ...this.optional, + ...(optional || {}) + }; + optional = Object.values(optional).filter(item => Boolean(item)).map(item => item.value || item, []); temp.splice(...[1, 0].concat(optional)); url = temp.join('/'); } diff --git a/ui/packages/consul-ui/tests/acceptance/dc/nodes/index.feature b/ui/packages/consul-ui/tests/acceptance/dc/nodes/index.feature index 8a3a52d1d9..a56758958c 100644 --- a/ui/packages/consul-ui/tests/acceptance/dc/nodes/index.feature +++ b/ui/packages/consul-ui/tests/acceptance/dc/nodes/index.feature @@ -45,7 +45,7 @@ Feature: dc / nodes / index --- Then the url should be /dc-1/nodes And the title should be "Nodes - Consul" - And a GET request was made to "/v1/internal/ui/nodes?dc=dc-1&with-peers=true" + And a GET request was made to "/v1/internal/ui/nodes?dc=dc-1&with-peers=true&ns=@namespace" Then I see 3 node models Scenario: Seeing the leader in node listing Given 3 node models from yaml diff --git a/ui/packages/consul-ui/tests/acceptance/dc/services/list.feature b/ui/packages/consul-ui/tests/acceptance/dc/services/list.feature index 3052fcf971..fe1682d251 100644 --- a/ui/packages/consul-ui/tests/acceptance/dc/services/list.feature +++ b/ui/packages/consul-ui/tests/acceptance/dc/services/list.feature @@ -16,7 +16,7 @@ Feature: dc / services / list dc: dc-1 --- Then the url should be /dc-1/services - And a GET request was made to "/v1/internal/ui/services?dc=dc-1&with-peers=true" + And a GET request was made to "/v1/internal/ui/services?dc=dc-1&with-peers=true&ns=@namespace" Then I see 3 service models diff --git a/ui/packages/consul-ui/tests/integration/adapters/node-test.js b/ui/packages/consul-ui/tests/integration/adapters/node-test.js index 61b92be49c..5904fb3f5c 100644 --- a/ui/packages/consul-ui/tests/integration/adapters/node-test.js +++ b/ui/packages/consul-ui/tests/integration/adapters/node-test.js @@ -14,9 +14,9 @@ module('Integration | Adapter | node', function(hooks) { const adapter = this.owner.lookup('adapter:node'); const client = this.owner.lookup('service:client/http'); const request = client.requestParams.bind(client); - const expected = `GET /v1/internal/ui/nodes?dc=${dc}${ + const expected = `GET /v1/internal/ui/nodes?dc=${dc}&with-peers=true${ shouldHaveNspace(nspace) ? `&ns=${nspace}` : `` - }&with-peers=true`; + }`; const actual = adapter.requestForQuery(request, { dc: dc, ns: nspace, diff --git a/ui/packages/consul-ui/tests/integration/adapters/service-test.js b/ui/packages/consul-ui/tests/integration/adapters/service-test.js index 9c6390f53e..853ecbff88 100644 --- a/ui/packages/consul-ui/tests/integration/adapters/service-test.js +++ b/ui/packages/consul-ui/tests/integration/adapters/service-test.js @@ -14,9 +14,9 @@ module('Integration | Adapter | service', function(hooks) { const adapter = this.owner.lookup('adapter:service'); const client = this.owner.lookup('service:client/http'); const request = client.requestParams.bind(client); - const expected = `GET /v1/internal/ui/services?dc=${dc}${ + const expected = `GET /v1/internal/ui/services?dc=${dc}&with-peers=true${ shouldHaveNspace(nspace) ? `&ns=${nspace}` : `` - }&with-peers=true`; + }`; let actual = adapter.requestForQuery(request, { dc: dc, ns: nspace,