mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-02-17 00:40:56 -05:00
Fix Student and Teacher signup forms firstName, lastName inputs
This commit is contained in:
parent
f3254f1061
commit
ed130e0c0e
4 changed files with 24 additions and 15 deletions
|
@ -190,6 +190,7 @@ module.exports = class BasicInfoView extends CocoView
|
|||
emails.generalNews ?= {}
|
||||
emails.generalNews.enabled = @$('#subscribe-input').is(':checked') and not _.isEmpty(@state.get('checkEmailValue'))
|
||||
me.set('emails', emails)
|
||||
me.set(_.pick(data, 'firstName', 'lastName'))
|
||||
|
||||
unless _.isNaN(@signupState.get('birthday').getTime())
|
||||
me.set('birthday', @signupState.get('birthday').toISOString())
|
||||
|
|
|
@ -188,7 +188,7 @@ module.exports = class CreateTeacherAccountView extends RootView
|
|||
onTrialRequestSubmit: ->
|
||||
window.tracker?.trackEvent 'Teachers Create Account Submitted', category: 'Teachers', ['Mixpanel']
|
||||
@formChanged = false
|
||||
attrs = _.pick(forms.formToObject(@$('form')), 'name', 'email', 'role')
|
||||
attrs = _.pick(forms.formToObject(@$('form')), 'name', 'email', 'role', 'firstName', 'lastName')
|
||||
attrs.role = attrs.role.toLowerCase()
|
||||
options = {}
|
||||
newUser = new User(attrs)
|
||||
|
|
|
@ -4,15 +4,11 @@ Classroom = require 'models/Classroom'
|
|||
forms = require 'core/forms'
|
||||
factories = require 'test/app/factories'
|
||||
|
||||
# TODO: Figure out why these tests break Travis. Suspect it has to do with the
|
||||
# asynchronous, Promise system. On the browser, these work, but in Travis, they
|
||||
# sometimes fail, so it's some sort of race condition.
|
||||
|
||||
responses = {
|
||||
signupSuccess: { status: 200, responseText: JSON.stringify({ email: 'some@email.com' })}
|
||||
}
|
||||
|
||||
xdescribe 'CreateAccountModal', ->
|
||||
describe 'CreateAccountModal', ->
|
||||
|
||||
modal = null
|
||||
|
||||
|
@ -68,24 +64,26 @@ xdescribe 'CreateAccountModal', ->
|
|||
segmentCheckView = null
|
||||
|
||||
describe 'INDIVIDUAL path', ->
|
||||
beforeEach ->
|
||||
beforeEach (done) ->
|
||||
modal = new CreateAccountModal()
|
||||
modal.render()
|
||||
jasmine.demoModal(modal)
|
||||
modal.$('.individual-path-button').click()
|
||||
segmentCheckView = modal.subviews.segment_check_view
|
||||
_.defer done
|
||||
|
||||
it 'has a birthdate form', ->
|
||||
expect(modal.$('.birthday-form-group').length).toBe(1)
|
||||
|
||||
describe 'STUDENT path', ->
|
||||
beforeEach ->
|
||||
beforeEach (done) ->
|
||||
modal = new CreateAccountModal()
|
||||
modal.render()
|
||||
jasmine.demoModal(modal)
|
||||
modal.$('.student-path-button').click()
|
||||
segmentCheckView = modal.subviews.segment_check_view
|
||||
spyOn(segmentCheckView, 'checkClassCodeDebounced')
|
||||
_.defer done
|
||||
|
||||
it 'has a classCode input', ->
|
||||
expect(modal.$('.class-code-input').length).toBe(1)
|
||||
|
@ -105,11 +103,11 @@ xdescribe 'CreateAccountModal', ->
|
|||
describe 'checkClassCode()', ->
|
||||
it 'shows a success message if the classCode is found', ->
|
||||
request = jasmine.Ajax.requests.mostRecent()
|
||||
expect(request).toBeUndefined()
|
||||
expect(_.string.startsWith(request.url, '/db/classroom')).toBe(false)
|
||||
modal.$('.class-code-input').val('test').trigger('input')
|
||||
segmentCheckView.checkClassCode()
|
||||
request = jasmine.Ajax.requests.mostRecent()
|
||||
expect(request).toBeDefined()
|
||||
expect(_.string.startsWith(request.url, '/db/classroom')).toBe(true)
|
||||
request.respondWith({
|
||||
status: 200
|
||||
responseText: JSON.stringify({
|
||||
|
@ -124,11 +122,11 @@ xdescribe 'CreateAccountModal', ->
|
|||
|
||||
beforeEach ->
|
||||
request = jasmine.Ajax.requests.mostRecent()
|
||||
expect(request).toBeUndefined()
|
||||
expect(_.string.startsWith(request.url, '/db/classroom')).toBe(false)
|
||||
modal.$('.class-code-input').val('test').trigger('input')
|
||||
modal.$('form.segment-check').submit()
|
||||
classCodeRequest = jasmine.Ajax.requests.mostRecent()
|
||||
expect(classCodeRequest).toBeDefined()
|
||||
expect(_.string.startsWith(classCodeRequest.url, '/db/classroom')).toBe(true)
|
||||
|
||||
describe 'when the classroom IS found', ->
|
||||
beforeEach (done) ->
|
||||
|
@ -144,6 +142,9 @@ xdescribe 'CreateAccountModal', ->
|
|||
it 'navigates to the BasicInfoView', ->
|
||||
expect(modal.signupState.get('screen')).toBe('basic-info')
|
||||
|
||||
describe 'on the BasicInfoView for students', ->
|
||||
|
||||
|
||||
describe 'when the classroom IS NOT found', ->
|
||||
beforeEach (done) ->
|
||||
classCodeRequest.respondWith({
|
||||
|
@ -180,7 +181,7 @@ xdescribe 'CreateAccountModal', ->
|
|||
beforeEach ->
|
||||
modal = new CreateAccountModal()
|
||||
modal.signupState.set({
|
||||
path: 'individual'
|
||||
path: 'student'
|
||||
screen: 'basic-info'
|
||||
})
|
||||
modal.render()
|
||||
|
@ -256,6 +257,7 @@ xdescribe 'CreateAccountModal', ->
|
|||
|
||||
describe 'onSubmitForm()', ->
|
||||
it 'shows required errors for empty fields when on INDIVIDUAL path', ->
|
||||
modal.signupState.set('path', 'individual')
|
||||
basicInfoView.$('input').val('')
|
||||
basicInfoView.$('#basic-info-form').submit()
|
||||
expect(basicInfoView.$('.form-group.has-error').length).toBe(3)
|
||||
|
@ -264,7 +266,7 @@ xdescribe 'CreateAccountModal', ->
|
|||
modal.signupState.set('path', 'student')
|
||||
modal.render()
|
||||
basicInfoView.$('#basic-info-form').submit()
|
||||
expect(basicInfoView.$('.form-group.has-error').length).toBe(5) # includes first and last name
|
||||
expect(basicInfoView.$('.form-group.has-error').length).toBe(4) # includes first and last name, not email
|
||||
|
||||
describe 'submit with password', ->
|
||||
beforeEach ->
|
||||
|
@ -272,6 +274,8 @@ xdescribe 'CreateAccountModal', ->
|
|||
email: 'some@email.com'
|
||||
password: 'password'
|
||||
name: 'A Username'
|
||||
firstName: 'First'
|
||||
lastName: 'Last'
|
||||
})
|
||||
basicInfoView.$('form').submit()
|
||||
|
||||
|
@ -313,6 +317,10 @@ xdescribe 'CreateAccountModal', ->
|
|||
it 'saves the user', ->
|
||||
request = jasmine.Ajax.requests.mostRecent()
|
||||
expect(_.string.startsWith(request.url, '/db/user')).toBe(true)
|
||||
body = JSON.parse(request.params)
|
||||
expect(body.firstName).toBe('First')
|
||||
expect(body.lastName).toBe('Last')
|
||||
expect(body.emails.generalNews.enabled).toBe(true)
|
||||
|
||||
describe 'saving the user FAILS', ->
|
||||
beforeEach (done) ->
|
||||
|
|
|
@ -236,7 +236,7 @@ describe 'CreateTeacherAccountView', ->
|
|||
expect(request.url).toBe('/db/user')
|
||||
expect(request.method).toBe('POST')
|
||||
attrs = JSON.parse(request.params)
|
||||
for attr in ['password', 'name', 'email', 'role']
|
||||
for attr in ['password', 'name', 'email', 'role', 'firstName', 'lastName']
|
||||
expect(attrs[attr]).toBeDefined()
|
||||
|
||||
describe 'after saving the new user', ->
|
||||
|
|
Loading…
Reference in a new issue