From 1ce510bb1891033f556208ed52325e4ba8eb04ef Mon Sep 17 00:00:00 2001 From: Anthony Davis Date: Wed, 21 May 2014 16:52:11 -0500 Subject: [PATCH] VRFS-1705 - 'monitor' subproj initial commit --- admin/Gemfile | 2 +- monitor/.rspec | 2 + monitor/Gemfile | 11 + monitor/Gemfile.lock | 59 +++ .../spec}/production_spec.rb | 15 +- monitor/spec/spec_helper.rb | 43 ++ monitor/spec/support/client_interactions.rb | 126 +++++ monitor/spec/support/stubs.rb | 9 + monitor/spec/support/utilities.rb | 481 ++++++++++++++++++ ruby/Gemfile | 2 +- web/Gemfile | 2 +- web/spec/spec_helper.rb | 5 +- websocket-gateway/Gemfile | 2 +- 13 files changed, 745 insertions(+), 14 deletions(-) create mode 100755 monitor/.rspec create mode 100755 monitor/Gemfile create mode 100755 monitor/Gemfile.lock rename {web/spec/features => monitor/spec}/production_spec.rb (84%) mode change 100644 => 100755 create mode 100755 monitor/spec/spec_helper.rb create mode 100755 monitor/spec/support/client_interactions.rb create mode 100755 monitor/spec/support/stubs.rb create mode 100755 monitor/spec/support/utilities.rb diff --git a/admin/Gemfile b/admin/Gemfile index df939b390..567f0e491 100644 --- a/admin/Gemfile +++ b/admin/Gemfile @@ -1,7 +1,7 @@ source 'http://rubygems.org' source 'https://jamjam:blueberryjam@int.jamkazam.com/gems/' -devenv = ENV["BUILD_NUMBER"].nil? || ENV["TEST_WWW"] == "1" +devenv = ENV["BUILD_NUMBER"].nil? if devenv gem 'jam_db', :path=> "../db/target/ruby_package" diff --git a/monitor/.rspec b/monitor/.rspec new file mode 100755 index 000000000..5f1647637 --- /dev/null +++ b/monitor/.rspec @@ -0,0 +1,2 @@ +--color +--format progress diff --git a/monitor/Gemfile b/monitor/Gemfile new file mode 100755 index 000000000..6b198c71c --- /dev/null +++ b/monitor/Gemfile @@ -0,0 +1,11 @@ +source "https://rubygems.org" + +gem "rspec" +gem "capybara" +gem "capybara-screenshot" +gem "poltergeist" +gem "launchy" # used for opening pages/screenshots when debugging + +# these used only for the Fixnum#seconds method :-/ +gem "i18n" +gem "activesupport" diff --git a/monitor/Gemfile.lock b/monitor/Gemfile.lock new file mode 100755 index 000000000..9ccd01cdd --- /dev/null +++ b/monitor/Gemfile.lock @@ -0,0 +1,59 @@ +GEM + remote: https://rubygems.org/ + specs: + activesupport (3.1.12) + multi_json (~> 1.0) + addressable (2.3.6) + capybara (2.2.1) + mime-types (>= 1.16) + nokogiri (>= 1.3.3) + rack (>= 1.0.0) + rack-test (>= 0.5.4) + xpath (~> 2.0) + capybara-screenshot (0.3.19) + capybara (>= 1.0, < 3) + launchy + cliver (0.3.2) + diff-lcs (1.2.5) + i18n (0.6.9) + launchy (2.4.2) + addressable (~> 2.3) + mime-types (2.2) + mini_portile (0.5.3) + multi_json (1.10.0) + nokogiri (1.6.1) + mini_portile (~> 0.5.0) + nokogiri (1.6.1-x86-mingw32) + mini_portile (~> 0.5.0) + poltergeist (1.5.0) + capybara (~> 2.1) + cliver (~> 0.3.1) + multi_json (~> 1.0) + websocket-driver (>= 0.2.0) + rack (1.5.2) + rack-test (0.6.2) + rack (>= 1.0) + rspec (2.14.1) + rspec-core (~> 2.14.0) + rspec-expectations (~> 2.14.0) + rspec-mocks (~> 2.14.0) + rspec-core (2.14.8) + rspec-expectations (2.14.5) + diff-lcs (>= 1.1.3, < 2.0) + rspec-mocks (2.14.6) + websocket-driver (0.3.3) + xpath (2.0.0) + nokogiri (~> 1.3) + +PLATFORMS + ruby + x86-mingw32 + +DEPENDENCIES + activesupport + capybara + capybara-screenshot + i18n + launchy + poltergeist + rspec diff --git a/web/spec/features/production_spec.rb b/monitor/spec/production_spec.rb old mode 100644 new mode 100755 similarity index 84% rename from web/spec/features/production_spec.rb rename to monitor/spec/production_spec.rb index 152bb94bc..3db23d9fd --- a/web/spec/features/production_spec.rb +++ b/monitor/spec/production_spec.rb @@ -1,9 +1,14 @@ require 'spec_helper' -# these tests MUST be idempotent and DO use actual production user accounts on www -www = 'http://www.jamkazam.com' +# these tests should be idempotent, and not spammy to other JK users +# because they DO use actual production user accounts on www (see the TestUsers below) -describe "Production site at #{www}", :test_www => true, :js => true, :type => :feature, :capybara_feature => true do +# Jenkins executes rspec on this folder every 15 minutes or so. +# SO don't use this to test something like a public session unless you want all the world to see + +www = ENV['MONITOR_URL'] || 'http://www.jamkazam.com' + +describe "Deployed site at #{www}", :js => true, :type => :feature, :capybara_feature => true do subject { page } @@ -28,7 +33,6 @@ describe "Production site at #{www}", :test_www => true, :js => true, :type => first_name + ' ' + last_name end end - user1 = TestUser.new({ email: 'anthony+jim@jamkazam.com', password: 'j4m!t3st3r', first_name: 'Jim', last_name: 'Smith', id: '68e8eea2-140d-44c1-b711-10d07ce70f96' }) user2 = TestUser.new({ email: 'anthony+john@jamkazam.com', password: 'j4m!t3st3r', first_name: 'John', last_name: 'Jones', id: '5bbcf689-2f73-452d-815a-c4f44e9e7f3e' }) @@ -46,7 +50,7 @@ describe "Production site at #{www}", :test_www => true, :js => true, :type => end it "is possible for #{user1} and #{user2} to see each other online, and to send messages" do - # this example heavily based on text_message_spec.rb + # this example heavily based on text_message_spec.rb in 'web' in_client(user1) do sign_in_poltergeist(user1) @@ -89,4 +93,3 @@ describe "Production site at #{www}", :test_www => true, :js => true, :type => end end - diff --git a/monitor/spec/spec_helper.rb b/monitor/spec/spec_helper.rb new file mode 100755 index 000000000..5df32957d --- /dev/null +++ b/monitor/spec/spec_helper.rb @@ -0,0 +1,43 @@ +require 'rubygems' +require 'active_support/time' +require 'capybara' +require 'capybara/rspec' +require 'capybara-screenshot' +require 'capybara-screenshot/rspec' +require 'capybara/poltergeist' + +require 'support/client_interactions' #TODO: Strip out the helper methods that production_spec does not use +require 'support/utilities' +require 'support/stubs' # to make the JamXXXX warnings go away + +# This file was generated by the `rspec --init` command. Conventionally, all +# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. +# Require this file using `require "spec_helper"` to ensure that it is only +# loaded once. +# +# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration +RSpec.configure do |config| + config.treat_symbols_as_metadata_keys_with_true_values = true + config.run_all_when_everything_filtered = true + config.filter_run :focus + + # Run specs in random order to surface order dependencies. If you find an + # order dependency and want to debug it, you can fix the order by providing + # the seed, which is printed after each run. + # --seed 1234 + config.order = 'random' + + config.include Capybara::DSL +end + +Capybara.javascript_driver = :poltergeist +Capybara.default_driver = :poltergeist +Capybara.run_server = false # since we're testing an app outside this project +Capybara.default_wait_time = 15 # ^^ ditto + +Capybara.configure do |config| + config.match = :one + config.exact_options = true + config.ignore_hidden_elements = true + config.visible_text_only = true +end \ No newline at end of file diff --git a/monitor/spec/support/client_interactions.rb b/monitor/spec/support/client_interactions.rb new file mode 100755 index 000000000..d2f000475 --- /dev/null +++ b/monitor/spec/support/client_interactions.rb @@ -0,0 +1,126 @@ + +# methods here all assume you are in /client + +NOTIFICATION_PANEL = '[layout-id="panelNotifications"]' + +# enters text into the search sidebar +def site_search(text, options = {}) + within('#searchForm') do + fill_in "search-input", with: text + end + + if options[:expand] + page.driver.execute_script("jQuery('#searchForm').submit()") + find('h1', text:'search results') + end +end + +# goes to the musician tile, and tries to find a musician +def find_musician(user) + visit "/client#/musicians" + + timeout = 30 + + start = Time.now + # scroll by 100px until we find a user with the right id + while page.all('#end-of-musician-list').length == 0 + page.execute_script('jQuery("#musician-filter-results").scrollTo("+=100px", 0, {axis:"y"})') + found = page.all(".result-list-button-wrapper[data-musician-id='#{user.id}']") + if found.length == 1 + return found[0] + elsif found.length > 1 + raise "ambiguous results in musician list" + end + + if Time.now - start > timeout + raise "unable to find musician #{user} within #{timeout} seconds" + end + end + + raise "unable to find musician #{user}" +end + +def initiate_text_dialog(user) + + # verify that the chat window is grayed out + site_search(user.first_name, expand: true) + + find("#search-results a[user-id=\"#{user.id}\"][hoveraction=\"musician\"]", text: user.name).hover_intent + find('#musician-hover #btnMessage').trigger(:click) + find('h1', text: 'conversation with ' + user.name) +end + +# sends a text message in the chat interface. +def send_text_message(msg, options={}) + find('#text-message-dialog') # assert that the dialog is showing already + + within('#text-message-dialog form.text-message-box') do + fill_in 'new-text-message', with: msg + end + find('#text-message-dialog .btn-send-text-message').trigger(:click) + find('#text-message-dialog .previous-message-text', text: msg) unless options[:should_fail] + + # close the dialog if caller specified close_on_send + if options[:close_on_send] + find('#text-message-dialog .btn-close-dialog', text: 'CLOSE').trigger(:click) if options[:close_on_send] + page.should have_no_selector('#text-message-dialog') + end + + if options[:should_fail] + find('#notification').should have_text(options[:should_fail]) + end +end + +# sends a chat message during session +def send_chat_message(msg) + find("[layout-id=\"panelChat\"] .chat-sender").should be_visible + + within("[layout-id=\"panelChat\"] .chat-sender form.chat-message-form") do + fill_in 'new-chat-message', with: msg + end + find("[layout-id=\"panelChat\"] .chat-sender .btn-send-chat-message").trigger(:click) +end + +def open_notifications + find("#{NOTIFICATION_PANEL} .panel-header").trigger(:click) +end + + +def hover_intent(element) + element.hover + element.hover +end + +# forces document.hasFocus() to return false +def document_blur + page.evaluate_script(%{(function() { + // save original + if(!window.documentFocus) { window.documentFocus = window.document.hasFocus; } + + window.document.hasFocus = function() { + console.log("document.hasFocus() returns false"); + return false; + } + })()}) +end + +def document_focus + page.evaluate_script(%{(function() { + // save original + if(!window.documentFocus) { window.documentFocus = window.document.hasFocus; } + + window.document.hasFocus = function() { + console.log("document.hasFocus() returns true"); + return true; + } + })()}) +end + +# simulates focus event on window +def window_focus + page.evaluate_script(%{window.jQuery(window).trigger('focus');}) +end + +def close_websocket + page.evaluate_script("window.JK.JamServer.close(true)") +end \ No newline at end of file diff --git a/monitor/spec/support/stubs.rb b/monitor/spec/support/stubs.rb new file mode 100755 index 000000000..86d78ff3e --- /dev/null +++ b/monitor/spec/support/stubs.rb @@ -0,0 +1,9 @@ +module JamRuby + class User + + end +end + +def signin_path + '/signin' +end \ No newline at end of file diff --git a/monitor/spec/support/utilities.rb b/monitor/spec/support/utilities.rb new file mode 100755 index 000000000..9003be855 --- /dev/null +++ b/monitor/spec/support/utilities.rb @@ -0,0 +1,481 @@ + +# add a hover_intent method to element, so that you can do find(selector).hover_intent +module Capybara + module Node + class Element + + def attempt_hover + begin + hover + rescue => e + end + end + def hover_intent + hover + sleep 0.3 + attempt_hover + sleep 0.3 + attempt_hover + end + end + end +end + + + +# holds a single test's session name's, mapped to pooled session names +$capybara_session_mapper = {} + +# called in before (or after) test, to make sure each test run has it's own map of session names +def reset_session_mapper + $capybara_session_mapper.clear + + Capybara.session_name = :default +end + +# manages the mapped session name +def mapped_session_name(session_name) + return :default if session_name == :default # special treatment for the built-in session + $capybara_session_mapper[session_name] ||= 'session_' + $capybara_session_mapper.length.to_s +end + +# in place of ever using Capybara.session_name directly, +# this utility is used to handle the mapping of session names in a way across all tests runs +def in_client(name) + session_name = name.class == JamRuby::User ? name.id : name + + Capybara.session_name = mapped_session_name(session_name) + + yield +end + + +def cookie_jar + Capybara.current_session.driver.browser.current_session.instance_variable_get(:@rack_mock_session).cookie_jar +end + + +#see also ruby/spec/support/utilities.rb +JAMKAZAM_TESTING_BUCKET = 'jamkazam-testing' #at least, this is the name given in jam-ruby +def wipe_s3_test_bucket + s3 = AWS::S3.new(:access_key_id => Rails.application.config.aws_access_key_id, + :secret_access_key => Rails.application.config.aws_secret_access_key) + test_bucket = s3.buckets[JAMKAZAM_TESTING_BUCKET] + if test_bucket.name == JAMKAZAM_TESTING_BUCKET + test_bucket.objects.each do |obj| + obj.delete + end + end +end + + +def sign_in(user) + visit signin_path + fill_in "Email", with: user.email + fill_in "Password", with: user.password + click_button "SIGN IN" + # Sign in when not using Capybara as well. + cookie_jar[:remember_token] = user.remember_token +end + +def set_cookie(k, v) + case Capybara.current_session.driver + when Capybara::Poltergeist::Driver + page.driver.set_cookie(k,v) + when Capybara::RackTest::Driver + headers = {} + Rack::Utils.set_cookie_header!(headers,k,v) + cookie_string = headers['Set-Cookie'] + Capybara.current_session.driver.browser.set_cookie(cookie_string) + when Capybara::Selenium::Driver + page.driver.browser.manage.add_cookie(:name=>k, :value=>v) + else + raise "no cookie-setter implemented for driver #{Capybara.current_session.driver.class.name}" + end +end + +def sign_in_poltergeist(user, options = {}) + validate = options[:validate] + validate = true if validate.nil? + + visit signin_path + fill_in "Email Address:", with: user.email + fill_in "Password:", with: user.password + click_button "SIGN IN" + + wait_until_curtain_gone + + # presence of this means websocket gateway is not working + page.should have_no_selector('.no-websocket-connection') if validate +end + + +def sign_out() + if Capybara.javascript_driver == :poltergeist + page.driver.remove_cookie(:remember_token) + else + page.driver.browser.manage.remove_cookie :name => :remember_token + end +end + +def sign_out_poltergeist(options = {}) + find('.userinfo').hover() + click_link 'Sign Out' + should_be_at_root if options[:validate] +end + +def should_be_at_root + find('h1', text: 'Play music together over the Internet as if in the same room') +end + +def leave_music_session_sleep_delay + # add a buffer to ensure WSG has enough time to expire + sleep_dur = (Rails.application.config.websocket_gateway_connect_time_stale_browser + + Rails.application.config.websocket_gateway_connect_time_expire_browser) * 1.4 + sleep sleep_dur +end + + +def wait_for_ajax(wait=Capybara.default_wait_time) + wait = wait * 10 #(because we sleep .1) + + counter = 0 + while page.execute_script("$.active").to_i > 0 + counter += 1 + sleep(0.1) + raise "AJAX request took longer than #{wait} seconds." if counter >= wait + end +end + +# waits until the user object has been requested, which comes after the 'curtain' is lifted +# and after a call to /api/user/:id for the current user is called initially +def wait_until_user(wait=Capybara.default_wait_time) + wait = wait * 10 #(because we sleep .1) + + counter = 0 + # while page.execute_script("$('.curtain').is(:visible)") == "true" + # counter += 1 + # sleep(0.1) + # raise "Waiting for user to populate took longer than #{wait} seconds." if counter >= wait + # end +end + +def wait_until_curtain_gone + page.should have_no_selector('.curtain') +end + +def wait_to_see_my_track + within('div.session-mytracks') {first('div.session-track.track')} +end + +def repeat_for(duration=Capybara.default_wait_time) + finish_time = Time.now + duration.seconds + loop do + yield + sleep 1 # by default this will execute the block every 1 second + break if (Time.now > finish_time) + end +end + +def determine_test_name(metadata, test_name_buffer = '') + description = metadata[:description_args] + if description.kind_of?(Array) + description = description[0] + end + if metadata.has_key? :example_group + return determine_test_name(metadata[:example_group], "#{description} #{test_name_buffer}") + else + return "#{description} #{test_name_buffer}" + end +end + +def get_description + description = example.metadata[:description_args] + if description.kind_of?(Array) + description = description[0] + end + return description +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 + +# takes, or creates, a unique session description which is returned for subsequent calls to join_session to use +# in finding this session) +def create_session(options={}) + creator = options[:creator] || FactoryGirl.create(:user) + unique_session_desc = options[:description] || "create_join_session #{SecureRandom.urlsafe_base64}" + genre = options[:genre] || 'Rock' + musician_access = options[:musician_access].nil? ? true : options[:musician_access] + fan_access = options[:fan_access].nil? ? true : options[:fan_access] + + # create session in one client + in_client(creator) do + page.driver.resize(1500, 800) # makes sure all the elements are visible + emulate_client + sign_in_poltergeist creator + wait_until_curtain_gone + visit "/client#/createSession" + expect(page).to have_selector('h2', text: 'session info') + + within('#create-session-form') do + fill_in('description', :with => unique_session_desc) + #select(genre, :from => 'genres', :visible => false) # this works, but is 'cheating' because easydropdown hides the native select element + jk_select(genre, '#create-session-form select[name="genres"]') + + jk_select(musician_access ? 'Public' : 'Private', '#create-session-form select#musician-access') + jk_select(fan_access ? 'Public' : 'Private', '#create-session-form select#fan-access') + find('#create-session-form div.musician-access-false.iradio_minimal').trigger(:click) + find('div.intellectual-property ins').trigger(:click) + find('#btn-create-session').trigger(:click) # fails if page width is low + end + + # verify that the in-session page is showing + expect(page).to have_selector('h2', text: 'my tracks') + find('#session-screen .session-mytracks .session-track') + end + + return creator, unique_session_desc, genre + +end + +# this code assumes that there are no music sessions in the database. it should fail on the +# find('.join-link') call if > 1 session exists because capybara will complain of multiple matches +def join_session(joiner, options) + description = options[:description] + + in_client(joiner) do + page.driver.resize(1500, 800) # makes sure all the elements are visible + emulate_client + sign_in_poltergeist joiner + wait_until_curtain_gone + visit "/client#/findSession" + + # verify the session description is seen by second client + expect(page).to have_text(description) + find('.join-link').trigger(:click) + find('#btn-accept-terms').trigger(:click) + expect(page).to have_selector('h2', text: 'my tracks') + find('#session-screen .session-mytracks .session-track') + end +end + + + +def emulate_client + page.driver.headers = { 'User-Agent' => ' JamKazam ' } +end + +def create_join_session(creator, joiners=[], options={}) + options[:creator] = creator + creator, unique_session_desc = create_session(options) + + # find session in second client + joiners.each do |joiner| + join_session(joiner, description: unique_session_desc) + end + + return creator, unique_session_desc +end + +def formal_leave_by user + in_client(user) do + find('#session-leave').trigger(:click) + #find('#btn-accept-leave-session').trigger(:click) + expect(page).to have_selector('h2', text: 'feed') + end +end + +def start_recording_with(creator, joiners=[], genre=nil) + create_join_session(creator, joiners, {genre: genre}) + in_client(creator) do + find('#recording-start-stop').trigger(:click) + find('#recording-status').should have_content 'Stop Recording' + end + joiners.each do |joiner| + in_client(joiner) do + find('#notification').should have_content 'started a recording' + find('#recording-status').should have_content 'Stop Recording' + end + end +end + +def stop_recording + find('#recording-start-stop').trigger(:click) +end + +def assert_recording_finished + find('#recording-status').should have_content 'Make a Recording' + should have_selector('h1', text: 'recording finished') +end + +def check_recording_finished_for(users=[]) + users.each do |user| + in_client(user) do + assert_recording_finished + end + end +end + +def claim_recording(name, description) + find('#recording-finished-dialog h1') + fill_in "claim-recording-name", with: name + fill_in "claim-recording-description", with: description + find('#keep-session-recording').trigger(:click) + page.should have_no_selector('h1', text: 'recording finished') +end + +def set_session_as_private() + find('#session-settings-button').trigger(:click) + within('#session-settings-dialog') do + jk_select("Private", '#session-settings-dialog #session-settings-musician-access') + #select('Private', :from => 'session-settings-musician-access') + find('#session-settings-dialog-submit').trigger(:click) + end + # verify it's dismissed + page.should have_no_selector('h1', text: 'update session settings') +end + +def set_session_as_public() + find('#session-settings-button').trigger(:click) + within('#session-settings-dialog') do + jk_select("Public", '#session-settings-dialog #session-settings-musician-access') + # select('Public', :from => 'session-settings-musician-access') + find('#session-settings-dialog-submit').trigger(:click) + end + # verify it's dismissed + page.should have_no_selector('h1', text: 'update session settings') +end + +def get_options(selector) + find(selector, :visible => false).all('option', :visible => false).collect(&:text).uniq +end + +def selected_genres(selector='#session-settings-genre') + page.evaluate_script("JK.GenreSelectorHelper.getSelectedGenres('#{selector}')") +end + +def random_genre + ['African', + 'Ambient', + 'Asian', + 'Blues', + 'Classical', + 'Country', + 'Electronic', + 'Folk', + 'Hip Hop', + 'Jazz', + 'Latin', + 'Metal', + 'Pop', + 'R&B', + 'Reggae', + 'Religious', + 'Rock', + 'Ska', + 'Other'].sample +end + +def change_session_genre #randomly just change it + here = 'select.genre-list' + #wait_for_ajax + find('#session-settings-button').trigger(:click) + find('#session-settings-dialog') # ensure the dialog is visible + within('#session-settings-dialog') do + wait_for_ajax + @new_genre = get_options(here).-(["Select Genre"]).-(selected_genres).sample.to_s + jk_select(@new_genre, '#session-settings-dialog select[name="genres"]') + wait_for_ajax + find('#session-settings-dialog-submit').trigger(:click) + end + return @new_genre +end + +def get_session_genre + here = 'select.genre-list' + find('#session-settings-button').trigger(:click) + wait_for_ajax + @current_genres = selected_genres + find('#session-settings-dialog-submit').trigger(:click) + return @current_genres.join(" ") +end + +def find_session_contains?(text) + visit "/client#/findSession" + wait_for_ajax + within('#find-session-form') do + expect(page).to have_text(text) + end +end + +def assert_all_tracks_seen(users=[]) + users.each do |user| + in_client(user) do + users.reject {|u| u==user}.each do |other| + find('div.track-label', text: other.name) + #puts user.name + " is able to see " + other.name + "\'s track" + end + end + end +end + +def view_profile_of user + id = user.kind_of?(JamRuby::User) ? user.id : user + # assume some user signed in already + visit "/client#/profile/#{id}" + wait_until_curtain_gone +end + +def view_band_profile_of band + id = band.kind_of?(JamRuby::Band) ? band.id : + band.kind_of?(JamRuby::BandMusician) ? band.bands.first.id : band + visit "/client#/bandProfile/#{id}" + wait_until_curtain_gone +end + +def sidebar_search_for string, category + visit "/client#/home" + find('#search-input') + fill_in "search", with: string + sleep 1 + page.execute_script("JK.Sidebar.searchForInput()") + wait_for_ajax + jk_select(category, "search_text_type") + wait_for_ajax +end + +def show_user_menu + page.execute_script("$('ul.shortcuts').show()") + #page.execute_script("JK.UserDropdown.menuHoverIn()") +end + +# wait for the easydropdown version of the specified select element to become visible +def wait_for_easydropdown(select) + find(select, :visible => false).find(:xpath, 'ancestor::div[contains(@class, "dropdown easydropdown")]') +end + +# defaults to enter key (13) +def send_key(selector, keycode = 13) + keypress_script = "var e = $.Event('keyup', { keyCode: #{keycode} }); jQuery('#{selector}').trigger(e);" + page.driver.execute_script(keypress_script) + +end + +def special_characters + ["?", "[", "]", "/", "\\", "=", "<", ">", ":", ";", ",", "'", "\"", "&", "$", "#", "*", "(", ")", "|", "~", "`", "!", "{", "}"] +end + +def garbage length + output = '' + length.times { output << special_characters.sample } + output.slice(0, length) +end \ No newline at end of file diff --git a/ruby/Gemfile b/ruby/Gemfile index 7a53e7f6b..7ecd9ef31 100644 --- a/ruby/Gemfile +++ b/ruby/Gemfile @@ -4,7 +4,7 @@ unless ENV["LOCAL_DEV"] == "1" source 'https://jamjam:blueberryjam@int.jamkazam.com/gems/' end -devenv = ENV["BUILD_NUMBER"].nil? || ENV["TEST_WWW"] == "1" +devenv = ENV["BUILD_NUMBER"].nil? if devenv gem 'jam_db', :path=> "../db/target/ruby_package" diff --git a/web/Gemfile b/web/Gemfile index 1ff24b15f..f494b74a4 100644 --- a/web/Gemfile +++ b/web/Gemfile @@ -5,7 +5,7 @@ unless ENV["LOCAL_DEV"] == "1" end # Look for $WORKSPACE, otherwise use "workspace" as dev path. -devenv = ENV["BUILD_NUMBER"].nil? || ENV["TEST_WWW"] == "1" +devenv = ENV["BUILD_NUMBER"].nil? if devenv gem 'jam_db', :path=> "../db/target/ruby_package" diff --git a/web/spec/spec_helper.rb b/web/spec/spec_helper.rb index 5af0fbc83..94960bf13 100644 --- a/web/spec/spec_helper.rb +++ b/web/spec/spec_helper.rb @@ -30,7 +30,7 @@ db_config = YAML::load(File.open('config/database.yml'))["test"] bputs "before recreate db" -SpecDb::recreate_database(db_config) unless ENV["TEST_WWW"] == "1" +SpecDb::recreate_database(db_config) bputs "before connect db" ActiveRecord::Base.establish_connection(YAML::load(File.open('config/database.yml'))["test"]) @@ -162,9 +162,6 @@ bputs "before register capybara" config.filter_run_excluding slow: true unless ENV['RUN_SLOW_TESTS'] == "1" || ENV['SLOW'] == "1" || ENV['ALL_TESTS'] == "1" config.filter_run_excluding aws: true unless ENV['RUN_AWS_TESTS'] == "1" || ENV['AWS'] == "1" || ENV['ALL_TESTS'] == "1" - # by default, do not run production web tests -- even when "ALL_TESTS" is desired - config.filter_run_excluding test_www: true unless ENV['TEST_WWW'] == "1" - # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures config.fixture_path = "#{::Rails.root}/spec/fixtures" diff --git a/websocket-gateway/Gemfile b/websocket-gateway/Gemfile index 4952d17e7..24daf06e9 100644 --- a/websocket-gateway/Gemfile +++ b/websocket-gateway/Gemfile @@ -5,7 +5,7 @@ unless ENV['LOCAL_DEV'] == '1' end # Look for $WORKSPACE, otherwise use "workspace" as dev path. -devenv = ENV["BUILD_NUMBER"].nil? || ENV["TEST_WWW"] == "1" +devenv = ENV["BUILD_NUMBER"].nil? if devenv gem 'jam_db', :path=> "../db/target/ruby_package"