jam-cloud/web/spec/features/find_sessions_spec.rb

262 lines
8.0 KiB
Ruby

require 'spec_helper'
describe "Find Session", :js => true, :type => :feature, :capybara_feature => true, :slow => true do
subject { page }
let(:austin) { austin_geoip }
let(:dallas) { dallas_geoip }
let(:user) { FactoryGirl.create(:user, last_jam_locidispid: austin_geoip[:locidispid], last_jam_addr: austin_ip) }
let(:finder) { FactoryGirl.create(:user, last_jam_locidispid: dallas_geoip[:locidispid], last_jam_addr: dallas_ip) }
before(:each) do
UserMailer.deliveries.clear
ActiveMusicSession.delete_all
SessionInfoComment.delete_all
Notification.delete_all
RsvpRequestRsvpSlot.delete_all
RsvpRequest.delete_all
RsvpSlot.delete_all
Invitation.delete_all
MusicSession.delete_all
end
describe "basic" do
before(:each) do
create_phony_database
emulate_client
fast_signin(user, "/client#/findSession")
FactoryGirl.create(:friendship, :user => user, :friend => finder)
end
# when no sessions have been created:
it "shows there are no sessions" do
# verify no sessions are found
expect(page).to have_selector('#no-active-sessions')
expect(page).to have_selector('#no-scheduled-sessions')
end
it "finds another public session" do
create_join_session(user, [finder])
end
describe "listing behavior" do
describe "active sessions" do
let!(:session1_creator) { FactoryGirl.create(:single_user_session, last_jam_locidispid: dallas_geoip[:locidispid], last_jam_addr: dallas_ip) }
it "find one active session" do
find('#btn-refresh').trigger(:click)
page.assert_selector('div#sessions-active .found-session', count: 1)
end
it "find many active sessions" do
20.times do
FactoryGirl.create(:single_user_session)
end
find('#btn-refresh').trigger(:click)
page.assert_selector('div#sessions-active .found-session', count: 20)
# attempt to scroll down--the end of session list should show, and there should now be 21 items
# page.execute_script('jQuery("#findSession .content-body-scroller").scrollTo("100%",100)') #scroll to the bottom of the element
# find('#end-of-session-list')
# page.all('div#sessions-active .found-session').count.should == 21
end
it "shows latency information correctly" do
# this will try to show all 6 latency badges. unknown, good, fair, poor, unacceptable, and me
verify_find_session_score(nil, '#sessions-active', user, session1_creator)
verify_find_session_score(3, '#sessions-active', user, session1_creator)
verify_find_session_score(40, '#sessions-active', user, session1_creator)
verify_find_session_score(80, '#sessions-active', user, session1_creator)
verify_find_session_score(110, '#sessions-active', user, session1_creator)
fast_signout
fast_signin(session1_creator, "/client#/findSession")
verify_find_session_score(nil, '#sessions-active', session1_creator, session1_creator)
# this should cause it to move to the scheduled session view; we'll check all the values again
ActiveMusicSession.delete_all
verify_find_session_score(nil, '#sessions-scheduled', session1_creator, session1_creator)
fast_signout
fast_signin(user, "/client#/findSession")
verify_find_session_score(nil, '#sessions-scheduled', user, session1_creator)
verify_find_session_score(3, '#sessions-scheduled', user, session1_creator)
verify_find_session_score(40, '#sessions-scheduled', user, session1_creator)
verify_find_session_score(80, '#sessions-scheduled', user, session1_creator)
verify_find_session_score(110, '#sessions-scheduled', user, session1_creator)
end
end
describe "scheduled sessions" do
let!(:scheduled_session) {FactoryGirl.create(:music_session) }
it "find one scheduled session" do
find('#btn-refresh').trigger(:click)
page.assert_selector('div#sessions-scheduled .found-session', count: 1)
end
it "finds many scheduled sessions" do
20.times do
FactoryGirl.create(:music_session)
end
find('#btn-refresh').trigger(:click)
page.assert_selector('div#sessions-scheduled .found-session', count: 20)
page.execute_script('jQuery("#findSession .content-body-scroller").scrollTo("100%",100)') #scroll to the bottom of the element
find('#no-scheduled-sessions')
page.assert_selector('div#sessions-scheduled .found-session', count: 21)
end
end
end
end
describe "active sessions" do
it "should render session details" do
# name
# genre
# description
# notation files
# musicians in session
# approved RSVPs
# open slots
# latency tag
# chat language
# musician access
# fan access
# legal policy
end
it "should allow user to join if invited" do
end
it "should allow user to join if musician_access is true" do
end
it "should allow user to join if invited and musician_access is false" do
end
end
describe "scheduled sessions" do
it "should render session details" do
# name
# genre
# description
# notation files
# approved RSVPs
# open slots
# latency tag
# chat language
# musician access
# fan access
# legal policy
end
it "should allow user to RSVP if invited" do
end
it "should allow user to RSVP if open_rsvps is true" do
end
it "should allow user to RSVP if invited and open_rsvps is false" do
end
end
describe "rsvp behavior" do
before(:each) do
stub_const("APP_CONFIG", web_config)
end
it "handles is_unstructured_rsvp sessions correctly" do
# create an unstructured session
music_session = FactoryGirl.create(:music_session, creator: user, is_unstructured_rsvp: true)
fast_signin(finder, Nav.find_session)
# verify it says the right thing in the 'Still Needed' section
find("#sessions-scheduled tr.found-session div.instruments", text: 'Any Instrument (Any Skill Level)')
# bring up the RSVP dialog
find('.rsvp-link').trigger(:click)
# select the only option (Any Instrument)
find('.rsvp-instruments input[value="unstructured"]').trigger(:click)
# submit the RSVP
find('#btnSubmitRsvp').trigger(:click)
# TODO: verify that the UI works - after VRFS-1892
end
it "RSVP text shows correctly" do
music_session = FactoryGirl.create(:music_session, creator: user)
fast_signin(user, Nav.find_session)
find("#sessions-scheduled .rsvp-msg span.text", text: "You have been confirmed for this session. ")
sign_out
# create a slot so the session can be joined
rsvp_slot = FactoryGirl.create(:rsvp_slot, music_session: music_session)
go_to_root
fast_signin(finder, Nav.find_session)
find("#sessions-scheduled .rsvp-link")
# now manipulate the database to make different states for the rsvp link/text area in find sessions
# make a request (not yet chosen)
rsvp_request = FactoryGirl.create(:rsvp_request_for_slots, chosen: nil, user: finder, slots: [rsvp_slot])
# first state: an unconfirmed RSVP
go_to_root
fast_signin(finder, Nav.find_session)
find("#sessions-scheduled .rsvp-msg span.text", text: "You have RSVP'ed to this session. ")
rsvp_request.rsvp_requests_rsvp_slots[0].chosen = true
rsvp_request.rsvp_requests_rsvp_slots[0].save!
# second state: a connfirmed RSVP
go_to_root
fast_signin(finder, Nav.find_session)
find("#sessions-scheduled .rsvp-msg span.text", text: "You have been confirmed for this session. ")
# need to now CANCEL, and check what it says: // VRFS-1891
# also need to check that it is open_rsvp = false.
end
end
end