2014-04-01 23:38:36 +00:00
require 'spec_helper'
2014-06-25 21:54:31 +00:00
describe " Launch App " , :js = > true , :type = > :feature , :capybara_feature = > true do
2014-04-01 23:38:36 +00:00
subject { page }
let ( :user ) { FactoryGirl . create ( :user ) }
2014-06-25 21:54:31 +00:00
let ( :ams ) { FactoryGirl . create ( :active_music_session , creator : user ) }
before ( :each ) do
ActiveMusicSession . delete_all
MusicSession . delete_all
end
2014-04-01 23:38:36 +00:00
2016-07-17 15:16:27 +00:00
shared_examples_for :launch_not_supported do | options |
2014-04-01 23:38:36 +00:00
it " should indicate not supported " do
sign_in_poltergeist user
2014-06-25 21:54:31 +00:00
ams . touch if options [ :need_session ]
2014-04-01 23:38:36 +00:00
visit options [ :screen_path ]
2014-06-25 21:54:31 +00:00
if options [ :actions ]
options [ :actions ] . call ( page )
end
2014-04-01 23:38:36 +00:00
should have_selector ( 'h1' , text : 'Application Notice' )
2014-04-21 15:17:40 +00:00
if options [ :gear_modal ] && options [ :gear_modal ] == true
should have_selector ( 'p' , text : 'To configure your audio gear, you must use the JamKazam application. Please download and install the application if you have not done so already.' )
else
should have_selector ( 'p' , text : 'To create or find and join a session, you must use the JamKazam application. Please download and install the application if you have not done so already.' )
end
2014-04-01 23:38:36 +00:00
find ( 'a.btn-go-to-download-page' ) . trigger ( :click )
2015-03-10 15:29:40 +00:00
find ( 'h2.create-account-header' , text : 'Download the free JamKazam app' )
2014-04-01 23:38:36 +00:00
end
end
2016-07-17 15:16:27 +00:00
shared_examples_for :launch_supported do | options |
2014-04-01 23:38:36 +00:00
it " should indicate supported " do
sign_in_poltergeist user
2014-06-25 21:54:31 +00:00
ams . touch if options [ :need_session ]
2014-04-01 23:38:36 +00:00
visit options [ :screen_path ]
2014-06-25 21:54:31 +00:00
if options [ :actions ]
options [ :actions ] . call ( page )
end
2014-04-01 23:38:36 +00:00
should have_selector ( 'h1' , text : 'Application Notice' )
2014-04-21 15:17:40 +00:00
if options [ :gear_modal ] && options [ :gear_modal ] == true
should have_selector ( 'p' , text : 'To configure your audio gear, you must use the JamKazam application.' )
else
should have_selector ( 'p' , text : 'To create or find and join a session, you must use the JamKazam application.' )
end
2014-04-01 23:38:36 +00:00
should have_selector ( '.btn-launch-app' )
find ( '.btn-launch-app' ) [ 'href' ] . start_with? ( 'jamkazam:' )
end
end
describe " unsupported " do
2014-06-25 21:54:31 +00:00
2014-04-01 23:38:36 +00:00
before do
# emulate mac safari
page . driver . headers = { 'User-Agent' = > 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.74.9 (KHTML, like Gecko) Version/7.0.2 Safari/537.74.9' }
end
2014-06-25 21:54:31 +00:00
it_behaves_like :launch_not_supported , screen_path : '/client#/createSession' , actions : lambda { | page | page . find ( 'li[create-type="quick-start"] ins' ) . trigger ( :click ) ; page . find ( '.btn-next' ) . trigger ( :click ) }
it_behaves_like :launch_not_supported , screen_path : '/client#/createSession' , actions : lambda { | page | page . find ( 'li[create-type="immediately"] ins' ) . trigger ( :click ) ; page . find ( '.btn-next' ) . trigger ( :click ) }
it_behaves_like :launch_not_supported , screen_path : '/client#/createSession' , actions : lambda { | page | page . find ( 'li[create-type="start-scheduled"] ins' ) . trigger ( :click ) ; page . find ( '.btn-next' ) . trigger ( :click ) }
it_behaves_like :launch_not_supported , screen_path : '/client#/findSession' , actions : lambda { | page | page . find ( '.join-link' ) . trigger ( :click ) } , need_session : true
2014-04-21 15:17:40 +00:00
it_behaves_like :launch_not_supported , screen_path : '/client#/account/audio' , gear_modal : true
2014-04-01 23:38:36 +00:00
end
describe " supported " do
before do
# emulate chrome
page . driver . headers = { 'User-Agent' = > 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36' }
end
2014-06-25 21:54:31 +00:00
it_behaves_like :launch_supported , screen_path : '/client#/createSession' , actions : lambda { | page | page . find ( 'li[create-type="quick-start"] ins' ) . trigger ( :click ) ; page . find ( '.btn-next' ) . trigger ( :click ) }
it_behaves_like :launch_supported , screen_path : '/client#/createSession' , actions : lambda { | page | page . find ( 'li[create-type="immediately"] ins' ) . trigger ( :click ) ; page . find ( '.btn-next' ) . trigger ( :click ) }
it_behaves_like :launch_supported , screen_path : '/client#/createSession' , actions : lambda { | page | page . find ( 'li[create-type="start-scheduled"] ins' ) . trigger ( :click ) ; page . find ( '.btn-next' ) . trigger ( :click ) }
it_behaves_like :launch_supported , screen_path : '/client#/findSession' , actions : lambda { | page | page . find ( '.join-link' ) . trigger ( :click ) } , need_session : true
2014-04-21 15:17:40 +00:00
it_behaves_like :launch_supported , screen_path : '/client#/account/audio' , gear_modal : true
2014-04-01 23:38:36 +00:00
end
end