Comment up custom visitable and add a couple of comments to be clearer

This commit is contained in:
John Cowen 2018-06-11 17:49:47 +01:00
parent 26e69d2ad1
commit 92fff1f736
3 changed files with 18 additions and 1 deletions

View File

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

View File

@ -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"]'),

View File

@ -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"]'),