diff --git a/ui-v2/tests/lib/page-object/visitable.js b/ui-v2/tests/lib/page-object/visitable.js index 5b7d42d7e..c6abebc63 100644 --- a/ui-v2/tests/lib/page-object/visitable.js +++ b/ui-v2/tests/lib/page-object/visitable.js @@ -35,7 +35,22 @@ function appendQueryParams(path, queryParams) { return path; } - +/** + * Custom implementation of `visitable` + * Currently aims to be compatible and as close as possible to the + * actual `ember-cli-page-object` version + * + * Additions: + * 1. Injectable encoder, for when you don't want your segments to be encoded + * or you have specific encoding needs + * Specifically in my case for KV urls where the `Key`/Slug shouldn't be encoded, + * defaults to the browsers `encodeURIComponent` for compatibility and ease. + * 2. `path` can be an array of (string) paths OR a string for compatibility. + * If a path cannot be generated due to a lack of properties on the + * dynamic segment params, if will keep trying 'path' in the array + * until it finds one that it can construct. This follows the same thinking + * as 'if you don't specify an item, then we are looking to create one' + */ export function visitable(path, encoder = encodeURIComponent) { return { isDescriptor: true, diff --git a/ui-v2/tests/pages/dc/acls/edit.js b/ui-v2/tests/pages/dc/acls/edit.js index 4170f45ea..d15301ef4 100644 --- a/ui-v2/tests/pages/dc/acls/edit.js +++ b/ui-v2/tests/pages/dc/acls/edit.js @@ -2,6 +2,7 @@ import { create, clickable, triggerable } from 'ember-cli-page-object'; import { visitable } from 'consul-ui/tests/lib/page-object/visitable'; export default create({ + // custom visitable visit: visitable(['/:dc/acls/:acl', '/:dc/acls/create']), // fillIn: fillable('input, textarea, [contenteditable]'), name: triggerable('keypress', '[name="name"]'), diff --git a/ui-v2/tests/pages/dc/kv/edit.js b/ui-v2/tests/pages/dc/kv/edit.js index 521981a24..c8af7bae0 100644 --- a/ui-v2/tests/pages/dc/kv/edit.js +++ b/ui-v2/tests/pages/dc/kv/edit.js @@ -2,6 +2,7 @@ import { create, clickable } from 'ember-cli-page-object'; import { visitable } from 'consul-ui/tests/lib/page-object/visitable'; export default create({ + // custom visitable visit: visitable(['/:dc/kv/:kv/edit', '/:dc/kv/create'], str => str), // fillIn: fillable('input, textarea, [contenteditable]'), // name: triggerable('keypress', '[name="additional"]'),