Skip to content
Browse files
bdd: Add test for spawning an external editor
  • Loading branch information
The-Compiler committed Jun 6, 2016
1 parent 7530360 commit 3cfb430cdfddb8c0298e091558a7d59cfa5d1521
Showing with 43 additions and 0 deletions.
  1. +17 −0 tests/end2end/data/editor.html
  2. +12 −0 tests/end2end/features/editor.feature
  3. +14 −0 tests/end2end/features/
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<meta charset="utf-8">
<script type="text/javascript">
function log_text() {
elem = document.getElementById("qute-textarea");
console.log("text: " + elem.value);
<textarea id="qute-textarea"></textarea>
<input type="button" onclick="log_text()" value="Log text">
@@ -70,3 +70,15 @@ Feature: Opening external editors
And I set up a fake editor replacing "http://localhost:(port)/data/hello.txt" by "foo!"
And I run :edit-url
Then the error "Invalid URL" should be shown

Scenario: Spawning an editor successfully
When I set up a fake editor returning "foobar"
And I open data/editor.html
And I run :hint all
And I run :follow-hint a
And I wait for "Clicked editable element!" in the log
And I run :open-editor
And I wait for "Read back: foobar" in the log
And I run :hint all
And I run :follow-hint s
Then the javascript message "text: foobar" should be logged
@@ -43,3 +43,17 @@ def set_up_editor_replacement(quteproc, httpbin, tmpdir, text, replacement):
""".format(text=text, replacement=replacement)))
editor = '"{}" "{}" {{}}'.format(sys.executable, script)
quteproc.set_setting('general', 'editor', editor)

@bdd.when(bdd.parsers.parse('I set up a fake editor returning "{text}"'))
def set_up_editor_replacement(quteproc, httpbin, tmpdir, text):
"""Set up general->editor to a small python script inserting a text."""
script = tmpdir / ''
import sys
with open(sys.argv[1], 'w', encoding='utf-8') as f:
editor = '"{}" "{}" {{}}'.format(sys.executable, script)
quteproc.set_setting('general', 'editor', editor)

0 comments on commit 3cfb430

Please sign in to comment.