From d5a60fdd43f8558cf20e5d7b12a761598b3a5656 Mon Sep 17 00:00:00 2001 From: jdlrobson Date: Thu, 27 Jul 2017 13:36:04 -0700 Subject: [PATCH] Browser tests: Use generic toast step Introduces a new generic "I should see a toast with message ".*"" step reducing toast steps to two generic ones. Change-Id: Ic8b91c78f6df088244f15223ee4ed658847a05b5 --- tests/browser/features/language.feature | 2 +- tests/browser/features/search_loggedin.feature | 2 +- .../step_definitions/common_article_steps.rb | 5 +++++ .../features/step_definitions/language_steps.rb | 4 ---- .../features/step_definitions/search_steps.rb | 4 ---- .../features/step_definitions/watchstar_steps.rb | 13 ------------- tests/browser/features/watchstar.feature | 4 ++-- 7 files changed, 9 insertions(+), 25 deletions(-) diff --git a/tests/browser/features/language.feature b/tests/browser/features/language.feature index 454d96a..f45a064 100644 --- a/tests/browser/features/language.feature +++ b/tests/browser/features/language.feature @@ -27,7 +27,7 @@ Feature: Language selection Scenario: Tapping the disabled icon shows a toast Given I go to a page that does not have languages When I click the switch-language page action - Then I should see a toast with message about page not being available in other languages + Then I should see a toast with message "This page is not available in other languages." Scenario: Closing language overlay (overlay button) Given I go to a page that has languages diff --git a/tests/browser/features/search_loggedin.feature b/tests/browser/features/search_loggedin.feature index 52cc5e9..291fe8e 100644 --- a/tests/browser/features/search_loggedin.feature +++ b/tests/browser/features/search_loggedin.feature @@ -12,4 +12,4 @@ Feature: Search And I see the search overlay And I type into search box "Selenium search tes" When I click a search watch star - Then I should see a toast + Then I should see a toast notification diff --git a/tests/browser/features/step_definitions/common_article_steps.rb b/tests/browser/features/step_definitions/common_article_steps.rb index 93baaa8..0e89e9e 100644 --- a/tests/browser/features/step_definitions/common_article_steps.rb +++ b/tests/browser/features/step_definitions/common_article_steps.rb @@ -30,6 +30,11 @@ Then(/^I should see a toast notification$/) do expect(on(ArticlePage).toast_element.when_present(10)).to be_visible end +Then(/^I should see a toast with message "(.+)"$/) do |msg| + step "I should see a toast notification" + expect(on(ArticlePage).toast_element.when_present.text).to match msg +end + Then /^I should see a drawer with message "(.+)"$/ do |text| expect(on(ArticlePage).drawer_element.when_present.text).to match text end diff --git a/tests/browser/features/step_definitions/language_steps.rb b/tests/browser/features/step_definitions/language_steps.rb index 2b8eb30..676f917 100644 --- a/tests/browser/features/step_definitions/language_steps.rb +++ b/tests/browser/features/step_definitions/language_steps.rb @@ -10,10 +10,6 @@ When /^I click on a language from the list of all languages$/ do on(ArticlePage).non_suggested_language_link_element.when_present.click end -Then(/^I should see a toast with message about page not being available in other languages$/) do - expect(on(ArticlePage).toast_element.when_present.text).to match 'This page is not available in other languages.' -end - Then(/^I should not see the languages overlay$/) do expect(on(ArticlePage).overlay_languages_element).not_to be_visible end diff --git a/tests/browser/features/step_definitions/search_steps.rb b/tests/browser/features/step_definitions/search_steps.rb index bd89290..3420aac 100644 --- a/tests/browser/features/step_definitions/search_steps.rb +++ b/tests/browser/features/step_definitions/search_steps.rb @@ -78,7 +78,3 @@ end Then(/^I should not see '#\/search' in URL$/) do expect(on(ArticlePage).current_url.end_with? '#/search').to be false end - -Then(/^I should see a toast$/) do - expect(on(ArticlePage).toast_element.when_present).to be_visible -end diff --git a/tests/browser/features/step_definitions/watchstar_steps.rb b/tests/browser/features/step_definitions/watchstar_steps.rb index c6366e2..10f5bdd 100644 --- a/tests/browser/features/step_definitions/watchstar_steps.rb +++ b/tests/browser/features/step_definitions/watchstar_steps.rb @@ -9,16 +9,3 @@ Given(/^I am viewing an unwatched page$/) do api.unwatch_page 'Selenium mobile watch test' step 'I am on the "Selenium mobile watch test" page' end - -Then(/^I should see a toast with message about watching the page$/) do - expect(on(ArticlePage).toast_element.when_present.text).to match 'Added Selenium mobile watch test to your watchlist' -end - -Then(/^I should see a toast with message about unwatching the page$/) do - on(ArticlePage) do |page| - page.wait_until do - page.text.include? 'Removed' # Chrome needs this, FF does not - end - expect(page.toast_element.when_present.text).to match 'Removed Selenium mobile watch test from your watchlist' - end -end diff --git a/tests/browser/features/watchstar.feature b/tests/browser/features/watchstar.feature index e756399..76ef5b0 100644 --- a/tests/browser/features/watchstar.feature +++ b/tests/browser/features/watchstar.feature @@ -7,11 +7,11 @@ Feature: Manage Watchlist Scenario: Add an article to the watchlist Given I am viewing an unwatched page When I click the watch star - Then I should see a toast with message about watching the page + Then I should see a toast with "Added Selenium mobile watch test to your watchlist" And the watch star should be selected Scenario: Remove an article from the watchlist Given I am viewing a watched page When I click the unwatch star - Then I should see a toast with message about unwatching the page + Then I should see a toast with message "Removed Selenium mobile watch test from your watchlist" And the watch star should not be selected