From b645a88adeb56576a026be674357e3d57ede176d Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 12 Sep 2016 15:25:03 +0200 Subject: [PATCH] Stabilize :insert-text tests With QtWebEngine, inserting text into the field is async, so if our test runs too fast, it would fail. Now we instead log stuff via JS on changes insteaad, and wait for those log messages in the tests. --- tests/end2end/data/paste_primary.html | 16 +++++++++++++++- tests/end2end/features/test_yankpaste_bdd.py | 11 ++--------- tests/end2end/features/yankpaste.feature | 16 ++++++++++------ 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/tests/end2end/data/paste_primary.html b/tests/end2end/data/paste_primary.html index 4f803aedf..f5a27650f 100644 --- a/tests/end2end/data/paste_primary.html +++ b/tests/end2end/data/paste_primary.html @@ -3,8 +3,22 @@ Paste primary selection + - + diff --git a/tests/end2end/features/test_yankpaste_bdd.py b/tests/end2end/features/test_yankpaste_bdd.py index 72c19830c..a07315df8 100644 --- a/tests/end2end/features/test_yankpaste_bdd.py +++ b/tests/end2end/features/test_yankpaste_bdd.py @@ -33,12 +33,5 @@ def init_fake_clipboard(quteproc): @bdd.when(bdd.parsers.parse('I set the text field to "{value}"')) def set_text_field(quteproc, value): - quteproc.send_cmd(":jseval document.getElementById('qute-textarea').value " - "= '{}';".format(value)) - - -@bdd.then(bdd.parsers.parse('the text field should contain "{value}"')) -def check_text_field(quteproc, value): - quteproc.send_cmd(":jseval console.log('text: ' + " - "document.getElementById('qute-textarea').value);") - quteproc.wait_for_js('text: ' + value) + quteproc.send_cmd(":jseval set_text('{}')".format(value)) + quteproc.wait_for_js('textarea set to: ' + value) diff --git a/tests/end2end/features/yankpaste.feature b/tests/end2end/features/yankpaste.feature index 667905100..abb59ad47 100644 --- a/tests/end2end/features/yankpaste.feature +++ b/tests/end2end/features/yankpaste.feature @@ -230,15 +230,17 @@ Feature: Yanking and pasting. #### :insert-text Scenario: Inserting text into an empty text field - When I open data/paste_primary.html + When I set general -> log-javascript-console to info + And I open data/paste_primary.html And I run :click-element id qute-textarea And I wait for "Clicked editable element!" in the log And I run :insert-text Hello world # Compare - Then the text field should contain "Hello world" + Then the javascript message "textarea contents: Hello world" should be logged Scenario: Inserting text into a text field at specific position - When I open data/paste_primary.html + When I set general -> log-javascript-console to info + And I open data/paste_primary.html And I set the text field to "one two three four" And I run :click-element id qute-textarea And I wait for "Clicked editable element!" in the log @@ -248,20 +250,22 @@ Feature: Yanking and pasting. And I press the key "" And I run :insert-text Hello world # Compare - Then the text field should contain "onHello worlde two three four" + Then the javascript message "textarea contents: onHello worlde two three four" should be logged @qtwebengine_osx_xfail Scenario: Inserting text into a text field with undo - When I open data/paste_primary.html + When I set general -> log-javascript-console to info + And I open data/paste_primary.html And I run :click-element id qute-textarea And I wait for "Clicked editable element!" in the log # Paste and undo And I run :insert-text This text should be undone + And I wait for the javascript message "textarea contents: This text should be undone" And I press the key "" # Paste final text And I run :insert-text This text should stay # Compare - Then the text field should contain "This text should stay" + Then the javascript message "textarea contents: This text should stay" should be logged Scenario: Inserting text without a focused field When I open data/paste_primary.html