From be2bb304251dedc2c9b3c961763e143ea26cab44 Mon Sep 17 00:00:00 2001 From: Steven Miers Date: Fri, 14 Nov 2014 13:09:19 -0600 Subject: [PATCH] VRFS-2478 : Fix JS timing error causing intermittent test failure. --- web/app/assets/javascripts/jamtrack.js | 7 +- web/app/views/clients/_web_filter.html.erb | 94 --------------------- web/app/views/clients/_web_filter.html.haml | 79 +++++++++++++++++ web/spec/features/jamtrack_shopping_spec.rb | 2 +- web/spec/support/utilities.rb | 3 +- 5 files changed, 86 insertions(+), 99 deletions(-) delete mode 100644 web/app/views/clients/_web_filter.html.erb create mode 100644 web/app/views/clients/_web_filter.html.haml diff --git a/web/app/assets/javascripts/jamtrack.js b/web/app/assets/javascripts/jamtrack.js index 07fd24546..6ae767514 100644 --- a/web/app/assets/javascripts/jamtrack.js +++ b/web/app/assets/javascripts/jamtrack.js @@ -35,6 +35,7 @@ } function clearResults() { + //logger.debug("CLEARING CONTENT") currentPage = 0; $content.empty(); $noMoreJamtracks.hide(); @@ -42,14 +43,15 @@ } function refresh() { - clearResults(); - currentQuery = buildQuery(); rest.getJamtracks(currentQuery) .done(function(response) { + clearResults(); handleJamtrackResponse(response); }) .fail(function(jqXHR) { + clearResults(); + $noMoreJamtracks.show(); app.notifyServerError(jqXHR, 'Jamtrack Unavailable') }) } @@ -95,6 +97,7 @@ } function handleJamtrackResponse(response) { + //logger.debug("Handling response", JSON.stringify(response)) next = response.next; renderJamtracks(response); diff --git a/web/app/views/clients/_web_filter.html.erb b/web/app/views/clients/_web_filter.html.erb deleted file mode 100644 index c192c0f82..000000000 --- a/web/app/views/clients/_web_filter.html.erb +++ /dev/null @@ -1,94 +0,0 @@ - -<% case search_type - when Search::PARAM_BAND - filter_label = :band - when Search::PARAM_MUSICIAN - filter_label = :musician - when Search::PARAM_FEED - filter_label = :feed - when Search::PARAM_JAMTRACK - filter_label = :jamtrack - end %> -<%= content_tag(:div, :id => defined?(id) ? id : 'session-controls', :class => "#{filter_label}-filter filter-head") do %> - <%= content_tag(:div, :class => "filter-element wrapper") do -%> - <% if :feed == filter_label %> - - <%= content_tag(:div, 'Sort Feed by:', :class => 'filter-element desc') %> - <%= select_tag("#{filter_label}_order_by", options_for_select(Search::F_SORT_OPTS), {:class => "#{filter_label}-order-by easydropdown" } ) %> - - <% elsif :jamtrack != filter_label %> - - <%= content_tag(:div, 'Order By:', :class => 'filter-element desc') %> - <%= select_tag("#{filter_label}_order_by", options_for_select(Search::M_ORDERINGS), {:class => "#{filter_label}-order-by easydropdown"} ) %> - - <% end %> - <% end -%> - <%= content_tag(:div, :class => 'filter-element wrapper') do -%> - <% if :band == filter_label || :jamtrack == filter_label %> - - <%= content_tag(:div, 'Genre:', :class => 'filter-element desc') %> - <%= select_tag("#{filter_label}_genre", - options_for_select([['Any', '']].concat(JamRuby::Genre.all.collect { |ii| [ii.description, ii.id] })), {:class => 'easydropdown'}) %> - - <% end %> - <% if :musician == filter_label || :jamtrack == filter_label %> - - <%= content_tag(:div, 'Instrument:', :class => 'filter-element desc instrument-selector') %> - <%= select_tag("#{filter_label}_instrument", - options_for_select([['Any', '']].concat(JamRuby::Instrument.all.collect { |ii| [ii.description, ii.id] })), {:class=> "easydropdown"}) %> - - <% end %> - <% if :feed == filter_label %> - - <%= content_tag(:div, 'Include Dates:', :class => 'filter-element desc') %> - <%= select_tag("#{filter_label}_date", options_for_select(Search::DATE_OPTS), {:class => "easydropdown"}) %> - - <% end %> - <% end -%> - <%= content_tag(:div, :class => 'filter-element wrapper') do -%> - <% if :feed == filter_label %> - - <%= content_tag(:div, 'Show:', :class => 'filter-element desc') %> - <%= select_tag("#{filter_label}_show", options_for_select(Search::SHOW_OPTS), {:class => "easydropdown"}) %> - - <% elsif :musician == filter_label %> - - <%= content_tag(:div, 'Latency:', :class => 'filter-element desc latency-or-distance') %> - <%= content_tag(:div, :class => 'query-distance-params') do -%> - <%= select_tag("musician_query_score", options_for_select(Search::M_SCORE_OPTS, Search::M_SCORE_DEFAULT), {:class => 'easydropdown'}) %> - <%= select_tag("musician_distance", options_for_select(Search::M_DISTANCE_OPTS, Search::M_DISTANCE_DEFAULT), {:class => 'easydropdown'}) %> - <% end -%> -
- to -
- - <% elsif :jamtrack == filter_label %> - - <%= content_tag(:div, 'Availability:', :class => 'filter-element desc') %> - <%= select_tag("#{filter_label}_availability", options_for_select([['Any', '']].concat(JamRuby::JamTrack::SALES_REGION), 'United States'), {:class => "easydropdown"}) %> - - <% else %> - - <%= content_tag(:div, 'Within', :class => 'filter-element desc') %> - <%= content_tag(:div, :class => 'query-distance-params') do -%> - <% default_distance = :musician == filter_label ? Search::M_MILES_DEFAULT : Search::B_MILES_DEFAULT %> - <%= select_tag("#{filter_label}_query_distance", options_for_select(Search::DISTANCE_OPTS, default_distance), {:class => 'easydropdown'}) %> - <% end -%> - <%= content_tag(:div, :class => 'filter-element desc') do -%> - miles of <%= content_tag(:span, current_user ? current_user.current_city(request.remote_ip) : '', :id => "#{filter_label}-filter-city") %> - <% end -%> - - <% end %> - <% end -%> - - <% if :feed == filter_label %> -
- REFRESH -
- <% elsif :musician == filter_label %> -
- REFRESH -
- <% end %> -<% end -%> - \ No newline at end of file diff --git a/web/app/views/clients/_web_filter.html.haml b/web/app/views/clients/_web_filter.html.haml new file mode 100644 index 000000000..82ef6f85e --- /dev/null +++ b/web/app/views/clients/_web_filter.html.haml @@ -0,0 +1,79 @@ +/ @begin web_filter +-case search_type + -when Search::PARAM_BAND + -filter_label =:band + -when Search::PARAM_MUSICIAN + -filter_label =:musician + -when Search::PARAM_FEED + -filter_label =:feed + -when Search::PARAM_JAMTRACK + -filter_label =:jamtrack +=content_tag(:div, :id => defined?(id) ? id : 'session-controls', :class => "#{filter_label}-filter filter-head") do + =content_tag(:div, :class => "filter-element wrapper") do + -if :feed==filter_label + / @begin sort filter + =content_tag(:div, 'Sort Feed by:', :class => 'filter-element desc') + =select_tag("#{filter_label}_order_by", options_for_select(Search::F_SORT_OPTS), {:class => "#{filter_label}-order-by easydropdown" } ) + / @end sort filter + -elsif :jamtrack !=filter_label + / @begin order by filter + =content_tag(:div, 'Order By:', :class => 'filter-element desc') + =select_tag("#{filter_label}_order_by", options_for_select(Search::M_ORDERINGS), {:class => "#{filter_label}-order-by easydropdown"} ) + / @end order by filter + =content_tag(:div, :class => 'filter-element wrapper') do + -if :band==filter_label || :jamtrack==filter_label + / @begin genre filter + =content_tag(:div, 'Genre:', :class => 'filter-element desc') + =select_tag("#{filter_label}_genre", | + options_for_select([['Any', '']].concat(JamRuby::Genre.all.collect { |ii| [ii.description, ii.id] })), {:class => 'easydropdown'}) | + / @end genre filter + -if :musician==filter_label || :jamtrack==filter_label + / @begin instrument filter + =content_tag(:div, 'Instrument:', :class => 'filter-element desc instrument-selector') + =select_tag("#{filter_label}_instrument", | + options_for_select([['Any', '']].concat(JamRuby::Instrument.all.collect { |ii| [ii.description, ii.id] })), {:class=> "easydropdown"}) | + / @end instrument filter + -if :feed==filter_label + / @begin date filter + =content_tag(:div, 'Include Dates:', :class => 'filter-element desc') + =select_tag("#{filter_label}_date", options_for_select(Search::DATE_OPTS), {:class => "easydropdown"}) + / @end date filter + =content_tag(:div, :class => 'filter-element wrapper') do + -if :feed==filter_label + / @begin show filter + =content_tag(:div, 'Show:', :class => 'filter-element desc') + =select_tag("#{filter_label}_show", options_for_select(Search::SHOW_OPTS), {:class => "easydropdown"}) + / @end show filter + -elsif :musician==filter_label + / @begin score filter + =content_tag(:div, 'Latency:', :class => 'filter-element desc latency-or-distance') + =content_tag(:div, :class => 'query-distance-params') do + =select_tag("musician_query_score", options_for_select(Search::M_SCORE_OPTS, Search::M_SCORE_DEFAULT), {:class => 'easydropdown'}) + =select_tag("musician_distance", options_for_select(Search::M_DISTANCE_OPTS, Search::M_DISTANCE_DEFAULT), {:class => 'easydropdown'}) + #musician-search-city.filter-element.desc + to + %a#musician-change-filter-city{:href => "#"} + %span#musician-filter-city + / @end score filter + -elsif :jamtrack==filter_label + / @begin availability filter + %h3 hey + =content_tag(:div, 'Availability:', :class => 'filter-element desc') + =select_tag("#{filter_label}_availability", options_for_select([['Any', '']].concat(JamRuby::JamTrack::SALES_REGION), 'United States'), {:class => "easydropdown"}) + / @end availability filter + -else + / @begin distance filter + =content_tag(:div, 'Within', :class => 'filter-element desc') + =content_tag(:div, :class => 'query-distance-params') do + -default_distance =:musician==filter_label ? Search::M_MILES_DEFAULT : Search::B_MILES_DEFAULT + =select_tag("#{filter_label}_query_distance", options_for_select(Search::DISTANCE_OPTS, default_distance), {:class => 'easydropdown'}) + =content_tag(:div, :class => 'filter-element desc') do + miles of #{content_tag(:span, current_user ? current_user.current_city(request.remote_ip) : '', :id => "#{filter_label}-filter-city")} + / @end distance filter + -if :feed==filter_label + .btn-refresh-holder + %a.button-grey.btn-refresh-entries{:href => "/client#/feed"} REFRESH + -elsif :musician==filter_label + .btn-refresh-holder + %a.button-grey.btn-refresh-entries{:href => "/client#/musicians"} REFRESH +/ @end web_filter \ No newline at end of file diff --git a/web/spec/features/jamtrack_shopping_spec.rb b/web/spec/features/jamtrack_shopping_spec.rb index e383192cd..761d1e378 100644 --- a/web/spec/features/jamtrack_shopping_spec.rb +++ b/web/spec/features/jamtrack_shopping_spec.rb @@ -26,7 +26,7 @@ describe "JamTrack Shopping", :js => true, :type => :feature, :capybara_feature end def find_jamtrack jamtrack, options = {} - jamtrack_record = find(".jamtrack-record[jamtrack-id=\"#{jamtrack.id}\"]") + jamtrack_record = find(".jamtrack-record[jamtrack-id=\"#{jamtrack.id}\"]") jamtrack_record.find('.detail-value', text: jamtrack.name) jamtrack_record.find('.detail-value', text: jamtrack.recording_type) jamtrack_record.find('.detail-value', text: jamtrack.original_artist) diff --git a/web/spec/support/utilities.rb b/web/spec/support/utilities.rb index d70b273c6..872bd736a 100644 --- a/web/spec/support/utilities.rb +++ b/web/spec/support/utilities.rb @@ -292,11 +292,10 @@ end # will select the value from a easydropdown'ed select element def jk_select(text, select) - # the approach here is to find the hidden select element, and work way back up to the elements that need to be interacted with find(select, :visible => false).find(:xpath, 'ancestor::div[contains(@class, "dropdown easydropdown")]').trigger(:click) find(select, :visible => false).find(:xpath, 'ancestor::div[contains(@class, "dropdown-wrapper") and contains(@class, "easydropdown-wrapper") and contains(@class, "open")]').find('li', text: text).trigger(:click) - + # works, but is 'cheating' because of visible = false #select(genre, :from => 'genres', :visible => false) end