-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add new codemirror helpers * adding json helpers to the secret pages * mark the edit button / link as the edit element instead of the json toggle * add acceptance tests for JSON editing
- Loading branch information
Showing
6 changed files
with
82 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const invariant = (truthy, error) => { | ||
if (!truthy) throw new Error(error); | ||
}; | ||
|
||
export default function(context, selector) { | ||
let cmService = context.owner.lookup('service:code-mirror'); | ||
|
||
let element = document.querySelector(selector); | ||
invariant(element, `Selector ${selector} matched no elements`); | ||
|
||
let cm = cmService.instanceFor(element.id); | ||
invariant(cm, `No registered CodeMirror instance for ${selector}`); | ||
|
||
return cm; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import getCodeMirrorInstance from 'vault/tests/helpers/codemirror'; | ||
// Like fillable, but for the CodeMirror editor | ||
// | ||
// Usage: fillIn: codeFillable('[data-test-editor]') | ||
// Page.fillIn(code); | ||
export function codeFillable(selector) { | ||
return { | ||
isDescriptor: true, | ||
|
||
get() { | ||
return function(context, code) { | ||
const cm = getCodeMirrorInstance(context, selector); | ||
cm.setValue(code); | ||
return this; | ||
}; | ||
}, | ||
}; | ||
} | ||
|
||
// Like text, but for the CodeMirror editor | ||
// | ||
// Usage: content: code('[data-test-editor]') | ||
// Page.code(); // some = [ 'string', 'of', 'code' ] | ||
export function code(selector) { | ||
return { | ||
isDescriptor: true, | ||
get() { | ||
return function(context) { | ||
const cm = getCodeMirrorInstance(context, selector); | ||
return cm.getValue(); | ||
}; | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
import { Base } from '../show'; | ||
import { create, clickable, collection, isPresent } from 'ember-cli-page-object'; | ||
import { code } from 'vault/tests/pages/helpers/codemirror'; | ||
|
||
export default create({ | ||
...Base, | ||
rows: collection('data-test-row-label'), | ||
edit: clickable('[data-test-secret-json-toggle]'), | ||
editIsPresent: isPresent('[data-test-secret-json-toggle]'), | ||
toggleJSON: clickable('[data-test-secret-json-toggle]'), | ||
toggleIsPresent: isPresent('[data-test-secret-json-toggle]'), | ||
edit: clickable('[data-test-secret-edit]'), | ||
editIsPresent: isPresent('[data-test-secret-edit]'), | ||
editor: { | ||
content: code('[data-test-component="json-editor"]'), | ||
}, | ||
}); |