diff --git a/features/search.feature b/features/search.feature index e7aaf38..4d0bd8d 100644 --- a/features/search.feature +++ b/features/search.feature @@ -5,16 +5,17 @@ Feature: search Background: Given the search index is empty + And feature "disable_asset_products" is disabled on environment Scenario: simple search for person Given the following users - | login | name | - | joaosilva | Joao Silva | + | login | name | + | joaosilva | Joao Silva | | josearaujo | Jose Araujo | When I go to the search page And I fill in "query" with "Silva" And I press "Search" - Then I should see "Joao Silva" + Then I should see "Joao Silva" within "div.search-results-people" And I should not see "Jose Araujo" Scenario: simple search for community @@ -25,7 +26,7 @@ Feature: search And I go to the search page And I fill in "query" with "fancy" And I press "Search" - Then I should see "Fancy community" + Then I should see "Fancy community" within "div.search-results-communities" And I should not see "Boring community" Scenario: simple search for enterprise @@ -36,7 +37,7 @@ Feature: search And I go to the search page And I fill in "query" with "shoes" And I press "Search" - Then I should see "Shoes shop" + Then I should see "Shoes shop" within "div.search-results-enterprises" And I should not see "Fruits shop" Scenario: simple search for content @@ -50,28 +51,26 @@ Feature: search When I go to the search page And I fill in "query" with "whales" And I press "Search" - Then I should see "whales and dolphins" + Then I should see "whales and dolphins" within "div.search-results-articles" And I should not see "bees and butterflies" - Scenario: simple search for product Given the following enterprises - | identifier | name | + | identifier | name | | colivre-ent | Colivre | And the following product_categories - | name | + | name | | Development | And the following products - | owner | category | name | + | owner | category | name | | colivre-ent | development | social networks consultancy | - | colivre-ent | development | wikis consultancy | + | colivre-ent | development | wikis consultancy | When I go to the search page And I fill in "query" with "wikis" And I press "Search" - Then I should see "wikis consultancy" + Then I should see "wikis consultancy" within "div.search-results-products" And I should not see "social networks consultancy" - Scenario: simple search for event Given the following communities | identifier | name | @@ -83,6 +82,25 @@ Feature: search When I go to the search page And I fill in "query" with "birthday" And I press "Search" - Then I should see "John Doe's birthday" + Then I should see "John Doe's birthday" within "div.search-results-events" And I should not see "Group meeting" + Scenario: search different types of entities with the same query + Given the following enterprises + | identifier | name | + | colivre | Colivre - Noosfero dev. | + And the following communities + | identifier | name | + | noosfero-users | Noosfero users | + And the following product_categories + | name | + | Development | + And the following products + | owner | name | category | + | colivre | Noosfero platform | Development | + When I go to the search page + And I fill in "query" with "noosfero" + And I press "Search" + Then I should see "Colivre - Noosfero dev." within "div.search-results-enterprises" + And I should see "Noosfero users" within "div.search-results-communities" + And I should see "Noosfero platform" within "div.search-results-products" diff --git a/features/search_enterprises.feature b/features/search_enterprises.feature new file mode 100644 index 0000000..2714c37 --- /dev/null +++ b/features/search_enterprises.feature @@ -0,0 +1,118 @@ +Feature: search enterprises + As a noosfero user + I want to search enterprises + In order to find ones that interest me + + Background: + Given the search index is empty + And the following enterprises + | identifier | name | + | shop1 | Shoes shop | + | shop2 | Fruits shop | + And the following categories as facets + | name | + | Temáticas | + + Scenario: show recent enterprises on index (empty query) + When I go to the search enterprises page + Then I should see "Shoes shop" within "#search-results" + And I should see "Fruits shop" within "#search-results" + + Scenario: simple search for enterprise + When I go to the search enterprises page + And I fill in "query" with "shoes" + And I press "Search" + Then I should see "Shoes shop" + And I should not see "Fruits shop" + + Scenario: see default facets when searching + When I go to the search enterprises page + And I fill in "query" with "shoes" + And I press "Search" + Then I should see "City" within "#facets-menu" + + Scenario: see category facets when searching + When I go to the search enterprises page + And I fill in "query" with "shoes" + And I press "Search" + Then I should see "Temáticas" within "#facets-menu" + + Scenario: see region on facets and results + Given the following cities + | name | state | + | Pres. Prudente | SP | + And the following enterprises + | identifier | name | city | + | art-pp | Artesanato PP | Pres. Prudente | + When I go to the search enterprises page + And I fill in "query" with "Artesanato" + And I press "Search" + Then I should see "Pres. Prudente" within "#facet-menu-f_region" + And I should see ", SP" within "#facet-menu-f_region" + And I should see "Pres. Prudente, SP" within "#search-results" + + Scenario: find enterprise by region + Given the following cities + | name | state | + | Pres. Prudente | SP | + And the following enterprises + | identifier | name | city | + | art-pp | Artesanato PP | Pres. Prudente | + When I go to the search enterprises page + And I fill in "query" with "Prudente" + And I press "Search" + Then I should see "Artesanato PP" within "#search-results" + + Scenario: find enterprise by category + Given the following categories + | name | + | Software Livre | + And the following enterprises + | identifier | name | category | + | noosfero | Noosfero | software-livre | + When I go to the search enterprises page + And I fill in "query" with "software" + And I press "Search" + Then I should see "Noosfero" within "#search-results" + + Scenario: find enterprises without exact query + Given the following enterprises + | identifier | name | + | noosfero | Noosfero Developers Association | + When I go to the search enterprises page + And I fill in "query" with "Noosfero Association" + And I press "Search" + Then I should see "Noosfero Developers Association" within "#search-results" + + Scenario: filter enterprises by facet + Given the following category + | name | parent | + | Software Livre | tematicas | + And the following enterprises + | identifier | name | category | + | noosfero | Noosfero Developers | software-livre | + | facebook | Facebook Developers | | + When I go to the search enterprises page + And I fill in "query" with "Developers" + And I press "Search" + And I follow "Software Livre" within "#facets-menu" + Then I should see "Noosfero Developers" within "#search-results" + And I should not see "Facebook Developers" + + Scenario: remember facet filter when searching new query + Given the following category + | name | parent | + | Software Livre | tematicas | + And the following enterprises + | identifier | name | category | + | noosfero | Noosfero Developers | software-livre | + | rails-dev | Rails Developers | | + | rails-usr | Rails Users | software-livre | + When I go to the search enterprises page + And I fill in "query" with "Developers" + And I press "Search" + And I follow "Software Livre" within "#facets-menu" + And I fill in "query" with "Rails" + And I press "Search" + Then I should see "Rails Users" within "#search-results" + And I should not see "Rails Developers" diff --git a/features/search_products.feature b/features/search_products.feature new file mode 100644 index 0000000..9bdbe35 --- /dev/null +++ b/features/search_products.feature @@ -0,0 +1,210 @@ +Feature: search products + As a noosfero user + I want to search products + In order to find ones that interest me + + Background: + Given the search index is empty + And feature "disable_asset_products" is disabled on environment + And the following enterprises + | identifier | name | + | colivre-ent | Colivre | + And the following product_categories + | name | + | Development | + And the following products + | owner | category | name | price | + | colivre-ent | development | social networks consultancy | 1.00 | + | colivre-ent | development | wikis consultancy | 2.00 | + + Scenario: show recent products on index (empty query) + When I go to the search products page + Then I should see "wikis consultancy" within "#search-results" + And I should see "social networks consultancy" within "#search-results" + + Scenario: simple search for product + When I go to the search products page + And I fill in "query" with "wikis" + And I press "Search" + Then I should see "wikis consultancy" within "#search-results" + And I should not see "social networks consultancy" + + Scenario: see default facets when searching + When I go to the search products page + And I fill in "query" with "wikis" + And I press "Search" + Then I should see "Related products" within "#facets-menu" + Then I should see "City" within "#facets-menu" + Then I should see "Qualifiers" within "#facets-menu" + + Scenario: show percentage (100%) of solidary economy inputs in results + Given the following inputs + | product | category | solidary | + | wikis consultancy | development | true | + When I go to the search products page + And I fill in "query" with "wikis" + And I press "Search" + Then I should see "100%" within "div.search-product-ecosol-percentage-icon-100" + + Scenario: show percentage (50%) of solidary economy inputs in results + Given the following inputs + | product | category | solidary | + | wikis consultancy | development | true | + | wikis consultancy | development | false | + When I go to the search products page + And I fill in "query" with "wikis" + And I press "Search" + Then I should see "50%" within "div.search-product-ecosol-percentage-icon-50" + + Scenario: show percentage (75%) of solidary economy inputs in results + Given the following inputs + | product | category | solidary | + | wikis consultancy | development | true | + | wikis consultancy | development | true | + | wikis consultancy | development | true | + | wikis consultancy | development | false | + When I go to the search products page + And I fill in "query" with "wikis" + And I press "Search" + Then I should see "75%" within "div.search-product-ecosol-percentage-icon-75" + + Scenario: show percentage (25%) of solidary economy inputs in results + Given the following inputs + | product | category | solidary | + | wikis consultancy | development | true | + | wikis consultancy | development | false | + | wikis consultancy | development | false | + | wikis consultancy | development | false | + When I go to the search products page + And I fill in "query" with "wikis" + And I press "Search" + Then I should see "25%" within "div.search-product-ecosol-percentage-icon-25" + + Scenario: display "zoom in" button on images on results + Given the following products + | owner | category | name | price | img | + | colivre-ent | development | noosfero | 12.34 | noosfero-network | + When I go to the search products page + And I fill in "query" with "noosfero" + And I press "Search" + Then I should not see "No image" + And I should see "Zoom in" within "a.zoomify-image" + + Scenario: search products by category + Given the following product_category + | name | + | Software Livre | + And the following product + | owner | name | category | + | colivre-ent | Noosfero | software-livre | + When I go to the search products page + And I fill in "query" with "software livre" + And I press "Search" + Then I should see "Noosfero" within "#search-results" + And I should not see "wikis consultancy" + And I should not see "social networks consultancy" + + Scenario: see region on facets and results + Given the following cities + | name | state | + | Pres. Prudente | SP | + And the following enterprise + | identifier | name | city | + | art-pp | Artesanato PP | Pres. Prudente | + And the following product_category + | name | + | Solidária | + And the following product + | owner | name | category | + | art-pp | Arte em Madeira | solidaria | + When I go to the search products page + And I fill in "query" with "Madeira" + And I press "Search" + Then I should see "Pres. Prudente" within "#facet-menu-f_region" + And I should see ", SP" within "#facet-menu-f_region" + And I should see "Pres. Prudente, SP" within "#search-results" + + Scenario: find product by region + Given the following cities + | name | state | + | Pres. Prudente | SP | + And the following enterprise + | identifier | name | city | + | art-pp | Artesanato PP | Pres. Prudente | + And the following product_category + | name | + | Solidária | + And the following product + | owner | name | category | + | art-pp | Arte em Madeira | solidaria | + When I go to the search products page + And I fill in "query" with "Prudente" + And I press "Search" + Then I should see "Arte em Madeira" within "#search-results" + + Scenario: find products without exact query + Given the following enterprise + | identifier | name | + | colivre | Colivre | + And the following product_category + | name | + | Software Livre | + And the following products + | owner | name | category | + | colivre | Noosfero Social Network Platform | software-livre | + When I go to the search products page + And I fill in "query" with "Noosfero Network" + And I press "Search" + Then I should see "Noosfero Social Network Platform" within "#search-results" + + Scenario: filter products by facet + Given the following enterprises + | identifier | name | + | colivre | Colivre | + | fb | FB inc. | + And the following categories as facets + | name | + | Temáticas | + And the following product_categories + | name | parent | + | Software Livre | tematicas | + | Big Brother | tematicas | + And the following products + | owner | name | category | + | colivre | Noosfero Network | software-livre | + | fb | Facebook Network | big-brother | + When I go to the search products page + And I fill in "query" with "Network" + And I press "Search" + And I follow "Software Livre" within "#facets-menu" + Then I should see "Noosfero Network" within "#search-results" + And I should not see "Facebook Network" + + Scenario: remember facet filter when searching new query + Given the following enterprises + | identifier | name | + | colivre | Colivre | + | fb | FB inc. | + | other | Other | + And the following categories as facets + | name | + | Temáticas | + And the following product_categories + | name | parent | + | Software Livre | tematicas | + | Big Brother | tematicas | + | Other | tematicas | + And the following products + | owner | name | category | + | colivre | Noosfero Network | software-livre | + | fb | Facebook Network | big-brother | + | other | Other open | software-livre | + | other | Other closed | big-brother | + When I go to the search products page + And I fill in "query" with "Network" + And I press "Search" + And I follow "Software Livre" within "#facets-menu" + And I fill in "query" with "Other" + And I press "Search" + Then I should see "Other open" within "#search-results" + And I should not see "Other closed" diff --git a/features/step_definitions/noosfero_steps.rb b/features/step_definitions/noosfero_steps.rb index a4e31e7..8ce05cd 100644 --- a/features/step_definitions/noosfero_steps.rb +++ b/features/step_definitions/noosfero_steps.rb @@ -7,7 +7,13 @@ Given /^the following users?$/ do |table| table.hashes.each do |item| person_data = item.dup person_data.delete("login") - User.create!(:login => item[:login], :password => '123456', :password_confirmation => '123456', :email => item[:login] + "@example.com", :person_data => person_data).activate + category = Category.find_by_slug person_data.delete("category") + user = User.create!(:login => item[:login], :password => '123456', :password_confirmation => '123456', :email => item[:login] + "@example.com", :person_data => person_data) + user.activate + p = user.person + p.categories << category if category + p.save! + user.save! end end @@ -25,6 +31,8 @@ Given /^the following (community|communities|enterprises?|organizations?)$/ do | table.hashes.each do |row| owner = row.delete("owner") domain = row.delete("domain") + city = row.delete("city") + category = row.delete("category") organization = klass.create!(row) if owner organization.add_admin(Profile[owner]) @@ -33,6 +41,15 @@ Given /^the following (community|communities|enterprises?|organizations?)$/ do | d = Domain.new :name => domain, :owner => organization d.save(false) end + if city + c = City.find_by_name city + organization.region = c + end + if category && !category.blank? + cat = Category.find_by_slug category + organization.categories << cat + end + organization.save! end end @@ -95,6 +112,7 @@ Given /^the following (articles|events|blogs|folders|forums|galleries)$/ do |con owner = Profile[owner_identifier] home = item.delete("homepage") language = item.delete("lang") + category = item.delete("category") translation_of_id = nil if item["translation_of"] if item["translation_of"] != "nil" @@ -111,6 +129,12 @@ Given /^the following (articles|events|blogs|folders|forums|galleries)$/ do |con if parent result.parent = Article.find_by_name(parent) end + if category + cat = Category.find_by_slug category + if cat + result.add_category(cat) + end + end result.save! if home == 'true' owner.home_page = result @@ -182,7 +206,9 @@ Given /^the following inputs?$/ do |table| product = Product.find_by_name(data.delete("product")) category = Category.find_by_slug(data.delete("category").to_slug) unit = Unit.find_by_singular(data.delete("unit")) - input = Input.create!(data.merge(:product => product, :product_category => category, :unit => unit)) + solidary = data.delete("solidary") + input = Input.create!(data.merge(:product => product, :product_category => category, :unit => unit, + :is_from_solidarity_economy => solidary)) input.update_attributes!(:position => data['position']) end end @@ -570,3 +596,31 @@ end Given /^the search index is empty$/ do ActsAsSolr::Post.execute(Solr::Request::Delete.new(:query => '*:*')) end + +# This could be merged with "the following categories" +Given /^the following categories as facets$/ do |table| + ids = [] + table.hashes.each do |item| + cat = Category.find_by_name(item[:name]) + if cat.nil? + cat = Category.create!(:environment_id => Environment.default.id, :name => item[:name]) + end + ids << cat.id + end + env = Environment.default + env.top_level_category_as_facet_ids = ids + env.save! +end + +Given /^the following cities$/ do |table| + table.hashes.each do |item| + state = State.find_by_acronym item[:state] + if !state + state = State.create!(:name => item[:state], :acronym => item[:state], :environment_id => Environment.default.id) + end + city = City.create!(:name => item[:name], :environment_id => Environment.default.id) + city.parent = state + city.save! + end +end + diff --git a/features/support/paths.rb b/features/support/paths.rb index 89be7f8..4b5db2a 100644 --- a/features/support/paths.rb +++ b/features/support/paths.rb @@ -72,6 +72,9 @@ module NavigationHelpers when /^the search page$/ '/search' + when /^the search (.+) page$/ + '/search/%s' % $1 + when /^(.+)'s cms/ '/myprofile/%s/cms' % Profile.find_by_name($1).identifier diff --git a/test/fixtures/files/noosfero-network.png b/test/fixtures/files/noosfero-network.png new file mode 100644 index 0000000..355d576 Binary files /dev/null and b/test/fixtures/files/noosfero-network.png differ -- libgit2 0.21.2