merging
This commit is contained in:
commit
0b3b4c5dfa
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
--color
|
||||
--format progress
|
||||
|
|
@ -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"
|
||||
|
|
@ -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
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
require 'spec_helper'
|
||||
|
||||
# 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)
|
||||
|
||||
# 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 }
|
||||
|
||||
before(:all) do
|
||||
Capybara.javascript_driver = :poltergeist
|
||||
Capybara.current_driver = Capybara.javascript_driver
|
||||
Capybara.app_host = www
|
||||
Capybara.run_server = false
|
||||
Capybara.default_wait_time = 10
|
||||
end
|
||||
|
||||
TestUser = Class.new do
|
||||
attr_accessor :email, :password, :first_name, :last_name, :id
|
||||
|
||||
def initialize(h)
|
||||
h.each {|k,v| send("#{k}=",v)}
|
||||
end
|
||||
|
||||
alias :to_s :first_name
|
||||
|
||||
def name
|
||||
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' })
|
||||
|
||||
# before(:each) do
|
||||
# emulate_client
|
||||
# end
|
||||
|
||||
it "is possible for #{user1} to sign in and not get disconnected within 30 seconds" do
|
||||
in_client(user1) do
|
||||
sign_in_poltergeist user1
|
||||
repeat_for(30.seconds) do
|
||||
expect(page).to_not have_selector('.no-websocket-connection') #looks for reconnect dialog every 1 second
|
||||
end
|
||||
end
|
||||
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 in 'web'
|
||||
|
||||
in_client(user1) do
|
||||
sign_in_poltergeist(user1)
|
||||
end
|
||||
|
||||
test_message = "#{SecureRandom.uuid} - Hey #{user1}!"
|
||||
test_response = "#{SecureRandom.uuid} - Hey yourself, #{user2}!"
|
||||
test_goodbye = "#{SecureRandom.uuid} - OK bye!"
|
||||
|
||||
in_client(user2) do
|
||||
sign_in_poltergeist(user2)
|
||||
expect(page).to have_xpath(
|
||||
"//div[@class='friend-name' and @user-id='#{user1.id}']/span[@class='friend-status']",
|
||||
:text => "Available" )
|
||||
|
||||
site_search(user1.name, expand: true)
|
||||
find("#search-results a[user-id=\"#{user1.id}\"][hoveraction=\"musician\"]", text: user1.name).hover_intent
|
||||
find('#musician-hover #btnMessage').trigger(:click)
|
||||
find('h1', text: 'conversation with ' + user1.name)
|
||||
send_text_message(test_message)
|
||||
end
|
||||
|
||||
in_client(user1) do
|
||||
expect(page).to have_xpath(
|
||||
"//div[@class='friend-name' and @user-id='#{user2.id}']/span[@class='friend-status']",
|
||||
:text => "Available" )
|
||||
find('#notification #ok-button').trigger(:click)
|
||||
find('h1', text: 'conversation with ' + user2.name)
|
||||
find('.previous-message-text', text: test_message)
|
||||
send_text_message(test_response, close_on_send: true)
|
||||
end
|
||||
|
||||
in_client(user2) do
|
||||
find('.previous-message-text', text: test_response)
|
||||
send_text_message(test_goodbye, close_on_send: true)
|
||||
end
|
||||
|
||||
in_client(user1) { sign_out_poltergeist }
|
||||
in_client(user2) { sign_out_poltergeist }
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
module JamRuby
|
||||
class User
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def signin_path
|
||||
'/signin'
|
||||
end
|
||||
|
|
@ -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
|
||||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Reference in New Issue