Commit 79b3cf7a3c177b06abc5c374c195c308157f989e

Authored by Fabio Teixeira
Committed by David Silva
1 parent c6e3ca2a

Adapt software's license selenium tests to autocomplete tests

Signed-off-by: Fabio Teixeira <fabio1079@gmail.com>
controllers/mpog_software_plugin_myprofile_controller.rb
@@ -20,10 +20,10 @@ class MpogSoftwarePluginMyprofileController &lt; MyProfileController @@ -20,10 +20,10 @@ class MpogSoftwarePluginMyprofileController &lt; MyProfileController
20 @community.environment = environment 20 @community.environment = environment
21 @software_info = SoftwareInfo.new(params[:software_info]) 21 @software_info = SoftwareInfo.new(params[:software_info])
22 22
23 - @license_info = if params[:license_info].nil? 23 + @license_info = if params[:license].blank? or params[:license][:license_infos_id].blank?
24 LicenseInfo.new 24 LicenseInfo.new
25 else 25 else
26 - LicenseInfo.find(params[:license_info][:id]) 26 + LicenseInfo.find(params[:license][:license_infos_id])
27 end 27 end
28 28
29 control_software_creation 29 control_software_creation
features/software_registration.feature
@@ -14,6 +14,7 @@ Feature: edit public software information @@ -14,6 +14,7 @@ Feature: edit public software information
14 And I follow "Create a new software" 14 And I follow "Create a new software"
15 And I fill in "community_name" with "basic software" 15 And I fill in "community_name" with "basic software"
16 And I fill in "software_info_finality" with "basic software finality" 16 And I fill in "software_info_finality" with "basic software finality"
  17 + And I type in "gp" in autocomplete list "#license_info_version" and I choose "GPL-2"
17 And I press "Create" 18 And I press "Create"
18 19
19 @selenium 20 @selenium
@@ -41,7 +42,7 @@ Feature: edit public software information @@ -41,7 +42,7 @@ Feature: edit public software information
41 Given I go to /myprofile/basic-software/plugin/mpog_software/edit_software 42 Given I go to /myprofile/basic-software/plugin/mpog_software/edit_software
42 When I follow "Specifications" 43 When I follow "Specifications"
43 And I follow "New Database" 44 And I follow "New Database"
44 - And I type in "my" into autocomplete list "database_autocomplete" and I choose "MySQL" 45 + And I type in "my" in autocomplete list ".database_autocomplete" and I choose "MySQL"
45 Then selector ".database_autocomplete" should have any "MySQL" 46 Then selector ".database_autocomplete" should have any "MySQL"
46 47
47 @selenium 48 @selenium
@@ -49,7 +50,7 @@ Feature: edit public software information @@ -49,7 +50,7 @@ Feature: edit public software information
49 Given I go to /myprofile/basic-software/plugin/mpog_software/edit_software 50 Given I go to /myprofile/basic-software/plugin/mpog_software/edit_software
50 When I follow "Specifications" 51 When I follow "Specifications"
51 And I follow "New language" 52 And I follow "New language"
52 - And I type in "py" into autocomplete list "language_autocomplete" and I choose "Python" 53 + And I type in "py" in autocomplete list ".language_autocomplete" and I choose "Python"
53 Then selector ".database_autocomplete" should have any "Python" 54 Then selector ".database_autocomplete" should have any "Python"
54 55
55 @selenium 56 @selenium
@@ -57,10 +58,10 @@ Feature: edit public software information @@ -57,10 +58,10 @@ Feature: edit public software information
57 Given I go to /myprofile/basic-software/plugin/mpog_software/edit_software 58 Given I go to /myprofile/basic-software/plugin/mpog_software/edit_software
58 When I follow "Specifications" 59 When I follow "Specifications"
59 And I follow "New language" 60 And I follow "New language"
60 - And I type in "py" into autocomplete list "language_autocomplete" and I choose "Python" 61 + And I type in "py" in autocomplete list ".language_autocomplete" and I choose "Python"
61 And I fill in "language__version" with "1.2.3" 62 And I fill in "language__version" with "1.2.3"
62 And I follow "New Database" 63 And I follow "New Database"
63 - And I type in "my" into autocomplete list "database_autocomplete" and I choose "MySQL" 64 + And I type in "my" in autocomplete list ".database_autocomplete" and I choose "MySQL"
64 And I fill in "database__version" with "4.5.6" 65 And I fill in "database__version" with "4.5.6"
65 Then I press "Save" 66 Then I press "Save"
66 And I follow "Software Info" 67 And I follow "Software Info"
@@ -86,10 +87,10 @@ Feature: edit public software information @@ -86,10 +87,10 @@ Feature: edit public software information
86 And I follow "Create a new software" 87 And I follow "Create a new software"
87 And I fill in "community_name" with "another software" 88 And I fill in "community_name" with "another software"
88 And I fill in "software_info_finality" with "another software finality" 89 And I fill in "software_info_finality" with "another software finality"
89 - And I select "GPL-2" from "license_info_id"  
90 - And I should see "www.gpl2.com" within "#version_link" 90 + And I type in "gp" in autocomplete list "#license_info_version" and I choose "GPL-2"
  91 + And I should see "Read license" within "#version_link"
