diff --git a/ui-v2/app/routes/dc/acls/create.js b/ui-v2/app/routes/dc/acls/create.js index ee36d0603..e71a805c1 100644 --- a/ui-v2/app/routes/dc/acls/create.js +++ b/ui-v2/app/routes/dc/acls/create.js @@ -13,6 +13,8 @@ export default Route.extend(WithAclActions, { }, model: function(params) { this.item = get(this, 'repo').create(); + // TODO: Why didn't I have to do this for KV's? + set(this.item, 'Name', ''); set(this.item, 'Datacenter', this.modelFor('dc').dc.Name); return hash({ create: true, diff --git a/ui-v2/app/templates/dc/acls/-form.hbs b/ui-v2/app/templates/dc/acls/-form.hbs index f9ea411ff..2d0ef5edf 100644 --- a/ui-v2/app/templates/dc/acls/-form.hbs +++ b/ui-v2/app/templates/dc/acls/-form.hbs @@ -26,12 +26,13 @@
{{#if create }} - + {{! we only need to check for an empty name here as ember munges autofocus, once we have autofocus back revisit this}} + {{ else }} {{/if}} -{{# if (and item.ID (not-eq item.ID 'anonymous')) }} +{{# if (and (not create) (not-eq item.ID 'anonymous')) }} {{#confirmation-dialog message='Are you sure you want to delete this ACL token?'}} {{#block-slot 'action' as |confirm|}} diff --git a/ui-v2/app/templates/dc/kv/-form.hbs b/ui-v2/app/templates/dc/kv/-form.hbs index 16d7f41bc..630396904 100644 --- a/ui-v2/app/templates/dc/kv/-form.hbs +++ b/ui-v2/app/templates/dc/kv/-form.hbs @@ -24,8 +24,10 @@
{{/if}} + {{!TODO This has a
around it in acls, remove or add for consistency }} {{#if create }} - + {{! we only need to check for an empty keyname here as ember munges autofocus, once we have autofocus back revisit this}} + {{ else }} diff --git a/ui-v2/app/validations/acl.js b/ui-v2/app/validations/acl.js index 876089487..5878e768e 100644 --- a/ui-v2/app/validations/acl.js +++ b/ui-v2/app/validations/acl.js @@ -2,5 +2,4 @@ import { validatePresence, validateLength } from 'ember-changeset-validations/va export default { Name: [validatePresence(true), validateLength({ min: 1 })], Type: validatePresence(true), - ID: validateLength({ min: 1 }), }; diff --git a/ui-v2/tests/acceptance/dc/acls/update.feature b/ui-v2/tests/acceptance/dc/acls/update.feature index 1ca2a9327..77c6417fd 100644 --- a/ui-v2/tests/acceptance/dc/acls/update.feature +++ b/ui-v2/tests/acceptance/dc/acls/update.feature @@ -11,6 +11,7 @@ Feature: dc / acls / update: ACL Update dc: datacenter acl: key --- + Then the url should be /datacenter/acls/key Then I type with yaml --- name: [Name] diff --git a/ui-v2/tests/acceptance/dc/kvs/update.feature b/ui-v2/tests/acceptance/dc/kvs/update.feature index 5eb92fd28..b6a880c8d 100644 --- a/ui-v2/tests/acceptance/dc/kvs/update.feature +++ b/ui-v2/tests/acceptance/dc/kvs/update.feature @@ -11,6 +11,7 @@ Feature: dc / kvs / update: KV Update dc: datacenter kv: [Name] --- + Then the url should be /datacenter/kv/[Name]/edit Then I type with yaml --- value: [Value] diff --git a/ui-v2/tests/acceptance/steps/submit-blank-steps.js b/ui-v2/tests/acceptance/steps/submit-blank-steps.js new file mode 100644 index 000000000..c5f07c804 --- /dev/null +++ b/ui-v2/tests/acceptance/steps/submit-blank-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/acceptance/submit-blank.feature b/ui-v2/tests/acceptance/submit-blank.feature new file mode 100644 index 000000000..a8024a384 --- /dev/null +++ b/ui-v2/tests/acceptance/submit-blank.feature @@ -0,0 +1,24 @@ +@setupApplicationTest +Feature: submit blank + In order to prevent form's being saved without values + As a user + I shouldn't be able to submit a blank form + Scenario: Visiting a blank form for [Model] + Given 1 datacenter model with the value "datacenter" + When I visit the [Model] page for yaml + --- + dc: datacenter + --- + Then the url should be /datacenter/[Slug]/create + And I submit + Then the url should be /datacenter/[Slug]/create + Where: + ------------------ + | Model | Slug | + | kv | kv | + | acl | acls | + ------------------ +@ignore + Scenario: The button is disabled + Then ok + diff --git a/ui-v2/tests/lib/page-object/visitable.js b/ui-v2/tests/lib/page-object/visitable.js index 8c8e985ae..5b7d42d7e 100644 --- a/ui-v2/tests/lib/page-object/visitable.js +++ b/ui-v2/tests/lib/page-object/visitable.js @@ -44,9 +44,22 @@ export function visitable(path, encoder = encodeURIComponent) { let executionContext = getExecutionContext(this); return executionContext.runAsync(context => { - let params = assign({}, dynamicSegmentsAndQueryParams); - let fullPath = fillInDynamicSegments(path, params, encoder); - + var params; + let fullPath = (function _try(paths) { + const path = paths.shift(); + params = assign({}, dynamicSegmentsAndQueryParams); + var fullPath; + try { + fullPath = fillInDynamicSegments(path, params, encoder); + } catch (e) { + if (paths.length > 0) { + fullPath = _try(paths); + } else { + throw e; + } + } + return fullPath; + })(typeof path === 'string' ? [path] : path.slice(0)); fullPath = appendQueryParams(fullPath, params); return context.visit(fullPath); diff --git a/ui-v2/tests/pages/dc/acls/edit.js b/ui-v2/tests/pages/dc/acls/edit.js index 5dbf7dc78..4170f45ea 100644 --- a/ui-v2/tests/pages/dc/acls/edit.js +++ b/ui-v2/tests/pages/dc/acls/edit.js @@ -1,7 +1,8 @@ -import { create, visitable, clickable, triggerable } from 'ember-cli-page-object'; +import { create, clickable, triggerable } from 'ember-cli-page-object'; +import { visitable } from 'consul-ui/tests/lib/page-object/visitable'; export default create({ - visit: visitable('/:dc/acls/:acl'), + visit: visitable(['/:dc/acls/:acl', '/:dc/acls/create']), // fillIn: fillable('input, textarea, [contenteditable]'), name: triggerable('keypress', '[name="name"]'), submit: clickable('[type=submit]'), diff --git a/ui-v2/tests/pages/dc/kv/edit.js b/ui-v2/tests/pages/dc/kv/edit.js index 7915cf179..521981a24 100644 --- a/ui-v2/tests/pages/dc/kv/edit.js +++ b/ui-v2/tests/pages/dc/kv/edit.js @@ -2,7 +2,7 @@ import { create, clickable } from 'ember-cli-page-object'; import { visitable } from 'consul-ui/tests/lib/page-object/visitable'; export default create({ - visit: visitable('/:dc/kv/:kv/edit', str => str), + visit: visitable(['/:dc/kv/:kv/edit', '/:dc/kv/create'], str => str), // fillIn: fillable('input, textarea, [contenteditable]'), // name: triggerable('keypress', '[name="additional"]'), submit: clickable('[type=submit]'), diff --git a/ui-v2/tests/steps.js b/ui-v2/tests/steps.js index 48b68ae99..98208ac03 100644 --- a/ui-v2/tests/steps.js +++ b/ui-v2/tests/steps.js @@ -65,6 +65,8 @@ export default function(assert) { ['I visit the $name page for yaml\n$yaml', 'I visit the $name page for json\n$json'], function(name, data) { currentPage = pages[name]; + // TODO: Consider putting an assertion here for testing the current url + // do I absolutely definitely need that all the time? return pages[name].visit(data); } )