Merge pull request #4331 from hashicorp/feature/hedge-empty-node-ids

Hedge for when consul sends nodes with an empty ID
This commit is contained in:
John Cowen 2018-07-03 16:11:31 +01:00 committed by GitHub
commit 5b759c3183
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 53 additions and 0 deletions

View File

@ -1,6 +1,14 @@
import Adapter from './application';
import { PRIMARY_KEY, SLUG_KEY } from 'consul-ui/models/node';
import { OK as HTTP_OK } from 'consul-ui/utils/http/status';
// TODO: Looks like ID just isn't used at all
// consider just using .Node for the SLUG_KEY
const fillSlug = function(item) {
if (item[SLUG_KEY] === '') {
item[SLUG_KEY] = item['Node'];
}
return item;
};
export default Adapter.extend({
urlForQuery: function(query, modelName) {
return this.appendURL('internal/ui/nodes', [], this.cleanQuery(query));
@ -14,6 +22,7 @@ export default Adapter.extend({
const url = this.parseURL(requestData.url);
switch (true) {
case this.isQueryRecord(url):
response = fillSlug(response);
response = {
...response,
...{
@ -23,6 +32,7 @@ export default Adapter.extend({
break;
default:
response = response.map((item, i, arr) => {
item = fillSlug(item);
return {
...item,
...{

View File

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

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