From 568c06a72a16c9dfa4a3cf8e5716bbd2f6a37aed Mon Sep 17 00:00:00 2001 From: Larissa Reis Date: Thu, 15 Jan 2015 22:56:55 -0300 Subject: [PATCH] Adds step definition to select token input search results --- features/events.feature | 4 ++-- features/publish_article.feature | 1 - features/step_definitions/custom_web_steps.rb | 12 ++++++++++++ features/step_definitions/noosfero_steps.rb | 4 ---- features/step_definitions/search_steps.rb | 18 +++++++++--------- 5 files changed, 23 insertions(+), 16 deletions(-) diff --git a/features/events.feature b/features/events.feature index fb6340d..c9815ea 100644 --- a/features/events.feature +++ b/features/events.feature @@ -167,8 +167,8 @@ Feature: events And I go to josesilva's control panel And I follow "Manage Content" And I follow "Another Conference" - And I follow "Spread" - And I check "Sample Community" + And I follow "Spread this" + And I type in "Sample Community" into autocomplete list "search-communities-to-publish" and I choose "Sample Community" And I press "Spread this" And I am on /profile/sample-community/events/2009/10/24 Then I should see "Another Conference" diff --git a/features/publish_article.feature b/features/publish_article.feature index 2b04db5..fb7e2f2 100644 --- a/features/publish_article.feature +++ b/features/publish_article.feature @@ -40,7 +40,6 @@ Feature: publish article | Sample Community | And I fill in "Title" with "Another name" And I press "Spread this" - And show sample-community tasks When I go to sample-community's blog Then I should see "Another name" And I should not see "Sample Article" diff --git a/features/step_definitions/custom_web_steps.rb b/features/step_definitions/custom_web_steps.rb index 5a177d0..dd5d6cd 100644 --- a/features/step_definitions/custom_web_steps.rb +++ b/features/step_definitions/custom_web_steps.rb @@ -44,3 +44,15 @@ end When /^I confirm the browser dialog$/ do page.driver.browser.switch_to.alert.accept end + +When /^I type in "([^\"]*)" into autocomplete list "([^\"]*)" and I choose "([^\"]*)"$/ do |term, input, result| + # We seem to have to wait for the page to load js + sleep 1 + page.execute_script("jQuery('#token-input-#{input}').trigger('focus').val('#{term}').trigger('keydown')") + + # We use this to wait for the search + page.should have_selector('.token-input-dropdown li') + + page.execute_script ("jQuery('.token-input-dropdown li:contains(\"#{result}\")').trigger('mousedown');") + page.should have_selector('li.token-input-token') +end diff --git a/features/step_definitions/noosfero_steps.rb b/features/step_definitions/noosfero_steps.rb index f38386d..bba0afd 100644 --- a/features/step_definitions/noosfero_steps.rb +++ b/features/step_definitions/noosfero_steps.rb @@ -772,7 +772,3 @@ Given /^the field (.*) is public for all users$/ do |field| person.save! end end - -And /^show (.*) tasks$/ do |identifier| - puts Community.find_by_identifier(identifier).tasks.pending.count -end diff --git a/features/step_definitions/search_steps.rb b/features/step_definitions/search_steps.rb index 4eeef3f..4b7abd7 100644 --- a/features/step_definitions/search_steps.rb +++ b/features/step_definitions/search_steps.rb @@ -5,16 +5,16 @@ When /^I choose the search filter "(.*)"$/ do |filter| end When /^I choose the following communities to spread$/ do |table| - ids = [] table.hashes.each do |row| name = row.delete("name") - community = Community.find_by_name(name) - ids << community.id + # We seem to have to wait for the page to load js + sleep 1 + page.execute_script("jQuery('#token-input-search-communities-to-publish').trigger('focus').val('#{name}').trigger('keydown')") + + # We use this to wait for the search + page.should have_selector('.token-input-dropdown li') + + page.execute_script ("jQuery('.token-input-dropdown li:contains(\"#{name}\")').trigger('mousedown');") + page.should have_selector('li.token-input-token') end - #TODO make this work somehow... - #fill_in('q', :with => ids.join(',')) - #fill_in('#search-communities-to-publish', :with => ids.join(',')) - page.execute_script("jQuery('#search-communities-to-publish').val(#{ids.join(',')})") - page.execute_script("jQuery('#search-communities-to-publish').show()") - p find('#search-communities-to-publish').value end -- libgit2 0.21.2