91 And I press "Create" 92 And I press "Create"
92 And I go to another-software's control panel 93 And I go to another-software's control panel
93 And I follow "Software Info" 94 And I follow "Software Info"
94 - And I select "GPL-3" from "license_info_id"  
95 - Then I should see "www.gpl3.com" within "#version_link"  
96 \ No newline at end of file 95 \ No newline at end of file
  96 + And I type in "gp" in autocomplete list "#license_info_version" and I choose "GPL-3"
  97 + Then I should see "Read license" within "#version_link"
97 \ No newline at end of file 98 \ No newline at end of file
features/step_definitions/mpog_steps.rb
@@ -41,12 +41,27 @@ Given /^Institutions has initial default values on database$/ do @@ -41,12 +41,27 @@ Given /^Institutions has initial default values on database$/ do
41 national_region.save 41 national_region.save
42 end 42 end
43 43
44 -Given /^I type in "([^"]*)" into autocomplete list "([^"]*)" and I choose "([^"]*)"$/ do |typed, input_institution, should_select|  
45 - page.driver.browser.execute_script %Q{ jQuery('input[data-autocomplete]').trigger("focus") }  
46 - fill_in("#{input_institution}",:with => typed)  
47 - page.driver.browser.execute_script %Q{ jQuery('input[data-autocomplete]').trigger("keydown") }  
48 - sleep 1  
49 - page.driver.browser.execute_script %Q{ jQuery('.ui-menu-item a:contains("#{should_select}")').trigger("mouseenter").trigger("click"); } 44 +Given /^I type in "([^"]*)" in autocomplete list "([^"]*)" and I choose "([^"]*)"$/ do |typed, input_field_selector, should_select|
  45 + # Wait the page javascript load
  46 + sleep 1
  47 + # Basicaly it, search for the input field, type something, wait for ajax end select an item
  48 + page.driver.browser.execute_script %Q{
  49 + var search_query = "#{input_field_selector}.ui-autocomplete-input";
  50 + var input = jQuery(search_query).first();
  51 +
  52 + input.trigger('click');
  53 + input.val('#{typed}');
  54 + input.trigger('keydown');
  55 +
  56 + window.setTimeout(function(){
  57 + search_query = ".ui-menu-item a:contains('#{should_select}')";
  58 + var typed = jQuery(search_query).first();
  59 +
  60 + typed.trigger('mouseenter').trigger('click');
  61 + console.log(jQuery('#license_info_id'));
  62 + }, 1000);
  63 + }
  64 + sleep 1
50 end 65 end
51 66
52 Given /^the following public institutions?$/ do |table| 67 Given /^the following public institutions?$/ do |table|