Skip to content

Commit

Permalink
update test for modern times, prevent false failures
Browse files Browse the repository at this point in the history
Change-Id: I8f64b02b3dc69e6f03f1617e29c39a5d65a868c4
  • Loading branch information
cmcmahon committed Dec 13, 2013
1 parent e2253b7 commit 0bdf8cc
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 72 deletions.
2 changes: 1 addition & 1 deletion features/page.feature
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,5 @@ Feature: Page
Then I should be on a page that says has been moved
And I should see the text A redirect has been created
And I should have a link to the old page title and a link to the new page title
And the the new page should have the correct text
And the new page should have the correct text
And the old page should display a redirect to the new page
151 changes: 80 additions & 71 deletions features/step_definitions/page_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,62 +13,65 @@
visit(DoesNotExistPage, using_params: {page_name: @random_string})
end

When(/^I click link Create source$/) do
on(DoesNotExistPage).create_source
end
When(/^I click Save page button$/) do
on(EditPage).save_element.when_present.click
end
When(/^I enter article text$/) do
on(EditPage) do |page|
page.article_text_element.when_present.click
page.article_text = "Starting a new page using the URL"
end
Given(/^I am starting a page to be moved$/) do
visit(DoesNotExistPage, using_params: {page_name: @random_string})
end

Then(/^Discussion link should be there$/) do
on(ArticlePage).discussion_element.should exist
end
Then(/^link Create should be there$/) do
on(DoesNotExistPage).create_source_element.should exist
Given(/^I am starting a page to be moved to a new name$/) do
visit(DoesNotExistPage, using_params: {page_name: @random_string})
end
Then(/^newly created page should open$/) do
@browser.url.should match Regexp.escape(@random_string)

Given(/^I create the page to be moved$/) do
step "I click link Create source"
step "I enter article text"
step "I click Save page button"
end
Then(/^page text should be there$/) do
on(ArticlePage).page_text.should match Regexp.escape("Starting a new page using the URL")

Given(/^I have clicked Move on the newly created page$/) do
step "I click link Create source"
step "I enter article text"
step "I click Save page button"
step "I click Move"
end
Then(/^page text should contain (.+)$/) do |text|
on(DoesNotExistPage).page_text.should match Regexp.escape(text)

When(/^I click link Create source$/) do
on(DoesNotExistPage).create_source_element.when_present.click
end
Then(/^page title should be there$/) do
on(ArticlePage).title.should match Regexp.escape(@random_string)

When(/^I click Move$/) do
on(ArticlePage) do |page|
page.actions_link
page.move_link
end
end
Then(/^text box with page text should be there$/) do
on(EditPage).article_text_element.should exist

When(/^I click Move page$/) do
on(MovePage).move_page
end
Then(/^watch element should not be there$/) do
on(ArticlePage).watch_element.should_not exist

When(/^I click Save page button$/) do
on(EditPage).save_element.when_present.click
end

Then(/^unwatch element should be there$/) do
on(ArticlePage).unwatch_element.should exist
When(/^I enter article text$/) do
on(EditPage) do |page|
page.article_text_element.when_present.click
page.article_text = "Starting a new page using the URL"
end
end

Given(/^I am starting a page to be moved$/) do
visit(DoesNotExistPage, using_params: {page_name: @random_string})
When(/^I make a new page name for the moved page$/) do
on(MovePage).new_title="#{@random_string} Moved"
end

Given(/^I create the page to be moved$/) do
step "I click link Create source"
step "I enter article text"
step "I click Save page button"
Then(/^Discussion link should be there$/) do
on(ArticlePage).discussion_element.when_present.should be_visible
end

When(/^I click Move$/) do
on(ArticlePage) do |page|
page.actions_link
page.move_link
Then(/^I should have a link to the old page title and a link to the new page title$/) do
on(MovePage) do |page|
page.old_page_link_element(@random_string).when_present.should be_visible
page.moved_page_link_element(@random_string).when_present.should be_visible
end
end

Expand All @@ -77,61 +80,59 @@
on(ArticlePage).page_text.should match Regexp.escape("Move page: #{@random_string}")
end

Then(/^I should see a Namespace selectbox$/) do
on(MovePage).namespace_element.should exist
Then(/^I should be on a page that says (.+)$/) do |success_message|
on(ArticlePage).page_text.should match Regexp.escape(success_message)
end

Then(/^I should see a To new title textbox$/) do
on(MovePage).new_title_element.should exist
Then(/^I should see the text A redirect has been created$/) do
on(ArticlePage).page_text.should match Regexp.escape("A redirect has been created")
end

Then(/^I should see a Reason textarea$/) do
on(MovePage).reason_element.should exist
Then(/^I should see a Leave a redirect radio button$/) do
on(MovePage).leave_redirect_element.should be_visible
end

Then(/^I should see a Leave a redirect radio button$/) do
on(MovePage).leave_redirect_element.should exist
Then(/^I should see a Namespace selectbox$/) do
on(MovePage).namespace_element.should be_visible
end

Then(/^I should see a Watch source page radio button$/) do
on(MovePage).watch_source_element.should exist
Then(/^I should see a Reason textarea$/) do
on(MovePage).reason_element.should be_visible
end

Given(/^I am starting a page to be moved to a new name$/) do
visit(DoesNotExistPage, using_params: {page_name: @random_string})
Then(/^I should see a To new title textbox$/) do
on(MovePage).new_title_element.should be_visible
end

Given(/^I have clicked Move on the newly created page$/) do
step "I click link Create source"
step "I enter article text"
step "I click Save page button"
step "I click Move"
Then(/^I should see a Watch source page radio button$/) do
on(MovePage).watch_source_element.should be_visible
end

When(/^I make a new page name for the moved page$/) do
on(MovePage).new_title="#{@random_string} Moved"
Then(/^link Create should be there$/) do
on(DoesNotExistPage).create_source_element.when_present.should be_visible
end

When(/^I click Move page$/) do
on(MovePage).move_page
Then(/^newly created page should open$/) do
@browser.url.should match Regexp.escape(@random_string)
end

Then(/^I should be on a page that says (.+)$/) do |success_message|
on(ArticlePage).page_text.should match Regexp.escape(success_message)
Then(/^page text should be there$/) do
on(ArticlePage).page_text.should match Regexp.escape("Starting a new page using the URL")
end

Then(/^I should have a link to the old page title and a link to the new page title$/) do
on(MovePage) do |page|
page.old_page_link_element(@random_string).when_present.should exist
page.moved_page_link_element(@random_string).when_present.should exist
end
Then(/^page text should contain (.+)$/) do |text|
on(DoesNotExistPage).page_text.should match Regexp.escape(text)
end

Then(/^I should see the text A redirect has been created$/) do
on(ArticlePage).page_text.should match Regexp.escape("A redirect has been created")
Then(/^page title should be there$/) do
on(ArticlePage).title.should match Regexp.escape(@random_string)
end

Then(/^the the new page should have the correct text$/) do
Then(/^text box with page text should be there$/) do
on(EditPage).article_text_element.should be_visible
end

Then(/^the new page should have the correct text$/) do
on(MovePage) do |page|
page.old_page_link_element(@random_string).when_present.click
page.redirect_content.should match(/Redirect page/)
Expand All @@ -145,3 +146,11 @@
page.body_content.should_not match(/Redirect page/)
end
end

Then(/^unwatch element should be there$/) do
on(ArticlePage).unwatch_element.when_present.should be_visible
end

Then(/^watch element should not be there$/) do
on(ArticlePage).watch_element.should_not be_visible
end

0 comments on commit 0bdf8cc

Please sign in to comment.