Commit 0b1b40e0ffeb95b734d9ffc87e7c45311edb61b7

Authored by Fabio Teixeira
Committed by Gabriela Navarro
1 parent 86a63650

Add cucumber/selenium tests for software catalog search

Signed-off-by: Fabio Teixeira <fabio1079@gmail.com>
Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com>
features/software_catalog.feature 0 → 100644
@@ -0,0 +1,57 @@ @@ -0,0 +1,57 @@
  1 +Feature: Search software
  2 + As a user
  3 + I want to be able to search catalogued software
  4 + So that I find a software that fit my needs
  5 + Background:
  6 + Given "MpogSoftwarePlugin" plugin is enabled
  7 + And I am logged in as mpog_admin
  8 + And I go to /admin/plugins
  9 + And I check "MpogSoftwarePlugin"
  10 + And I press "Save changes"
  11 + And I go to /account/logout
  12 + And the following categories
  13 + | name | display_in_menu |
  14 + | Software | true |
  15 + And the following categories
  16 + | parent | name | display_in_menu |
  17 + | Software | Health | true |
  18 + | Software | Education | true |
  19 + And the following softwares
  20 + | name | public_software | categories |
  21 + | Software One | true | Health |
  22 + | Software Two | false | Health, Education |
  23 +
  24 +
  25 + Scenario: Show all softwares when open search page
  26 + Given I go to /search/software_infos
  27 + Then I should see "Software One"
  28 + Then I should see "Software Two"
  29 +
  30 + Scenario: Show all softwares when search software
  31 + Given I go to /search/software_infos
  32 + And I fill in "search-input" with "Software"
  33 + Then I should see "Software One"
  34 + Then I should see "Software Two"
  35 +
  36 + Scenario: Show softwares one when search software one
  37 + Given I go to /search/software_infos
  38 + And I fill in "search-input" with "Software One"
  39 + And I press "Search"
  40 + Then I should see "Software One"
  41 + Then I should not see "Software Two"
  42 +
  43 + @selenium
  44 + Scenario: Show only "Software Two" when searching for "Education" category
  45 + Given I go to /search/software_infos
  46 + And I click on anything with selector "#filter-option-catalog-software"
  47 + And I check "Education"
  48 + Then I should see "Software Two"
  49 + Then I should not see "Software One"
  50 +
  51 + @selenium
  52 + Scenario: Show both Software "One" and "Two" when searching for "Health" category
  53 + Given I go to /search/software_infos
  54 + And I click on anything with selector "#filter-option-catalog-software"
  55 + And I check "Health"
  56 + Then I should see "Software One"
  57 + Then I should see "Software Two"
features/step_definitions/mpog_steps.rb
@@ -155,6 +155,16 @@ Given /^the following softwares$/ do |table| @@ -155,6 +155,16 @@ Given /^the following softwares$/ do |table|
155 software_info.operating_systems << operating_system 155 software_info.operating_systems << operating_system
156 end 156 end
157 157
  158 + if item[:categories]
  159 + categories = item[:categories].split(",")
  160 + categories.map! {|category| category.strip}
  161 +
  162 + categories.each do |category_name|
  163 + category = Category.find_by_name category_name
  164 + software_info.community.categories << category
  165 + end
  166 + end
  167 +
158 software_info.save! 168 software_info.save!
159 end 169 end
160 end 170 end