VRFS-1666 add test, finish

This commit is contained in:
Bert Owen 2014-06-20 18:52:36 +02:00
parent 6096687b07
commit e200747096
3 changed files with 202 additions and 16 deletions

View File

@ -438,7 +438,7 @@
<script type="text/template" id="template-session-buttons">
<div class="sessionbuttons-holder">
<a class="button-orange" href="http://jamkazam.desk.com/" target="_blank">HELP</a>
<a class="button-orange btn-help" href="http://jamkazam.desk.com/" target="_blank">HELP</a>
<a class="button-orange btn-back" href="#">BACK</a>
<a class="button-orange btn-next" href="#">NEXT</a>
</div>

View File

@ -1,17 +1,19 @@
require 'spec_helper'
describe "Create Session Flow", :js => true, :type => :feature, :capybara_feature => true do
pending "implementing...."
context "create session flow" do
let(:user1) { FactoryGirl.create(:user) }
let(:user2) { FactoryGirl.create(:user) }
let(:user1) { FactoryGirl.create(:user) }
let(:user2) { FactoryGirl.create(:user) }
context "create session flow ui" do
before(:each) do
MusicSession.delete_all
ActiveMusicSession.delete_all
sign_in_poltergeist(user1)
in_client(user1) do
page.driver.resize(1500, 800) # makes sure all the elements are visible
emulate_client
sign_in_poltergeist user1
wait_until_curtain_gone
visit "/client#/createSession"
end
end
@ -24,16 +26,19 @@ describe "Create Session Flow", :js => true, :type => :feature, :capybara_featur
find('div#scheduled-session-not-found')
find('div[info-id="start-scheduled"]')
page.should have_css(".session-stepnumber", :count => 2)
page.should have_css(".session-stepnumber .session-stepactive", :count => 1)
page.should have_css(".session-stepnumber.session-stepactive", :count => 1)
page.should_not have_css(".btn-back")
page.should have_css(".btn-next")
page.should have_css(".btn-help")
end
end
it "select option for scheduling a session" do
in_client(user1) do
find('li[create-type="schedule-future"] ins').trigger(:click)
find('div[info-id="scheduled-future"]')
find('div[info-id="schedule-future"]')
page.should have_css(".session-stepnumber", :count => 5)
page.should have_css(".session-stepnumber .session-stepactive", :count => 1)
page.should have_css(".session-stepnumber.session-stepactive", :count => 1)
find('div#schedule-future-wrapper')
find('h3', text: 'When will the session happen?')
find('input#session-start-date')
@ -49,25 +54,25 @@ describe "Create Session Flow", :js => true, :type => :feature, :capybara_featur
find('li[create-type="rsvp"] ins').trigger(:click)
find('div[info-id="rsvp"]')
page.should have_css(".session-stepnumber", :count => 5)
page.should have_css(".session-stepnumber .session-stepactive", :count => 1)
page.should have_css(".session-stepnumber.session-stepactive", :count => 1)
end
end
it "select option for starting session right now" do
it "select option for starting session right now" do
in_client(user1) do
find('li[create-type="immediately"] ins').trigger(:click)
find('div[info-id="immediately"]')
page.should have_css(".session-stepnumber", :count => 5)
page.should have_css(".session-stepnumber .session-stepactive", :count => 1)
page.should have_css(".session-stepnumber.session-stepactive", :count => 1)
end
end
it "select option for starting quick session" do
in_client(user1) do
in_client(user1) do
find('li[create-type="quick-start"] ins').trigger(:click)
find('div[info-id="quick-start"]')
page.should have_css(".session-stepnumber", :count => 2)
page.should have_css(".session-stepnumber .session-stepactive", :count => 1)
page.should have_css(".session-stepnumber.session-stepactive", :count => 1)
end
end
end
@ -83,34 +88,161 @@ describe "Create Session Flow", :js => true, :type => :feature, :capybara_featur
it "initial status" do
in_client(user1) do
find('.session-step-title', text: 'What Are You Playing?')
page.should have_css(".btn-back")
page.should have_css(".btn-next")
page.should have_css(".btn-help")
end
end
it "validates genre, name and description" do
in_client(user1) do
find('.btn-next').trigger(:click)
find('ul.error-text li', text: 'You must select a genre.')
find('ul.error-text li', text: 'Name is required')
find('ul.error-text li', text: 'Description is required')
end
end
end
describe "step 3" do
before(:each) do
in_client(user1) do
find('li[create-type="schedule-future"] ins').trigger(:click)
find('.btn-next').trigger(:click)
jk_select("Rock", '#create-session-form select[name="genres"]')
fill_in('session-name', :with => "Test Name")
fill_in('session-description', :with => "Test Description")
find('.btn-next').trigger(:click)
end
end
it "initial status" do
end
find('.session-step-title', text: 'Who Is Playing With You?')
find('input#session-plus-musicians[type="checkbox"][checked="checked"]')
find('input[type="checkbox"][session-instrument-id="electric guitar"][checked="checked"]')
expect( find(:css, 'select#session-language-list').value ).to eq('en')
page.should have_css(".session-stepnumber", :count => 5)
page.should have_css(".session-stepnumber.session-stepactive", :count => 1)
page.should have_css(".btn-back")
page.should have_css(".btn-next")
page.should have_css(".btn-help")
end
end
describe "step 4" do
before(:each) do
in_client(user1) do
find('li[create-type="schedule-future"] ins').trigger(:click)
find('.btn-next').trigger(:click)
jk_select("Rock", '#create-session-form select[name="genres"]')
fill_in('session-name', :with => "Test Name")
fill_in('session-description', :with => "Test Description")
find('.btn-next').trigger(:click)
find('.btn-next').trigger(:click)
end
end
it "initial status" do
find('.session-step-title', text: 'What Are Your Policies?')
find('input#session-policy-standard[type="radio"][checked="checked"]')
find('input#session-policy-confirm[type="checkbox"]')
expect( find(:css, 'select#session-musician-access').value ).to eq('musicians-approval')
expect( find(:css, 'select#session-fans-access').value ).to eq('listen-chat-each')
page.should have_css(".btn-back")
page.should have_css(".btn-next")
page.should have_css(".btn-help")
end
it "validates terms of service checkbox" do
find('.btn-next').trigger(:click)
find('ul.error-text li', text: 'You must accept the Session Policy.')
end
end
describe "step 5" do
before(:each) do
in_client(user1) do
find('li[create-type="schedule-future"] ins').trigger(:click)
find('.btn-next').trigger(:click)
jk_select("Rock", '#create-session-form select[name="genres"]')
fill_in('session-name', :with => "Test Name")
fill_in('session-description', :with => "Test Description")
find('.btn-next').trigger(:click)
find('.btn-next').trigger(:click)
find('div#divSessionPolicy ins').trigger(:click)
find('.btn-next').trigger(:click)
end
it "initial status" do
find('.session-step-title', text: 'Review & Confirm?')
find('em#session-name-disp', text: 'Test (Rock)')
find('div#session-description-disp', text: 'Test Description')
find('div#session-language-disp', text: 'English')
find('div#session-invited-disp', text: 'Any interested JamKazam musicians that I approve')
find('div#session-instruments-me-disp', text: 'Electric Guitar')
find('div#session-musician-access-disp', text: 'Musicians: Musicians may join by approval')
find('div#session-fans-access-disp', text: 'Fans: Fans may listen, chat with each other')
find('div#session-policy-disp', text: 'Standard')
page.should have_css(".btn-back")
page.should have_css(".btn-next")
page.should have_css(".btn-help")
end
end
end
end
context "create session flow backend" do
describe "schedule a session" do
it "schedule a session" do
schedule_session({creator: user1})
end
it "start a session after scheduling" do
pending "Waiting Brian to fix rsvp bug..."
MusicSession.delete_all
schedule_session({creator: user1})
in_client(user1) do
visit "/client#/createSession"
find('.btn-next').trigger(:click)
find('.btn-next').trigger(:click)
expect(page).to have_selector('h2', text: 'my tracks')
find('#session-screen .session-mytracks .session-track')
end
end
end
it "start quick session" do
page.driver.resize(1500, 800) # makes sure all the elements are visible
emulate_client
sign_in_poltergeist user1
wait_until_curtain_gone
visit "/client#/createSession"
expect(page).to have_selector('h1', text: 'create session')
find('li[create-type="quick-start"] ins').trigger(:click)
find('div[info-id="quick-start"]')
find('.btn-next').trigger(:click)
find('.btn-next', text: 'START SESSION').trigger(:click)
expect(page).to have_selector('h2', text: 'my tracks')
find('#session-screen .session-mytracks .session-track')
end
end
end

