This repository was archived by the owner on Mar 4, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 59
SUP-2728, Add iOS community to Onboarding page (Skill picker) #613
Merged
+475
−51
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,224 @@ | ||
/* jshint -W117, -W030 */ | ||
describe('Skill Picker Controller', function() { | ||
var vm; | ||
var toasterSvc, memberCertService, profileService; | ||
var mockProfile = mockData.getMockProfile(); | ||
|
||
// beforeEach(function() { | ||
// bard.appModule('tc.skill-picker'); | ||
// bard.inject(this, '$controller', '$rootScope', '$q', 'userProfile'); | ||
beforeEach(function() { | ||
bard.appModule('tc.skill-picker'); | ||
bard.inject(this, '$controller', '$rootScope', '$q', 'MemberCertService', 'ProfileService', 'toaster', 'CONSTANTS'); | ||
|
||
// vm = $controller('SkillPickerController', { | ||
// }); | ||
// }); | ||
memberCertService = MemberCertService; | ||
profileService = ProfileService; | ||
var swiftProgramId = CONSTANTS.SWIFT_PROGRAM_ID; | ||
|
||
// bard.verifyNoOutstandingHttpRequests(); | ||
// mock member cert api | ||
sinon.stub(memberCertService, 'getMemberRegistration', function(userId, programId) { | ||
var deferred = $q.defer(); | ||
if (programId === swiftProgramId) { | ||
var resp = {eventId: swiftProgramId, userId: 12345}; | ||
deferred.resolve(resp); | ||
} else { | ||
deferred.resolve(); | ||
} | ||
return deferred.promise; | ||
}); | ||
|
||
sinon.stub(memberCertService, 'registerMember', function(userId, programId) { | ||
var deferred = $q.defer(); | ||
var resp = {eventId: programId, userId: 12345}; | ||
if (programId === 100) { | ||
deferred.reject(); | ||
} else { | ||
deferred.resolve(resp); | ||
} | ||
return deferred.promise; | ||
}); | ||
|
||
// it('should be created successfully', function() { | ||
// expect(vm).to.exist; | ||
// }); | ||
// adds spy method to mocked profile object for saving the profile | ||
mockProfile.save = sinon.spy(); | ||
|
||
// mock profile service | ||
sinon.stub(profileService, 'updateUserSkills', function(username, skills) { | ||
var deferred = $q.defer(); | ||
var resp = {}; | ||
if (skills[412]) { | ||
deferred.reject(); | ||
} else { | ||
deferred.resolve(resp); | ||
} | ||
return deferred.promise; | ||
}); | ||
|
||
// mocks the toaster service | ||
toasterSvc = toaster; | ||
bard.mockService(toaster, { | ||
pop: $q.when(true), | ||
default: $q.when(true) | ||
}); | ||
|
||
var scope = $rootScope.$new(); | ||
vm = $controller('SkillPickerController', { | ||
$scope: scope, | ||
userProfile: mockProfile, | ||
featuredSkills: [] | ||
}); | ||
$rootScope.$digest(); | ||
}); | ||
|
||
bard.verifyNoOutstandingHttpRequests(); | ||
|
||
it('should be created successfully', function() { | ||
expect(vm).to.exist; | ||
expect(vm.showCommunity).to.exist.to.false; | ||
}); | ||
|
||
it('should have empty tracks object ', function() { | ||
expect(vm.tracks).to.exist; | ||
expect(vm.tracks.DESIGN).not.to.exist; | ||
expect(vm.tracks.DEVELOP).not.to.exist; | ||
expect(vm.tracks.DATA_SCIENCE).not.to.exist; | ||
}); | ||
|
||
it('should have correct userIdentity ', function() { | ||
expect(vm.userId).to.exist.to.equal(mockProfile.userId); | ||
expect(vm.username).to.exist.to.equal(mockProfile.handle); | ||
}); | ||
|
||
it('should not have page dirty ', function() { | ||
var dirty = vm.isPageDirty(); | ||
expect(dirty).to.equal(false); | ||
}); | ||
|
||
it('should be created successfully with showCommunity being true', function() { | ||
// backup original swift program id, to restore after test execution | ||
var origSwiftProgId = CONSTANTS.SWIFT_PROGRAM_ID; | ||
// update swift program id to something which says, member is not registered | ||
CONSTANTS.SWIFT_PROGRAM_ID = 3446; | ||
vm = $controller('SkillPickerController', { | ||
$scope: $rootScope.$new(), | ||
userProfile: mockProfile, | ||
featuredSkills: [] | ||
}); | ||
$rootScope.$digest(); | ||
expect(vm).to.exist; | ||
// showCommunity flag should be set to true because we have at least one unregistered community | ||
expect(vm.showCommunity).to.exist.to.true; | ||
// restores the original swift program id | ||
CONSTANTS.SWIFT_PROGRAM_ID = origSwiftProgId; | ||
}); | ||
|
||
it('should add skill ', function() { | ||
vm.toggleSkill(409); | ||
expect(vm.mySkills).to.exist.have.length(1); | ||
}); | ||
|
||
it('should remove added skill ', function() { | ||
vm.toggleSkill(409); | ||
// should add the skill | ||
expect(vm.mySkills).to.exist.have.length(1); | ||
// next call to toggleSkill with same argument, should remove that skill | ||
vm.toggleSkill(409); | ||
// should remove the skill | ||
expect(vm.mySkills).to.exist.have.length(0); | ||
}); | ||
|
||
it('should not make any update call without any change ', function() { | ||
vm.submitSkills(); | ||
$rootScope.$digest(); | ||
expect(mockProfile.save).not.to.be.called; | ||
expect(profileService.updateUserSkills).not.to.be.called; | ||
expect(memberCertService.registerMember).not.to.be.called; | ||
}); | ||
|
||
it('should update tracks for the member ', function() { | ||
vm.tracks.DEVELOP = true; | ||
vm.tracks.DESIGN = false; | ||
vm.submitSkills(); | ||
$rootScope.$digest(); | ||
expect(mockProfile.save).to.be.calledOnce; | ||
expect(profileService.updateUserSkills).not.to.be.called; | ||
expect(memberCertService.registerMember).not.to.be.called; | ||
}); | ||
|
||
it('should show error popup for updating tracks ', function() { | ||
vm.tracks.DEVELOP = true; | ||
// stubs the save method to reject the promise | ||
mockProfile.save = function() {}; | ||
sinon.stub(mockProfile, 'save', function() { | ||
var deferred = $q.defer(); | ||
deferred.reject(); | ||
return deferred.promise; | ||
}); | ||
vm.submitSkills(); | ||
$rootScope.$digest(); | ||
expect(mockProfile.save).to.be.calledOnce; | ||
expect(toasterSvc.pop).to.have.been.calledWith('error', "Whoops!", sinon.match('wrong')).calledOnce; | ||
expect(profileService.updateUserSkills).not.to.be.called; | ||
expect(memberCertService.registerMember).not.to.be.called; | ||
}); | ||
|
||
it('should update skills for the member ', function() { | ||
vm.mySkills = [409, 410]; | ||
vm.submitSkills(); | ||
$rootScope.$digest(); | ||
expect(mockProfile.save).not.to.be.called; | ||
expect(profileService.updateUserSkills).to.be.calledOnce; | ||
expect(memberCertService.registerMember).not.to.be.called; | ||
}); | ||
|
||
it('should show error popup for error in updating skills ', function() { | ||
vm.mySkills = [409, 410, 412]; | ||
vm.submitSkills(); | ||
$rootScope.$digest(); | ||
expect(mockProfile.save).not.to.be.called; | ||
expect(profileService.updateUserSkills).to.be.calledOnce; | ||
expect(toasterSvc.pop).to.have.been.calledWith('error', "Whoops!", sinon.match('wrong')).calledOnce; | ||
expect(memberCertService.registerMember).not.to.be.called; | ||
}); | ||
|
||
it('should update communities for the member ', function() { | ||
vm.communities['ios'].status = true; | ||
vm.communities['ios'].dirty = true; | ||
vm.submitSkills(); | ||
$rootScope.$digest(); | ||
expect(mockProfile.save).not.to.be.called; | ||
expect(profileService.updateUserSkills).not.to.be.called; | ||
expect(memberCertService.registerMember).to.be.calledOnce; | ||
}); | ||
|
||
// we may need to update this test case when we want to call unregister endpoint | ||
it('should NOT update communities for the member for disabled community ', function() { | ||
vm.communities['ios'].status = false; | ||
vm.communities['ios'].dirty = true; | ||
vm.submitSkills(); | ||
$rootScope.$digest(); | ||
expect(mockProfile.save).not.to.be.called; | ||
expect(profileService.updateUserSkills).not.to.be.called; | ||
expect(memberCertService.registerMember).not.to.be.called; | ||
}); | ||
|
||
it('should NOT update communities for the member for enabled but non dirty community ', function() { | ||
// TODO need one more community, with dirty true, to test out the non dirty community update | ||
vm.communities['ios'].status = true; | ||
vm.communities['ios'].dirty = false; | ||
vm.submitSkills(); | ||
$rootScope.$digest(); | ||
expect(mockProfile.save).not.to.be.called; | ||
expect(profileService.updateUserSkills).not.to.be.called; | ||
expect(memberCertService.registerMember).not.to.be.called; | ||
}); | ||
|
||
it('should show error popup for error in updating communities ', function() { | ||
vm.communities['ios'].programId = 100;// to cause rejction of the promise | ||
vm.communities['ios'].status = true; | ||
vm.communities['ios'].dirty = true; | ||
vm.submitSkills(); | ||
$rootScope.$digest(); | ||
expect(mockProfile.save).not.to.be.called; | ||
expect(profileService.updateUserSkills).not.to.be.called; | ||
expect(memberCertService.registerMember).to.be.calledOnce; | ||
expect(toasterSvc.pop).to.have.been.calledWith('error', "Whoops!", sinon.match('wrong')).calledOnce; | ||
}); | ||
|
||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,67 @@ | |
color: $accent-gray; | ||
} | ||
|
||
.communities { | ||
width: 100%; | ||
margin-bottom: 30px; | ||
.communities__title { | ||
@include sofia-pro-regular; | ||
text-transform: uppercase; | ||
font-size: 18px; | ||
padding-bottom: 10px; | ||
} | ||
.communities__description { | ||
@include font-with-weight('Merriweather Sans'); | ||
color: #A3A3AE; | ||
font-size: 13px; | ||
line-height: 18px; | ||
} | ||
.communities__list { | ||
margin-top: 10px; | ||
.community { | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: space-between; | ||
align-items: center; | ||
padding: 15px 0; | ||
border-bottom: 1px solid $gray-light; | ||
|
||
&.disabled { | ||
background-color: $gray-lightest; | ||
} | ||
|
||
.community__details { | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
padding-left: 10px; | ||
} | ||
|
||
.community__text { | ||
margin-left: 10px; | ||
} | ||
|
||
.community__title { | ||
font-size: 16px; | ||
line-height: 28px; | ||
@include font-with-weight('Sofia Pro', 500); | ||
transition: .1s color; | ||
|
||
&.disabled { | ||
color: $gray-dark; | ||
} | ||
} | ||
|
||
.community__description { | ||
@include font-with-weight('Merriweather Sans', 400); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default |
||
font-size: 13px; | ||
margin-top: 4px; | ||
color: $accent-gray; | ||
} | ||
} | ||
} | ||
} | ||
|
||
.tracks-container { | ||
width: 100%; | ||
>.title { | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we'll probably deprecate these mixins, so it's safer to use the
@include font-with-weight
mixin