bdd: Add test for spawning an external editor
This commit is contained in:
parent
753036067d
commit
3cfb430cdf
17
tests/end2end/data/editor.html
Normal file
17
tests/end2end/data/editor.html
Normal file
@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Textarea</title>
|
||||
<script type="text/javascript">
|
||||
function log_text() {
|
||||
elem = document.getElementById("qute-textarea");
|
||||
console.log("text: " + elem.value);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<textarea id="qute-textarea"></textarea>
|
||||
<input type="button" onclick="log_text()" value="Log text">
|
||||
</body>
|
||||
</html>
|
@ -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 / 'script.py'
|
||||
script.write(textwrap.dedent("""
|
||||
import sys
|
||||
|
||||
with open(sys.argv[1], 'w', encoding='utf-8') as f:
|
||||
f.write({text!r})
|
||||
""".format(text=text)))
|
||||
editor = '"{}" "{}" {{}}'.format(sys.executable, script)
|
||||
quteproc.set_setting('general', 'editor', editor)
|
||||
|
Loading…
Reference in New Issue
Block a user