From 6d55c7a98c4a0882e66b870605fb69f777997bfe Mon Sep 17 00:00:00 2001 From: John Cowen Date: Tue, 19 Jun 2018 15:25:56 +0100 Subject: [PATCH] Add a failing test to show that lock session TTL's are not shown --- ui-v2/app/templates/dc/nodes/-sessions.hbs | 3 +- .../acceptance/dc/nodes/sessions/list.feature | 28 +++++++++++++++++++ .../steps/dc/nodes/sessions/list-steps.js | 10 +++++++ ui-v2/tests/helpers/set-cookies.js | 3 ++ ui-v2/tests/helpers/type-to-url.js | 5 ++++ ui-v2/tests/pages/dc/nodes/show.js | 3 ++ ui-v2/tests/steps.js | 5 ++++ 7 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 ui-v2/tests/acceptance/dc/nodes/sessions/list.feature create mode 100644 ui-v2/tests/acceptance/steps/dc/nodes/sessions/list-steps.js diff --git a/ui-v2/app/templates/dc/nodes/-sessions.hbs b/ui-v2/app/templates/dc/nodes/-sessions.hbs index 322cb9411..8e3d43ddb 100644 --- a/ui-v2/app/templates/dc/nodes/-sessions.hbs +++ b/ui-v2/app/templates/dc/nodes/-sessions.hbs @@ -1,5 +1,6 @@ {{#if (gt sessions.length 0)}} {{#tabular-collection + data-test-sessions class="sessions" items=sessions as |item index| }} @@ -22,7 +23,7 @@ {{item.LockDelay}} - + {{item.TTL}} diff --git a/ui-v2/tests/acceptance/dc/nodes/sessions/list.feature b/ui-v2/tests/acceptance/dc/nodes/sessions/list.feature new file mode 100644 index 000000000..41055dc74 --- /dev/null +++ b/ui-v2/tests/acceptance/dc/nodes/sessions/list.feature @@ -0,0 +1,28 @@ +@setupApplicationTest +Feature: dc / nodes / sessions /list: List Lock Sessions + In order to get information regarding lock sessions + As a user + I should be able to see a listing of lock sessions with necessary information under the lock sessions tab for a node + Scenario: Given 2 session with string TTLs + Given 1 datacenter model with the value "dc1" + And 1 node model from yaml + --- + - ID: node-0 + --- + And 2 session models from yaml + --- + - TTL: 30s + - TTL: 60m + --- + When I visit the node page for yaml + --- + dc: dc1 + node: node-0 + --- + And I click lockSessions on the tabs + Then I see lockSessionsIsSelected on the tabs + Then I see TTL on the sessions like yaml + --- + - 30s + - 60m + --- diff --git a/ui-v2/tests/acceptance/steps/dc/nodes/sessions/list-steps.js b/ui-v2/tests/acceptance/steps/dc/nodes/sessions/list-steps.js new file mode 100644 index 000000000..9bfbe9ac9 --- /dev/null +++ b/ui-v2/tests/acceptance/steps/dc/nodes/sessions/list-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); + }); +} diff --git a/ui-v2/tests/helpers/set-cookies.js b/ui-v2/tests/helpers/set-cookies.js index 04f085763..1e0547357 100644 --- a/ui-v2/tests/helpers/set-cookies.js +++ b/ui-v2/tests/helpers/set-cookies.js @@ -17,6 +17,9 @@ export default function(type, count, obj) { key = 'CONSUL_ACL_COUNT'; obj['CONSUL_ENABLE_ACLS'] = 1; break; + case 'session': + key = 'CONSUL_SESSION_COUNT'; + break; } if (key) { obj[key] = count; diff --git a/ui-v2/tests/helpers/type-to-url.js b/ui-v2/tests/helpers/type-to-url.js index 6fa84bbbb..0b2c8f582 100644 --- a/ui-v2/tests/helpers/type-to-url.js +++ b/ui-v2/tests/helpers/type-to-url.js @@ -16,6 +16,11 @@ export default function(type) { case 'acl': url = ['/v1/acl/list']; break; + case 'session': + url = function(url) { + return url.indexOf('/v1/session/node/') === 0; + }; + break; } return function(actual) { if (url === null) { diff --git a/ui-v2/tests/pages/dc/nodes/show.js b/ui-v2/tests/pages/dc/nodes/show.js index 577a03ae2..d51bda6cf 100644 --- a/ui-v2/tests/pages/dc/nodes/show.js +++ b/ui-v2/tests/pages/dc/nodes/show.js @@ -10,4 +10,7 @@ export default create({ services: collection('#services [data-test-tabular-row]', { port: attribute('data-test-service-port', '.port'), }), + sessions: collection('#lock-sessions [data-test-tabular-row]', { + TTL: attribute('data-test-session-ttl', '[data-test-session-ttl]'), + }), }); diff --git a/ui-v2/tests/steps.js b/ui-v2/tests/steps.js index a75d11499..e6e08e86e 100644 --- a/ui-v2/tests/steps.js +++ b/ui-v2/tests/steps.js @@ -33,6 +33,9 @@ export default function(assert) { case 'acls': model = 'acl'; break; + case 'sessions': + model = 'session'; + break; } cb(null, model); }, yadda) @@ -218,6 +221,8 @@ export default function(assert) { ) { const _component = currentPage[component]; const iterator = new Array(_component.length).fill(true); + // this will catch if we get aren't managing to select a component + assert.ok(iterator.length > 0); iterator.forEach(function(item, i, arr) { const actual = _component.objectAt(i)[property]; // anything coming from the DOM is going to be text/strings