VRFS-4142 - more fixes after more testing (test drive packages)

This commit is contained in:
Seth Call 2016-06-03 08:41:14 -05:00
parent 8b8aa08ac0
commit 7d182e6153
7 changed files with 176 additions and 20 deletions

View File

@ -1132,7 +1132,7 @@ module JamRuby
origin = options[:origin] origin = options[:origin]
test_drive_package_details = options[:test_drive_package] test_drive_package_details = options[:test_drive_package]
test_drive_package = TestDrivePackage.find_by_name(test_drive_package_details[:name]) test_drive_package = TestDrivePackage.find_by_name(test_drive_package_details[:name]) if test_drive_package_details
school = School.find(school_id) if school_id school = School.find(school_id) if school_id
user = User.new user = User.new

View File

@ -1056,7 +1056,7 @@ UserStore = context.UserStore
phrase = this.slotTimePhrase(this.counteredSlot()) phrase = this.slotTimePhrase(this.counteredSlot())
action = `<p>Has suggested a different time for your lesson.</p>` action = `<p>Has suggested a different time for your lesson.</p>`
detail = `<p>Proposed alternate day/time is {phrase}</p>` detail = `<p className="counter-stmt">Proposed alternate day/time is {phrase}</p>`
`<div className="contents"> `<div className="contents">
<div className="row"> <div className="row">

View File

