codecombat/test/app/views/teachers/ActivateLicensesModal.spec.coffee

140 lines
5.1 KiB
CoffeeScript
Raw Normal View History

2016-03-30 16:57:19 -04:00
ActivateLicensesModal = require 'views/courses/ActivateLicensesModal'
Classrooms = require 'collections/Classrooms'
Courses = require 'collections/Courses'
Levels = require 'collections/Levels'
Prepaids = require 'collections/Prepaids'
2016-03-30 16:57:19 -04:00
Users = require 'collections/Users'
forms = require 'core/forms'
factories = require 'test/app/factories'
2016-03-30 16:57:19 -04:00
# Needs some fixing
describe 'ActivateLicensesModal', ->
beforeEach (done) ->
@members = new Users(_.times(4, (i) -> factories.makeUser()))
@classrooms = new Classrooms([
factories.makeClassroom({}, { @members })
factories.makeClassroom()
])
selectedUsers = new Users(@members.slice(0,3))
options = _.extend({}, {
classroom: @classrooms.first(), @classrooms, users: @members, selectedUsers
}, options)
@modal = new ActivateLicensesModal(options)
@prepaidThatExpiresSooner = factories.makePrepaid({maxRedeemers: 1, endDate: moment().add(1, 'month').toISOString()})
@prepaidThatExpiresLater = factories.makePrepaid({maxRedeemers: 1, endDate: moment().add(2, 'months').toISOString()})
prepaids = new Prepaids([
# empty
factories.makePrepaid({maxRedeemers: 0, endDate: moment().add(1, 'day').toISOString()})
# expired
factories.makePrepaid({maxRedeemers: 10, endDate: moment().subtract(1, 'day').toISOString()})
2016-03-30 16:57:19 -04:00
# pending
factories.makePrepaid({
maxRedeemers: 100
startDate: moment().add(1, 'month').toISOString()
endDate: moment().add(2, 'months').toISOString()
})
# these should be used
@prepaidThatExpiresSooner
@prepaidThatExpiresLater
])
@modal.prepaids.fakeRequests[0].respondWith({ status: 200, responseText: prepaids.stringify() })
@modal.classrooms.fakeRequests[0].respondWith({
status: 200
responseText: @classrooms.stringify()
})
@modal.classrooms.first().users.fakeRequests[0].respondWith({
status: 200
responseText: @members.stringify()
})
jasmine.demoModal(@modal)
_.defer done
2016-03-30 16:57:19 -04:00
describe 'the class dropdown', ->
it 'contains an All Students option', ->
expect(@modal.$('select option:last-child').data('i18n')).toBe('teacher.all_students')
2016-03-30 16:57:19 -04:00
it 'displays the current classname', ->
expect(@modal.$('option:selected').html()).toBe(@classrooms.first().get('name'))
2016-03-30 16:57:19 -04:00
it 'contains all of the teacher\'s classes', ->
expect(@modal.$('select option').length).toBe(3) # including 'All Students' options
2016-03-30 16:57:19 -04:00
describe 'the checklist of students', ->
it 'should separate the unenrolled from the enrolled students'
it 'should have a checkmark by the selected students'
it 'should display all the students'
describe 'the credits availble count', ->
it 'should match the number of unused prepaids', ->
expect(@modal.$('#total-available').html()).toBe('2')
describe 'the Enroll button', ->
it 'should show the number of selected students', ->
expect(@modal.$('#total-selected-span').html()).toBe('3')
it 'should fire off one request when clicked'
describe 'when the teacher has enough licenses', ->
beforeEach ->
selected = @modal.state.get('selectedUsers')
selected.remove(selected.first())
2016-03-30 16:57:19 -04:00
it 'should be enabled', ->
expect(@modal.$('#activate-licenses-btn').hasClass('disabled')).toBe(false)
describe 'when clicked', ->
beforeEach ->
@modal.$('form').submit()
it 'enrolls the selected students with the soonest-to-expire, available prepaid', ->
request = jasmine.Ajax.requests.mostRecent()
if request.url.indexOf(@prepaidThatExpiresSooner.id) is -1
fail('The first prepaid should be the prepaid that expires sooner')
request.respondWith({ status: 200, responseText: '{ "redeemers": [{}] }' })
request = jasmine.Ajax.requests.mostRecent()
if request.url.indexOf(@prepaidThatExpiresLater.id) is -1
fail('The second prepaid should be the prepaid that expires later')
2016-03-30 16:57:19 -04:00
describe 'when the teacher doesn\'t have enough licenses', ->
2016-03-30 16:57:19 -04:00
it 'should be disabled', ->
expect(@modal.$('#activate-licenses-btn').hasClass('disabled')).toBe(true)
describe 'the Purchase More button', ->
it 'should redirect to the license purchasing page'
2016-03-30 16:57:19 -04:00
Stuff Partially fix ActivateLicensesModal.spec [IN PROGRESS] Don't display deleted users Move userID to classroom.deletedMembers on user delete (not retroactive) Fix PDF links for course guides, remove old PDFs from repo Remove deprecated SalesView Remove underline for not-yet-linked student names Only show class select when there's more than one Ignore case when sorting student names Use student.broadName instead of name for display and sorting Fix initial load not showing progress after joining a course (hacky) Fix text entry for enrollment number input Fix enrollment statistics Fix enrollment stats completely (and add back in per-class unenrolled count) Add deletedMembers to classroom schema More fixes to enrollment stats (don't count nonmember prepaids) Don't use 0 as implicit false for openSpots Update suggested number of credit to buy automatically Fix classroom edit form ignoring cleared values Add alert text when more users selected than enrollments available Alert user when trying to assign course to unenrolled students Alert user when assigning course to nobody Add some tests for TeacherClassView bulk assign alerts Fix TeacherClassView tests failing without demos Use model/collection.fakeRequests :D Remove unused comment Fix handling of improperly sorted deleted users on clientside Add test for moving deleted users to deletedMembers Add script for moving all deleted classroom members to classroom.deletedMembers Completely rewrite tallying up enrollment statistics Fix some tests to not be dependent on logged-in user Address PR comments Fix default number of enrollments to buy Fix i18n for not enough enrollments Use custom error message for classroom name length
2016-04-07 17:55:42 -04:00
#
2016-03-30 16:57:19 -04:00
# describe 'enroll button', ->
# beforeEach (done) ->
# makeModal.bind(this)(done)
Stuff Partially fix ActivateLicensesModal.spec [IN PROGRESS] Don't display deleted users Move userID to classroom.deletedMembers on user delete (not retroactive) Fix PDF links for course guides, remove old PDFs from repo Remove deprecated SalesView Remove underline for not-yet-linked student names Only show class select when there's more than one Ignore case when sorting student names Use student.broadName instead of name for display and sorting Fix initial load not showing progress after joining a course (hacky) Fix text entry for enrollment number input Fix enrollment statistics Fix enrollment stats completely (and add back in per-class unenrolled count) Add deletedMembers to classroom schema More fixes to enrollment stats (don't count nonmember prepaids) Don't use 0 as implicit false for openSpots Update suggested number of credit to buy automatically Fix classroom edit form ignoring cleared values Add alert text when more users selected than enrollments available Alert user when trying to assign course to unenrolled students Alert user when assigning course to nobody Add some tests for TeacherClassView bulk assign alerts Fix TeacherClassView tests failing without demos Use model/collection.fakeRequests :D Remove unused comment Fix handling of improperly sorted deleted users on clientside Add test for moving deleted users to deletedMembers Add script for moving all deleted classroom members to classroom.deletedMembers Completely rewrite tallying up enrollment statistics Fix some tests to not be dependent on logged-in user Address PR comments Fix default number of enrollments to buy Fix i18n for not enough enrollments Use custom error message for classroom name length
2016-04-07 17:55:42 -04:00
#
2016-03-30 16:57:19 -04:00
# it 'should display the correct total number of credits', ->
# expect(@modal.$('#total-available').html()).toBe('2')
Stuff Partially fix ActivateLicensesModal.spec [IN PROGRESS] Don't display deleted users Move userID to classroom.deletedMembers on user delete (not retroactive) Fix PDF links for course guides, remove old PDFs from repo Remove deprecated SalesView Remove underline for not-yet-linked student names Only show class select when there's more than one Ignore case when sorting student names Use student.broadName instead of name for display and sorting Fix initial load not showing progress after joining a course (hacky) Fix text entry for enrollment number input Fix enrollment statistics Fix enrollment stats completely (and add back in per-class unenrolled count) Add deletedMembers to classroom schema More fixes to enrollment stats (don't count nonmember prepaids) Don't use 0 as implicit false for openSpots Update suggested number of credit to buy automatically Fix classroom edit form ignoring cleared values Add alert text when more users selected than enrollments available Alert user when trying to assign course to unenrolled students Alert user when assigning course to nobody Add some tests for TeacherClassView bulk assign alerts Fix TeacherClassView tests failing without demos Use model/collection.fakeRequests :D Remove unused comment Fix handling of improperly sorted deleted users on clientside Add test for moving deleted users to deletedMembers Add script for moving all deleted classroom members to classroom.deletedMembers Completely rewrite tallying up enrollment statistics Fix some tests to not be dependent on logged-in user Address PR comments Fix default number of enrollments to buy Fix i18n for not enough enrollments Use custom error message for classroom name length
2016-04-07 17:55:42 -04:00
#
# it 'should be disabled when teacher doesn\'t have enough licenses', ->
2016-03-30 16:57:19 -04:00
# expect(@modal.$('#total-available').html()).toBe('2')
Stuff Partially fix ActivateLicensesModal.spec [IN PROGRESS] Don't display deleted users Move userID to classroom.deletedMembers on user delete (not retroactive) Fix PDF links for course guides, remove old PDFs from repo Remove deprecated SalesView Remove underline for not-yet-linked student names Only show class select when there's more than one Ignore case when sorting student names Use student.broadName instead of name for display and sorting Fix initial load not showing progress after joining a course (hacky) Fix text entry for enrollment number input Fix enrollment statistics Fix enrollment stats completely (and add back in per-class unenrolled count) Add deletedMembers to classroom schema More fixes to enrollment stats (don't count nonmember prepaids) Don't use 0 as implicit false for openSpots Update suggested number of credit to buy automatically Fix classroom edit form ignoring cleared values Add alert text when more users selected than enrollments available Alert user when trying to assign course to unenrolled students Alert user when assigning course to nobody Add some tests for TeacherClassView bulk assign alerts Fix TeacherClassView tests failing without demos Use model/collection.fakeRequests :D Remove unused comment Fix handling of improperly sorted deleted users on clientside Add test for moving deleted users to deletedMembers Add script for moving all deleted classroom members to classroom.deletedMembers Completely rewrite tallying up enrollment statistics Fix some tests to not be dependent on logged-in user Address PR comments Fix default number of enrollments to buy Fix i18n for not enough enrollments Use custom error message for classroom name length
2016-04-07 17:55:42 -04:00
#
#
#
2016-03-30 16:57:19 -04:00
# describe 'when enrolling only a single student', ->
# describe 'the list of students', ->
# it 'should only have the one student selected'
Stuff Partially fix ActivateLicensesModal.spec [IN PROGRESS] Don't display deleted users Move userID to classroom.deletedMembers on user delete (not retroactive) Fix PDF links for course guides, remove old PDFs from repo Remove deprecated SalesView Remove underline for not-yet-linked student names Only show class select when there's more than one Ignore case when sorting student names Use student.broadName instead of name for display and sorting Fix initial load not showing progress after joining a course (hacky) Fix text entry for enrollment number input Fix enrollment statistics Fix enrollment stats completely (and add back in per-class unenrolled count) Add deletedMembers to classroom schema More fixes to enrollment stats (don't count nonmember prepaids) Don't use 0 as implicit false for openSpots Update suggested number of credit to buy automatically Fix classroom edit form ignoring cleared values Add alert text when more users selected than enrollments available Alert user when trying to assign course to unenrolled students Alert user when assigning course to nobody Add some tests for TeacherClassView bulk assign alerts Fix TeacherClassView tests failing without demos Use model/collection.fakeRequests :D Remove unused comment Fix handling of improperly sorted deleted users on clientside Add test for moving deleted users to deletedMembers Add script for moving all deleted classroom members to classroom.deletedMembers Completely rewrite tallying up enrollment statistics Fix some tests to not be dependent on logged-in user Address PR comments Fix default number of enrollments to buy Fix i18n for not enough enrollments Use custom error message for classroom name length
2016-04-07 17:55:42 -04:00
#
2016-03-30 16:57:19 -04:00
# describe 'when bulk-enrolling students', ->
# describe 'the list of students', ->
# it 'should have the right students selected'
Stuff Partially fix ActivateLicensesModal.spec [IN PROGRESS] Don't display deleted users Move userID to classroom.deletedMembers on user delete (not retroactive) Fix PDF links for course guides, remove old PDFs from repo Remove deprecated SalesView Remove underline for not-yet-linked student names Only show class select when there's more than one Ignore case when sorting student names Use student.broadName instead of name for display and sorting Fix initial load not showing progress after joining a course (hacky) Fix text entry for enrollment number input Fix enrollment statistics Fix enrollment stats completely (and add back in per-class unenrolled count) Add deletedMembers to classroom schema More fixes to enrollment stats (don't count nonmember prepaids) Don't use 0 as implicit false for openSpots Update suggested number of credit to buy automatically Fix classroom edit form ignoring cleared values Add alert text when more users selected than enrollments available Alert user when trying to assign course to unenrolled students Alert user when assigning course to nobody Add some tests for TeacherClassView bulk assign alerts Fix TeacherClassView tests failing without demos Use model/collection.fakeRequests :D Remove unused comment Fix handling of improperly sorted deleted users on clientside Add test for moving deleted users to deletedMembers Add script for moving all deleted classroom members to classroom.deletedMembers Completely rewrite tallying up enrollment statistics Fix some tests to not be dependent on logged-in user Address PR comments Fix default number of enrollments to buy Fix i18n for not enough enrollments Use custom error message for classroom name length
2016-04-07 17:55:42 -04:00
#
2016-03-30 16:57:19 -04:00
# describe 'selecting more students', ->
# it 'should increase the student counter'