118 lines
4.5 KiB
Ruby
Executable File
118 lines
4.5 KiB
Ruby
Executable File
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
|
|
# (theoretically) Google Analytics does not track requests made from this fake jam client
|
|
|
|
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
|
|
end
|
|
|
|
before { puts "\n" }
|
|
after { puts "\n\n" }
|
|
|
|
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
|
|
|
|
if www =~ /staging/
|
|
# use staging accounts
|
|
user1 = TestUser.new({ email: 'anthony+jim@jamkazam.com', password: 'j4m!t3st3r', first_name: 'Jim', last_name: 'Smith', id: '43fb60a7-7b6a-4aa6-af3c-59b1e58a842b' })
|
|
user2 = TestUser.new({ email: 'anthony+john@jamkazam.com', password: 'j4m!t3st3r', first_name: 'John', last_name: 'Jones', id: '54c5d5c1-aa44-4db8-9bac-922ead64162e' })
|
|
else
|
|
# use production accounts
|
|
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' })
|
|
end
|
|
|
|
it "is possible for #{user1} to sign in and not get disconnected within 30 seconds" do
|
|
in_client(user1) do
|
|
puts "\n *** #{user1}'s client *** \n"
|
|
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
|
|
puts "\n *** #{user1}'s client *** \n"
|
|
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
|
|
puts "\n *** #{user2}'s client *** \n"
|
|
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
|
|
puts "\n *** #{user1}'s client *** \n"
|
|
expect(page).to have_xpath(
|
|
"//div[@class='friend-name' and @user-id='#{user2.id}']/span[@class='friend-status']",
|
|
:text => "Available" )
|
|
find('#notification #btn-reply').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
|
|
puts "\n *** #{user2}'s client *** \n"
|
|
find('.previous-message-text', text: test_response)
|
|
send_text_message(test_goodbye, close_on_send: true)
|
|
end
|
|
|
|
in_client(user1) { puts "\n *** #{user1}'s client *** \n"; sign_out_poltergeist }
|
|
in_client(user2) { puts "\n *** #{user2}'s client *** \n"; sign_out_poltergeist }
|
|
end
|
|
|
|
let(:queue_limit) { 5 }
|
|
|
|
it "should not find any stuck workers in resque queues" do
|
|
page.driver.basic_authorize('jamjam','blueberryjam')
|
|
visit '/admin/resque/queues'
|
|
page.all('tr:not(.failure) .size').each do |job_queue|
|
|
expect(job_queue.text.to_i).to be < queue_limit
|
|
end
|
|
#this (maybe mistakenly) ignores the .failure queue, since it can be in the hundreds - VRFS-1930
|
|
end
|
|
end
|