From 1a16b5aa9ef7141d67ef2625a95a35ff559744ef Mon Sep 17 00:00:00 2001 From: cmcmahon Date: Mon, 5 May 2014 12:10:47 -0700 Subject: [PATCH] [browser test] refactor bullets test to use API etc. Get rid of all hard-coded values for both the target page and also the text on the target page, which is now all set in the .feature file. Note that we're deconstructing the @make_selectable hook by doing this. @make_selectable may become obsolete when all the tests are refactored to use APIPage Change-Id: Iad1b160d9d0274effb8504f276bd4816932d299c --- .../test/browser/features/bullets.feature | 6 ++++- .../step_definitions/bullets_steps.rb | 26 ++++++++++++------- .../features/step_definitions/shared_steps.rb | 12 +++++++++ .../support/pages/visual_editor_page.rb | 1 + .../features/support/pages/zarticlepage.rb | 5 ++++ 5 files changed, 39 insertions(+), 11 deletions(-) create mode 100644 modules/ve-mw/test/browser/features/support/pages/zarticlepage.rb diff --git a/modules/ve-mw/test/browser/features/bullets.feature b/modules/ve-mw/test/browser/features/bullets.feature index ac5a29f6c7..89bff7f900 100644 --- a/modules/ve-mw/test/browser/features/bullets.feature +++ b/modules/ve-mw/test/browser/features/bullets.feature @@ -1,6 +1,10 @@ -@en.wikipedia.beta.wmflabs.org @firefox @login @make_selectable_line @test2.wikipedia.org +@en.wikipedia.beta.wmflabs.org @firefox @login @test2.wikipedia.org Feature: VisualEditor Bullets, Numbering + Background: + Given I go to the "Bullets VisualEditor Test" page with content "Bullets VisualEditor Test" + And I make the text "Bullets VisualEditor Test" be selected + Scenario Outline: check strings for bullets and numbering When I click And I click Save page diff --git a/modules/ve-mw/test/browser/features/step_definitions/bullets_steps.rb b/modules/ve-mw/test/browser/features/step_definitions/bullets_steps.rb index 742eb7a00c..50e27e8190 100644 --- a/modules/ve-mw/test/browser/features/step_definitions/bullets_steps.rb +++ b/modules/ve-mw/test/browser/features/step_definitions/bullets_steps.rb @@ -1,3 +1,9 @@ +Given(/^I go to the "(.+)" page with content "(.+)"$/) do |page_title, page_content| + @wikitext = page_content + on(APIPage).create page_title, page_content + step "I am on the #{page_title} page" +end + Given(/^I close the VE information window$/) do pending # express the regexp above with the code you wish you had end @@ -24,9 +30,9 @@ end Then(/^a \# is added in front of input string in the diff view$/) do on(VisualEditorPage) do |page| page.wait_until(10) do - page.diff_view.include? "# This " + page.diff_view.include? "# #{@wikitext}" end - page.diff_view.should match Regexp.new(/^\# This is a new line/) + page.diff_view.should match Regexp.new(/^\# #{@wikitext}/) end end @@ -37,9 +43,9 @@ end Then(/^a \* is added in front of input string in the diff view$/) do on(VisualEditorPage) do |page| page.wait_until(10) do - page.diff_view.include? "* This " + page.diff_view.include? "* #{@wikitext}" end - page.diff_view.should match Regexp.new(/^\* This is a new line/) + page.diff_view.should match Regexp.new(/^\* #{@wikitext}/) end end @@ -50,18 +56,18 @@ end Then(/^a \#\# is added in front of input string in the diff view$/) do on(VisualEditorPage) do |page| page.wait_until(10) do - page.diff_view.include? "## This " + page.diff_view.include? "## #{@wikitext}" end - page.diff_view.should match Regexp.new(/^\#\# This is a new line/) + page.diff_view.should match Regexp.new(/^\#\# #{@wikitext}/) end end Then(/^a \*\* is added in front of input string in the diff view$/) do on(VisualEditorPage) do |page| page.wait_until(10) do - page.diff_view.include? "** This " + page.diff_view.include? "** #{@wikitext}" end - page.diff_view.should match Regexp.new(/^\*\* This is a new line/) + page.diff_view.should match Regexp.new(/^\*\* #{@wikitext}/) end end @@ -73,9 +79,9 @@ end Then(/^nothing is added in front of input string in the diff view$/) do on(VisualEditorPage) do |page| page.wait_until(10) do - page.diff_view.include? "This " + page.review_failed_element.when_present.text.include? "No changes to review" end - page.diff_view.should match Regexp.new(/^This is a new line/) + page.review_failed_element.when_present.text.should match "No changes to review" end end diff --git a/modules/ve-mw/test/browser/features/step_definitions/shared_steps.rb b/modules/ve-mw/test/browser/features/step_definitions/shared_steps.rb index 2a8c5bf751..b9c4193afa 100644 --- a/modules/ve-mw/test/browser/features/step_definitions/shared_steps.rb +++ b/modules/ve-mw/test/browser/features/step_definitions/shared_steps.rb @@ -2,6 +2,18 @@ Given(/^I am at my user page$/) do visit(VisualEditorPage) end +Given(/^I am on the (.+) page$/) do |article| + article = article.gsub(/ /, '_') + visit(ZtargetPage, :using_params => {:article_name => article}) +end + +Given(/^I make the text "(.*?)" be selected$/) do |select_text| + on(VisualEditorPage).content_element.when_present.click + require "watir-webdriver/extensions/select_text" + on(VisualEditorPage).content_element.when_present.select_text select_text + sleep 1 # turn the sleep on if this test fails with bullet/number in front of string NOT "This is.." +end + When(/^I click Review and Save$/) do on(VisualEditorPage) do |page| page.container_disabled_element.when_not_visible.should_not exist diff --git a/modules/ve-mw/test/browser/features/support/pages/visual_editor_page.rb b/modules/ve-mw/test/browser/features/support/pages/visual_editor_page.rb index 08fc8dd85e..3df73df695 100644 --- a/modules/ve-mw/test/browser/features/support/pages/visual_editor_page.rb +++ b/modules/ve-mw/test/browser/features/support/pages/visual_editor_page.rb @@ -86,6 +86,7 @@ class VisualEditorPage a(:remove_template, title: "Remove template", frame: frame) span(:return_to_save, class: "oo-ui-labeledElement-label", text: "Return to save form", frame: frame) span(:review_changes, class: "oo-ui-labeledElement-label", text: "Review your changes", frame: frame) + div(:review_failed, class: "oo-ui-window-title", frame: frame) span(:second_save_page, class: "oo-ui-labeledElement-label", text: "Save page", frame: frame) unordered_list(:suggestion_list, class: "ve-ui-mwTitleInputWidget-menu", frame: frame) div(:template_header, class: "ve-ui-mwTransclusionDialog-single", frame: frame) diff --git a/modules/ve-mw/test/browser/features/support/pages/zarticlepage.rb b/modules/ve-mw/test/browser/features/support/pages/zarticlepage.rb new file mode 100644 index 0000000000..cedd007523 --- /dev/null +++ b/modules/ve-mw/test/browser/features/support/pages/zarticlepage.rb @@ -0,0 +1,5 @@ +class ZtargetPage < VisualEditorPage + include URL + page_url URL.url("<%=params[:article_name]%>?vehidebetadialog=true&veaction=edit") + include PageObject +end