diff --git a/tests/end2end/data/editor.html b/tests/end2end/data/editor.html new file mode 100644 index 000000000..11f43463d --- /dev/null +++ b/tests/end2end/data/editor.html @@ -0,0 +1,17 @@ + + + + + Textarea + + + + + + + diff --git a/tests/end2end/features/editor.feature b/tests/end2end/features/editor.feature index 8bb48926f..3af4883a6 100644 --- a/tests/end2end/features/editor.feature +++ b/tests/end2end/features/editor.feature @@ -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 diff --git a/tests/end2end/features/test_editor_bdd.py b/tests/end2end/features/test_editor_bdd.py index 7b400705f..a4718ecc0 100644 --- a/tests/end2end/features/test_editor_bdd.py +++ b/tests/end2end/features/test_editor_bdd.py @@ -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)