View File

@ -282,6 +282,60 @@ def create_session(options={})
end
def schedule_session(options = {})
creator = options[:creator] || FactoryGirl.create(:user)
unique_session_name = options[:name] || "schedule_session #{SecureRandom.urlsafe_base64}"
unique_session_desc = options[:description] || "schedule_session #{SecureRandom.urlsafe_base64}"
genre = options[:genre] || 'Rock'
musician_access = options[:musician_access].nil? ? true : options[:musician_access]
approval_required = options[:approval_required].nil? ? true : options[:approval_required]
fan_access = options[:fan_access].nil? ? true : options[:fan_access]
fan_chat = options[:fan_chat].nil? ? true : options[:fan_chat]
musician_access_value = 'Musicians may join by approval'
fan_permission_value = 'Fans may listen, chat with each other'
if musician_access && !approval_required
musician_access_value = 'Musicians may join at will'
elsif !musician_access && !approval_required
musician_access_value = 'Only RSVP musicians may join'
end
if fan_access && fan_chat
fan_permission_value = 'Fans may listen, chat with the band'
elsif !fan_access && !fan_chat
fan_permission_value = 'Fans may not listen to session'
end
# schedule a 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('h1', text: 'create session')
find('li[create-type="schedule-future"] ins').trigger(:click)
find('.btn-next').trigger(:click)
jk_select(genre, '#create-session-form select[name="genres"]')
fill_in('session-name', :with => unique_session_name)
fill_in('session-description', :with => unique_session_desc)
find('.btn-next').trigger(:click)
find('.btn-next').trigger(:click)
find('div#divSessionPolicy ins').trigger(:click)
jk_select(musician_access_value, '#session-musician-access')
jk_select(fan_permission_value, '#session-fans-access')
find('.btn-next').trigger(:click)
find('.btn-next', text: 'PUBLISH SESSION').trigger(:click)
find('div[type="createSession"]')
end
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)