jenkins-bot has submitted this change and it was merged.

Change subject: QA: refactor VE editing
......................................................................


QA: refactor VE editing

Using the type_into method in this way causes a couple of issues:

* one is that it is only used once and so no need to abstract it
* another is that having steps before expectations breaks the
Given/When/Then intended to be used. This is also the source
of the stale elements noted below.
* because of how the page is (re)used, Selenium sometimes encounters
stale elements [1]
* and sending a space to VE fixes a Selenium-Firefox problem [2]

[1] 
https://integration.wikimedia.org/ci/view/BrowserTests/view/-All/job/browsertests-MobileFrontend-en.m.wikipedia.beta.wmflabs.org-linux-chrome-sauce/207/testReport/junit/(root)/VisualEditor%20Mobile/I_can_edit_a_page_using_VisualEditor/

[2] 
https://integration.wikimedia.org/ci/view/BrowserTests/view/-All/job/browsertests-MobileFrontend-en.m.wikipedia.beta.wmflabs.org-linux-firefox-sauce/243/testReport/(root)/VisualEditor%20Mobile/I_can_edit_a_page_using_VisualEditor/

Change-Id: I3294e5a35873d6bd528dd8bd5df04d35c3b1070c
---
M tests/browser/features/step_definitions/editor_ve_steps.rb
M tests/browser/features/support/pages/article_page.rb
2 files changed, 8 insertions(+), 25 deletions(-)

Approvals:
  Dduvall: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/tests/browser/features/step_definitions/editor_ve_steps.rb 
b/tests/browser/features/step_definitions/editor_ve_steps.rb
index 9906265..34bc80f 100644
--- a/tests/browser/features/step_definitions/editor_ve_steps.rb
+++ b/tests/browser/features/step_definitions/editor_ve_steps.rb
@@ -30,24 +30,21 @@
 
 When(/^I edit the article using VisualEditor$/) do
   on(ArticlePage) do |page|
-    @article_text = page.type_into(:editor_ve)
-
-    expect(page.editor_ve).to include(@article_text)
-
+    @text_to_type = "text-#{rand(32 ** 8).to_s(32)}"
+    page.editor_ve_element.when_present.send_keys(" ")
+    page.editor_ve_element.send_keys(@text_to_type)
     page.wait_until { page.continue_button_element.enabled? }
     page.continue_button
-
     page.wait_until { page.submit_button_element.enabled? }
     page.confirm(true) { page.submit_button }
+    page.wait_until { page.toast.include?("Your edit was saved") }
+    page.wait_until { page.content_element.visible? }
   end
 end
 
 Then(/^I see the edit reflected in the article content$/) do
   on(ArticlePage) do |page|
-    page.wait_until { page.toast.include?("Your edit was saved") }
-    page.wait_until { page.content_element.visible? }
-
-    expect(page.content).to include(@article_text)
+    expect(page.content).to include(@text_to_type)
   end
 end
 
@@ -57,5 +54,4 @@
 
 Then(/^I no longer see the VisualEditor$/) do
   expect(on(ArticlePage).editor_ve_element).to_not exist
-end
-
+end
\ No newline at end of file
diff --git a/tests/browser/features/support/pages/article_page.rb 
b/tests/browser/features/support/pages/article_page.rb
index 5a8417b..33cf319 100644
--- a/tests/browser/features/support/pages/article_page.rb
+++ b/tests/browser/features/support/pages/article_page.rb
@@ -165,17 +165,4 @@
   # error and warning boxes
   div(:warning_box, css: ".warning")
   div(:error_message, css: ".error")
-
-  # Enters the given or random text into the given element. Note that a click
-  # event is used over focus to properly handle content-editable elements.
-  #
-  def type_into(element_name, text = nil)
-    text ||= "text-#{rand(32 ** 8).to_s(32)}"
-
-    element = send("#{element_name}_element")
-    element.click
-    element.send_keys(:enter, text)
-
-    text
-  end
-end
+end
\ No newline at end of file

-- 
To view, visit https://gerrit.wikimedia.org/r/160995
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I3294e5a35873d6bd528dd8bd5df04d35c3b1070c
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Cmcmahon <[email protected]>
Gerrit-Reviewer: Awjrichards <[email protected]>
Gerrit-Reviewer: Cmcmahon <[email protected]>
Gerrit-Reviewer: Dduvall <[email protected]>
Gerrit-Reviewer: JGonera <[email protected]>
Gerrit-Reviewer: Zfilipin <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to