Commit 79b3cf7a3c177b06abc5c374c195c308157f989e

Authored by Fabio Teixeira
Committed by David Silva
1 parent c6e3ca2a
Exists in master and in 79 other branches add_sisp_to_chef, add_super_archives_plugin, api_for_colab, automates_core_packing, backup_not_prod, changes_in_buttons_on_content_panel, colab_automated_login, colab_spb_plugin_recipe, colab_widgets_settings, design_validation, dev_env_minimal, disable_email_dev, fix_breadcrumbs_position, fix_categories_software_link, fix_edit_institution, fix_edit_software_with_another_license, fix_get_license_info, fix_gitlab_assets_permission, fix_list_style_inside_article, fix_list_style_on_folder_elements, fix_members_pagination, fix_merge_request_url, fix_models_translations, fix_no_license, fix_software_api, fix_software_block_migration, fix_software_communities_translations, fix_software_communities_unit_test, fix_style_create_institution_admin_panel, fix_superarchives_imports, fix_sym_links_noosfero, focus_search_field_theme, gov-user-refactoring, gov-user-refactoring-rails4, header_fix, institution_modal_on_rating, kalibro-conf-refactoring, kalibro-processor-package, lxc_settings, margin_fix, mezuro_cookbook, prezento, refactor_download_block, refactor_software_communities, refactor_software_for_sisp, register_page, release-process, release-process-v2, remove-unused-images, remove_broken_theme, remove_secondary_email_from_user, remove_sisp_buttons, removing_super_archives_email, review_message, scope2method, signals_user_noosfero, sisp_catalog_header, sisp_colab_config, sisp_dev, sisp_dev_master, sisp_simple_version, software_as_organization, software_catalog_style_fix, software_communities_html_refactor, software_infos_api, spb_minimal_env, spb_to_rails4, spec_refactor, stable-4.1, stable-4.2, stable-4.x, temp_soft_comm_refactoring, theme_header, theme_javascript_refactory, thread_dropdown, thread_page, update_search_by_categories, update_software_api, update_softwares_boxes

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 20 @community.environment = environment
21 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 24 LicenseInfo.new
25 25 else
26   - LicenseInfo.find(params[:license_info][:id])
  26 + LicenseInfo.find(params[:license][:license_infos_id])
27 27 end
28 28  
29 29 control_software_creation
... ...
features/software_registration.feature
... ... @@ -14,6 +14,7 @@ Feature: edit public software information
14 14 And I follow "Create a new software"
15 15 And I fill in "community_name" with "basic software"
16 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 18 And I press "Create"
18 19  
19 20 @selenium
... ... @@ -41,7 +42,7 @@ Feature: edit public software information
41 42 Given I go to /myprofile/basic-software/plugin/mpog_software/edit_software
42 43 When I follow "Specifications"
43 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 46 Then selector ".database_autocomplete" should have any "MySQL"
46 47  
47 48 @selenium
... ... @@ -49,7 +50,7 @@ Feature: edit public software information
49 50 Given I go to /myprofile/basic-software/plugin/mpog_software/edit_software
50 51 When I follow "Specifications"
51 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 54 Then selector ".database_autocomplete" should have any "Python"
54 55  
55 56 @selenium
... ... @@ -57,10 +58,10 @@ Feature: edit public software information
57 58 Given I go to /myprofile/basic-software/plugin/mpog_software/edit_software
58 59 When I follow "Specifications"
59 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 62 And I fill in "language__version" with "1.2.3"
62 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 65 And I fill in "database__version" with "4.5.6"
65 66 Then I press "Save"
66 67 And I follow "Software Info"
... ... @@ -86,10 +87,10 @@ Feature: edit public software information
86 87 And I follow "Create a new software"
87 88 And I fill in "community_name" with "another software"
88 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 92 And I press "Create"
92 93 And I go to another-software's control panel
93 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 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 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 41 national_region.save
42 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 65 end
51 66  
52 67 Given /^the following public institutions?$/ do |table|
... ...