@ -324,7 +324,7 @@ UserStore = context.UserStore
if response.test_drive?.teacher_id if response.test_drive?.teacher_id
teacher_id = response.test_drive.teacher_id teacher_id = response.test_drive.teacher_id
if testDriveCount == '1' if testDriveCount == '1'
text = "You have purchased 1 TestDrive credit and have used it to request a JamClass with #{@state.teacher.name}. The teacher has received your request and should respond shortly." text = "You have purchased 1 TestDrive credit and have used it to request a JamClass with #{@state.package.teachers[0].user.name}. The teacher has received your request and should respond shortly."
else if response.package? else if response.package?
text = "Each teacher has received your request and should respond shortly." text = "Each teacher has received your request and should respond shortly."
else else
@ -433,7 +433,7 @@ UserStore = context.UserStore
teachers = [] teachers = []
teachersHolder = [] teachersHolder = []
count = 0 count = 0
for teacher_choice in @state.package.teachers for teacher_choice in @state.package.teachers
if count == 2 if count == 2
teachersHolder.push( teachersHolder.push(
@ -487,11 +487,11 @@ UserStore = context.UserStore
if this.state.package? if this.state.package?
if @state.package.teachers.length == 1 if @state.package.teachers.length == 1
explanation = `<span>You are purchasing the TestDrive package of JamClass by JamKazam. This purchase entities you to take a private online music lesson from this instructor. The price of this TestDrive is $14.99. If you have scheduling conflicts with this instructors, we will help you choose another teacher as a replacement.</span>` explanation = `<span className="explanation">You are purchasing the TestDrive package of JamClass by JamKazam. This purchase entities you to take a private online music lesson from this instructor. The price of this TestDrive is $14.99. If you have scheduling conflicts with this instructors, we will help you choose another teacher as a replacement.</span>`
else if @state.package.teachers.length == 2 else if @state.package.teachers.length == 2
explanation = `<span className="explanation">You are purchasing the TestDrive package of JamClass by JamKazam. This purchase entities you to take 2 private online music lessons - 1 each from these 2 instructors. The price of this TestDrive is $29.99. If you have scheduling conflicts with any of these instructors, we will help you choose another teacher as a replacement.</span>` explanation = `<span className="explanation">You are purchasing the TestDrive package of JamClass by JamKazam. This purchase entities you to take 2 private online music lessons - 1 each from these 2 instructors. The price of this TestDrive is $29.99. If you have scheduling conflicts with any of these instructors, we will help you choose another teacher as a replacement.</span>`
else if @state.package.teachers.length == 4 else if @state.package.teachers.length == 4
explanation = `<span>You are purchasing the TestDrive package of JamClass by JamKazam. This purchase entities you to take 4 private online music lessons - 1 each from these 4 instructors. The price of this TestDrive is $49.99. If you have scheduling conflicts with any of these instructors, we will help you choose another teacher as a replacement.</span>` explanation = `<span className="explanation">You are purchasing the TestDrive package of JamClass by JamKazam. This purchase entities you to take 4 private online music lessons - 1 each from these 4 instructors. The price of this TestDrive is $49.99. If you have scheduling conflicts with any of these instructors, we will help you choose another teacher as a replacement.</span>`
else else
alert("unknown package type") alert("unknown package type")
else else

View File

@ -18,6 +18,7 @@ UserStore = context.UserStore
return return
e.preventDefault() e.preventDefault()
this.setState({clicked: true}) this.setState({clicked: true})
StripeActions.connect(this.props.purpose, this.props.user) StripeActions.connect(this.props.purpose, this.props.user)

View File

@ -67,7 +67,7 @@
<p>Like the TestDrive concept, but 4 teachers is too many for you?</p> <p>Like the TestDrive concept, but 4 teachers is too many for you?</p>
<ul> <ul>
<li>Get a special offer of <a className="pick-two" onClick={this.selector.bind(this, 2)}>2 of these teachers for a total of $29.99</a>.</li> <li>Get a special offer of <a className="pick-two" onClick={this.selector.bind(this, 2)}>2 of these teachers for a total of $29.99</a>.</li>
<li>Or <a onClick={this.selector.bind(this, 1)}>1 teacher for $14.99</a>.</li> <li>Or <a className="pick-one" onClick={this.selector.bind(this, 1)}>1 teacher for $14.99</a>.</li>
<li>Or you can <a href="/client#/jamclass/searchOptions">search all of our teachers</a> and then book a TestDrive package.</li> <li>Or you can <a href="/client#/jamclass/searchOptions">search all of our teachers</a> and then book a TestDrive package.</li>
</ul> </ul>
</div>` </div>`
@ -77,7 +77,7 @@
<p>The single most important factor in the success of your music lessons is your teacher. You wouldn't marry <p>The single most important factor in the success of your music lessons is your teacher. You wouldn't marry
the first person you date, right?</p> the first person you date, right?</p>
<p>Take full 30-minute lessons from each of these 2 amazing teachers for just $14.99 each - a total of <p className="price-explain">Take full 30-minute lessons from each of these 2 amazing teachers for just $14.99 each - a total of
$29.99. Then you can pick the one who is best for you to continue your musical journey, with the $29.99. Then you can pick the one who is best for you to continue your musical journey, with the
confidence that your investment in lessons will deliver maximum growth!</p> confidence that your investment in lessons will deliver maximum growth!</p>
</div>` </div>`
@ -86,7 +86,7 @@
`<div className="other-options"> `<div className="other-options">
<p>Like the TestDrive concept, but prefer not to try 2 different teachers?</p> <p>Like the TestDrive concept, but prefer not to try 2 different teachers?</p>
<ul> <ul>
<li>Get a special offer of <a onClick={this.selector.bind(this, 1)}>1 of these teachers for just $14.99</a>. </li> <li>Get a special offer of <a className="pick-one" onClick={this.selector.bind(this, 1)}>1 of these teachers for just $14.99</a>. </li>
<li>Or you can <a href="/client#/jamclass/searchOptions">search all of our teachers</a> and then book a TestDrive package.</li> <li>Or you can <a href="/client#/jamclass/searchOptions">search all of our teachers</a> and then book a TestDrive package.</li>
</ul> </ul>
</div>` </div>`

View File

@ -153,6 +153,17 @@ rest = context.JK.Rest()
@setState({processing: true}) @setState({processing: true})
createTestDriveData: () ->
test_drive_package = null
if @props.package?
test_drive_package ={}
if window.teacherModifications?
teachers = window.teacherModifications
else
teachers = @props.package.teachers
test_drive_package.name = @props.package.name
test_drive_package.teachers = teachers
test_drive_package
markStudent: () -> markStudent: () ->
rest.updateUser({student: true}) rest.updateUser({student: true})
.done((response) => .done((response) =>
@ -170,16 +181,7 @@ rest = context.JK.Rest()
password = $form.find('input[name="password"]').val() password = $form.find('input[name="password"]').val()
terms = $form.find('input[name="terms"]').is(':checked') terms = $form.find('input[name="terms"]').is(':checked')
test_drive_package = null test_drive_package = @createTestDriveData()
if @props.package?
test_drive_package ={}
if window.teacherModifications?
teachers = window.teacherModifications
else
teachers = @props.package.teachers
test_drive_package.name = @props.package.name
test_drive_package.teachers = teachers
rest.signup({email: email, password: password, first_name: null, last_name: null, terms: terms, student: true, test_drive_package: test_drive_package}) rest.signup({email: email, password: password, first_name: null, last_name: null, terms: terms, student: true, test_drive_package: test_drive_package})
.done((response) => .done((response) =>

View File

@ -152,6 +152,159 @@ describe "Student Landing", :js => true, :type => :feature, :capybara_feature =>
foundTeacher2.should be_true foundTeacher2.should be_true
end end
it "2-count package, user picks 2" do
package = FactoryGirl.create(:test_drive_package, :two_pack)
visit "/landing/jamclass/students?utm-teachers=#{package.name}"
find('h1.jamclass-h1', 'Let Us Find You The Perfect Music Teacher')
find('h2.jamclass-h2', 'And Connect You Online With Our Patented, Unique Technology')
teacher1 = package.test_drive_package_teachers[0].user
teacher2 = package.test_drive_package_teachers[1].user
find('p.price-explain', text: 'Take full 30-minute lessons from each of these 2 amazing teachers for just $14.99 each')
fill_in "email", with: 'student_package3@jamkazam.com'
fill_in "password", with: 'jam123'
find('.register-area ins', visible: false).trigger(:click)
find('button.cta-button', text: 'SIGN UP').trigger(:click)
find('.teacher-name-packaged', text: teacher1.last_name)
find('.teacher-name-packaged', text: teacher2.last_name)
find('.explanation', text: '2 private online music lessons - 1 each from these 2 instructors')
fill_out_payment(nil, "Super HahaGuy")
find('#banner h1', text: 'TestDrive Purchased')
find('#banner .dialog-inner', text: 'Each teacher has received your request and should respond shortly')
find('#banner .close-btn').trigger(:click)
user = User.find_by_email('student_package3@jamkazam.com')
user.test_drive_package_choices.count.should eql 1
choice = user.test_drive_package_choices[0]
choice.test_drive_package_choice_teachers.count.should eql 2
purchase = user.most_recent_test_drive_purchase
purchase.lesson_package_type.is_test_drive?.should be_true
purchase.lesson_package_type.test_drive_count.should eql 2
user.student_lesson_bookings.count.should eql 2
foundTeacher1 = false
foundTeacher2 = false
user.student_lesson_bookings.each do |booking|
if booking.teacher == teacher1
foundTeacher1 = true
end
if booking.teacher == teacher2
foundTeacher2 = true
end
end
foundTeacher1.should be_true
foundTeacher2.should be_true
end
it "2-count package, user picks 1" do
package = FactoryGirl.create(:test_drive_package, :one_pack)
visit "/landing/jamclass/students?utm-teachers=#{package.name}"
find('h1.jamclass-h1', 'Let Us Find You The Perfect Music Teacher')
find('h2.jamclass-h2', 'And Connect You Online With Our Patented, Unique Technology')
teacher1 = package.test_drive_package_teachers[0].user
teacher2 = package.test_drive_package_teachers[1].user
find('a.pick-one').trigger(:click)
find('input[data-teacher-id="' + teacher2.id + '"]').trigger(:click)
find('a.select-teachers').trigger(:click)
fill_in "email", with: 'student_package4@jamkazam.com'
fill_in "password", with: 'jam123'
find('.register-area ins', visible: false).trigger(:click)
find('button.cta-button', text: 'SIGN UP').trigger(:click)
find('.teacher-name-packaged', text: teacher2.last_name)
page.should_not have_selector('.teacher-name-packaged', text: teacher1.last_name)
find('.explanation', text: 'This purchase entities you to take a private online music lesson from this instructor')
fill_out_payment(nil, "Super HahaGuy")
find('#banner h1', text: 'TestDrive Purchased')
find('#banner .dialog-inner', text: 'You have purchased 1 TestDrive credit and have used it to request a JamClass with ' + teacher2.name)
find('#banner .close-btn').trigger(:click)
user = User.find_by_email('student_package4@jamkazam.com')
user.test_drive_package_choices.count.should eql 1
choice = user.test_drive_package_choices[0]
choice.test_drive_package_choice_teachers.count.should eql 1
purchase = user.most_recent_test_drive_purchase
purchase.lesson_package_type.is_test_drive?.should be_true
purchase.lesson_package_type.test_drive_count.should eql 1
user.student_lesson_bookings.count.should eql 1
foundTeacher2 = false
user.student_lesson_bookings.each do |booking|
if booking.teacher == teacher2
foundTeacher2 = true
end
end
foundTeacher2.should be_true
end
it "1-count package" do
package = FactoryGirl.create(:test_drive_package, :one_pack)
visit "/landing/jamclass/students?utm-teachers=#{package.name}"
find('h1.jamclass-h1', 'Let Us Find You The Perfect Music Teacher')
find('h2.jamclass-h2', 'And Connect You Online With Our Patented, Unique Technology')
teacher1 = package.test_drive_package_teachers[0].user
fill_in "email", with: 'student_package5@jamkazam.com'
fill_in "password", with: 'jam123'
find('.register-area ins', visible: false).trigger(:click)
find('button.cta-button', text: 'SIGN UP').trigger(:click)
find('.teacher-name-packaged', text: teacher1.last_name)
find('.explanation', text: 'This purchase entities you to take a private online music lesson from this instructor')
fill_out_payment(nil, "Super HahaGuy")
find('#banner h1', text: 'TestDrive Purchased')
find('#banner .dialog-inner', text: 'You have purchased 1 TestDrive credit and have used it to request a JamClass with ' + teacher1.name)
find('#banner .close-btn').trigger(:click)
user = User.find_by_email('student_package4@jamkazam.com')
user.test_drive_package_choices.count.should eql 1
choice = user.test_drive_package_choices[0]
choice.test_drive_package_choice_teachers.count.should eql 1
purchase = user.most_recent_test_drive_purchase
purchase.lesson_package_type.is_test_drive?.should be_true
purchase.lesson_package_type.test_drive_count.should eql 1
user.student_lesson_bookings.count.should eql 1
foundTeacher1 = false
user.student_lesson_bookings.each do |booking|
if booking.teacher == teacher2
foundTeacher1 = true
end
end
foundTeacher1.should be_true
end
it "package 4 count" do it "package 4 count" do
package = FactoryGirl.create(:test_drive_package, :four_pack) package = FactoryGirl.create(:test_drive_package, :four_pack)
visit "/landing/jamclass/students?utm-teachers=#{package.name}" visit "/landing/jamclass/students?utm-teachers=#{package.name}"
@ -221,7 +374,7 @@ describe "Student Landing", :js => true, :type => :feature, :capybara_feature =>
switch_user(user, '/client#/jamclass') switch_user(user, '/client#/jamclass')
jamclass_hover_option(lesson, 'status', 'View Status') jamclass_hover_option(lesson, 'status', 'View Status')
find('.generic-time-stmt', text: 'proposed alternate day/time is') find('.counter-stmt', text: 'Proposed alternate day/time is')
approve_lesson(lesson) approve_lesson(lesson)
validate_status(lesson, 'Scheduled') validate_status(lesson, 'Scheduled')