From 6e3ad50e99f3b1f97f307bd94e6b2f6750b4b988 Mon Sep 17 00:00:00 2001 From: John Cowen Date: Tue, 3 Jul 2018 13:23:45 +0100 Subject: [PATCH] Hedge for when consul sends nodes with an empty ID --- ui-v2/app/adapters/node.js | 3 ++ .../acceptance/dc/nodes/empty-ids.feature | 33 +++++++++++++++++++ .../steps/dc/nodes/empty-ids-steps.js | 10 ++++++ 3 files changed, 46 insertions(+) create mode 100644 ui-v2/tests/acceptance/dc/nodes/empty-ids.feature create mode 100644 ui-v2/tests/acceptance/steps/dc/nodes/empty-ids-steps.js diff --git a/ui-v2/app/adapters/node.js b/ui-v2/app/adapters/node.js index 0890a8aa1..22460875a 100644 --- a/ui-v2/app/adapters/node.js +++ b/ui-v2/app/adapters/node.js @@ -23,6 +23,9 @@ export default Adapter.extend({ break; default: response = response.map((item, i, arr) => { + if (item[SLUG_KEY] === '') { + item[SLUG_KEY] = item['Node']; + } return { ...item, ...{ diff --git a/ui-v2/tests/acceptance/dc/nodes/empty-ids.feature b/ui-v2/tests/acceptance/dc/nodes/empty-ids.feature new file mode 100644 index 000000000..434766775 --- /dev/null +++ b/ui-v2/tests/acceptance/dc/nodes/empty-ids.feature @@ -0,0 +1,33 @@ +@setupApplicationTest +Feature: Hedge for if nodes come in over the API with no ID + Scenario: A node list with some missing IDs + Given 1 datacenter model with the value "dc-1" + And 5 node models from yaml + --- + - ID: id-1 + Node: name-1 + - ID: "" + Node: name-2 + - ID: "" + Node: name-3 + - ID: "" + Node: name-4 + - ID: "" + Node: name-5 + --- + When I visit the nodes page for yaml + --- + dc: dc-1 + --- + Then the url should be /dc-1/nodes + Then I see name on the nodes like yaml + --- + - name-1 + - name-2 + - name-3 + - name-4 + - name-5 + +@ignore + Scenario: Visually comparing + Then the ".unhealthy" element should look like the "/node_modules/@hashicorp/consul-testing-extras/fixtures/dc/nodes/empty-ids.png" image diff --git a/ui-v2/tests/acceptance/steps/dc/nodes/empty-ids-steps.js b/ui-v2/tests/acceptance/steps/dc/nodes/empty-ids-steps.js new file mode 100644 index 000000000..a7eff3228 --- /dev/null +++ b/ui-v2/tests/acceptance/steps/dc/nodes/empty-ids-steps.js @@ -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); + }); +}