[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
This commit is contained in:
cmcmahon 2014-05-05 12:10:47 -07:00 committed by Cmcmahon
parent 0bcab80d2a
commit 1a16b5aa9e
5 changed files with 39 additions and 11 deletions

View file

@ -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 <control>
And I click Save page

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -0,0 +1,5 @@
class ZtargetPage < VisualEditorPage
include URL
page_url URL.url("<%=params[:article_name]%>?vehidebetadialog=true&veaction=edit")
include PageObject
end