From 8a1c361e1773611f96435dd96ac4c4cbf2462ac4 Mon Sep 17 00:00:00 2001 From: John Cowen Date: Wed, 13 Jun 2018 14:31:36 +0100 Subject: [PATCH 1/2] Disable the delete button in the acl list for the anon token only --- ui-v2/app/templates/dc/acls/index.hbs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ui-v2/app/templates/dc/acls/index.hbs b/ui-v2/app/templates/dc/acls/index.hbs index 49a51ab80..b0c032328 100644 --- a/ui-v2/app/templates/dc/acls/index.hbs +++ b/ui-v2/app/templates/dc/acls/index.hbs @@ -47,9 +47,11 @@
  • Clone
  • +{{# if (not-eq item.ID 'anonymous') }}
  • Delete
  • +{{/if}} {{/action-group}} {{/block-slot}} From 9aa86d892ddbf1eda0a2b40ef6d689f2b39bc299 Mon Sep 17 00:00:00 2001 From: John Cowen Date: Thu, 14 Jun 2018 15:01:54 +0100 Subject: [PATCH 2/2] Add test for not showing the delete button for the first acl... Also, change the action group page objects to use data-test attributes instead of last-child which isn't reliable (and stay consistent) --- ui-v2/app/templates/dc/acls/index.hbs | 8 ++-- ui-v2/app/templates/dc/kv/index.hbs | 4 +- ui-v2/tests/acceptance/dc/acls/index.feature | 14 ++++++ .../acceptance/steps/dc/acls/index-steps.js | 10 +++++ ui-v2/tests/pages/dc/acls/index.js | 2 +- ui-v2/tests/pages/dc/kv/index.js | 2 +- ui-v2/tests/steps.js | 43 ++++++++++++++++++- 7 files changed, 74 insertions(+), 9 deletions(-) create mode 100644 ui-v2/tests/acceptance/dc/acls/index.feature create mode 100644 ui-v2/tests/acceptance/steps/dc/acls/index-steps.js diff --git a/ui-v2/app/templates/dc/acls/index.hbs b/ui-v2/app/templates/dc/acls/index.hbs index b0c032328..f4668373c 100644 --- a/ui-v2/app/templates/dc/acls/index.hbs +++ b/ui-v2/app/templates/dc/acls/index.hbs @@ -39,17 +39,17 @@ {{#action-group index=index onchange=(action change) checked=(if (eq checked index) 'checked')}} diff --git a/ui-v2/app/templates/dc/kv/index.hbs b/ui-v2/app/templates/dc/kv/index.hbs index 6db169a64..a7822eda6 100644 --- a/ui-v2/app/templates/dc/kv/index.hbs +++ b/ui-v2/app/templates/dc/kv/index.hbs @@ -51,10 +51,10 @@ {{#action-group index=index onchange=(action change) checked=(if (eq checked index) 'checked')}} {{/action-group}} diff --git a/ui-v2/tests/acceptance/dc/acls/index.feature b/ui-v2/tests/acceptance/dc/acls/index.feature new file mode 100644 index 000000000..bf0e8b163 --- /dev/null +++ b/ui-v2/tests/acceptance/dc/acls/index.feature @@ -0,0 +1,14 @@ +@setupApplicationTest +Feature: dc / acls / index: ACL List + + Scenario: + Given 1 datacenter model with the value "dc-1" + And 3 acl models + When I visit the acls page for yaml + --- + dc: dc-1 + --- + Then the url should be /dc-1/acls + And I click actions on the acls + Then I don't see delete on the acls + Then I see 3 acl models diff --git a/ui-v2/tests/acceptance/steps/dc/acls/index-steps.js b/ui-v2/tests/acceptance/steps/dc/acls/index-steps.js new file mode 100644 index 000000000..a7eff3228 --- /dev/null +++ b/ui-v2/tests/acceptance/steps/dc/acls/index-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/pages/dc/acls/index.js b/ui-v2/tests/pages/dc/acls/index.js index 7b03bb758..8b3c60cc5 100644 --- a/ui-v2/tests/pages/dc/acls/index.js +++ b/ui-v2/tests/pages/dc/acls/index.js @@ -7,7 +7,7 @@ export default create({ name: attribute('data-test-acl', '[data-test-acl]'), acl: clickable('a'), actions: clickable('label'), - delete: clickable('li:last-child a'), + delete: clickable('[data-test-delete]'), confirmDelete: clickable('button.type-delete'), }), filter: filter, diff --git a/ui-v2/tests/pages/dc/kv/index.js b/ui-v2/tests/pages/dc/kv/index.js index 08c223778..446122e6c 100644 --- a/ui-v2/tests/pages/dc/kv/index.js +++ b/ui-v2/tests/pages/dc/kv/index.js @@ -6,7 +6,7 @@ export default create({ name: attribute('data-test-kv', '[data-test-kv]'), kv: clickable('a'), actions: clickable('label'), - delete: clickable('li:last-child a'), + delete: clickable('[data-test-delete]'), confirmDelete: clickable('button.type-delete'), }), }); diff --git a/ui-v2/tests/steps.js b/ui-v2/tests/steps.js index 98208ac03..4a429f6bb 100644 --- a/ui-v2/tests/steps.js +++ b/ui-v2/tests/steps.js @@ -227,7 +227,48 @@ export default function(assert) { }); }) .then(['I see $property on the $component'], function(property, component) { - assert.ok(currentPage[component][property], `Expected to see ${property} on ${component}`); + // TODO: Time to work on repetition + // Collection + var obj; + if (typeof currentPage[component].objectAt === 'function') { + obj = currentPage[component].objectAt(0); + } else { + obj = currentPage[component]; + } + let _component; + if (typeof obj === 'function') { + const func = obj[property].bind(obj); + try { + _component = func(); + } catch (e) { + console.error(e); + throw new Error( + `The '${property}' property on the '${component}' page object doesn't exist` + ); + } + } else { + _component = obj; + } + assert.ok(_component[property], `Expected to see ${property} on ${component}`); + }) + .then(["I don't see $property on the $component"], function(property, component) { + // Collection + var obj; + if (typeof currentPage[component].objectAt === 'function') { + obj = currentPage[component].objectAt(0); + } else { + obj = currentPage[component]; + } + const func = obj[property].bind(obj); + assert.throws( + function() { + func(); + }, + function(e) { + return e.toString().indexOf('Element not found') !== -1; + }, + `Expected to not see ${property} on ${component}` + ); }) .then(['I see $property'], function(property, component) { assert.ok(currentPage[property], `Expected to see ${property}`);