Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 4b96b72

Browse files
author
vikasrohit
committed
Merge branch 'dev' into feature/sup-2754-allow-hiding-external-links
* dev: Updated dashboard tests SUP-2789, Edit Profile page-->3 cards should be present in one row SUP-2790, Weblink regular expression:--Able to add "http://aa" as a weblink SUP-2481, intergrate-web-links-api Remove double quotes Fixed showing top placements SUP-2757, Remove scroll listener for tc-sticky directive to avoid memory leak updated .svg assets, fixed wrong transparency
2 parents 9822510 + c347e33 commit 4b96b72

File tree

17 files changed

+351
-304
lines changed

17 files changed

+351
-304
lines changed

app/directives/external-account/external-web-link.directive.jade

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
.web-link
22
form(name="addWebLinkFrm", ng-submit="addWebLinkFrm.$valid && addWebLink()", autocomplete="off")
33
.validation-bar.url(ng-class="{ 'error-bar': (addWebLinkFrm.url.$dirty && addWebLinkFrm.url.$invalid) }")
4-
input.form-field.url(name="url", type="url", ng-model="url", placeholder="http://www.yourlink.com", required)
4+
input.form-field.url(name="url", type="text", ng-pattern="urlRegEx" ng-model="url", placeholder="http://www.yourlink.com", required)
55

66
.form-input-error(ng-show="addWebLinkFrm.url.$dirty && addWebLinkFrm.url.$invalid")
77
p(ng-show="addWebLinkFrm.url.$error.required") This is a required field.
88

9-
p(ng-show="addWebLinkFrm.url.$error.url") Please enter a valid URL
9+
p(ng-show="addWebLinkFrm.url.$error.pattern") Please enter a valid URL
1010

1111
button.tc-btn.tc-btn-m(type="submit",
1212
tc-busy-button, tc-busy-when="addingWebLink", tc-busy-message="Adding",

app/directives/external-account/external-web-links.directive.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
$log = $log.getInstance('ExternalWebLinkCtrl');
2727
$scope.addingWebLink = false;
2828
$scope.errorMessage = null;
29+
$scope.urlRegEx = /^(http(s?):\/\/)?(www\.)?[a-zA-Z0-9\.\-\_]+(\.[a-zA-Z]{2,3})+(\/[a-zA-Z0-9\_\-\s\.\/\?\%\#\&\=]*)?$/;
2930

3031
$scope.addWebLink = function() {
3132
$log.debug("URL: " + $scope.url);

app/directives/tc-sticky/tc-sticky.directive.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@
4747
}
4848
}
4949
});
50+
// remove the event listener before destroying the directive
51+
scope.$on('$destroy',function() {
52+
angular.element($window).unbind("scroll");
53+
});
5054
}
5155
};
5256
}

app/my-dashboard/header-dashboard/header-dashboard.spec.js

Lines changed: 7 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,9 @@ describe('Header Dashboard Controller', function() {
8888
$rootScope.$apply();
8989
});
9090

91-
xit('variables should be initialized to correct value', function() {
92-
expect(controller.domain).to.equal(domain);
93-
expect(controller.isCopilot).to.equal(false);
94-
expect(controller.hasRatings).to.equal(true);
95-
expect(controller.loading).to.equal(false);
91+
it('variables should be initialized to correct value', function() {
9692
expect(controller.profile).to.exist;
9793
expect(controller.profile.handle).to.equal('albertwang');
98-
expect(controller.rankStats).to.exist;
99-
// there are 7 sub tracks with non null/zero value for one of rank/wins/fulfillment
100-
expect(controller.rankStats).to.have.length(7);
101-
expect(controller.moneyEarned).to.equal(60.50);
10294
});
10395
});
10496

@@ -123,13 +115,8 @@ describe('Header Dashboard Controller', function() {
123115
});
124116

125117
it('variables should be initialized to correct value', function() {
126-
// expect(controller.loading).to.equal(false);
127-
// TODO Fixme
128-
// expect(controller.profile).to.exist;
129-
// expect(controller.profile.handle).to.equal('albertwang');
130-
// expect(controller.rankStats).to.exist;
131-
// expect(controller.rankStats).to.have.length(0);
132-
// expect(controller.moneyEarned).to.equal(60.50);
118+
expect(controller.profile).to.exist;
119+
expect(controller.profile.handle).to.equal('albertwang');
133120
});
134121
});
135122

@@ -148,50 +135,14 @@ describe('Header Dashboard Controller', function() {
148135
UserService : userService,
149136
ProfileService: profileService,
150137
userIdentity: identity,
151-
profile: profile
138+
profile: profileService.getUserProfile()
152139
});
153140
$rootScope.$apply();
154141
});
155142

156-
xit('variables should be initialized to correct value', function() {
157-
expect(controller.loading).to.equal(false);
158-
expect(controller.profile).not.to.exist;
159-
expect(controller.rankStats).to.exist;
160-
// there are 7 sub tracks with non null/zero value for one of rank/wins/fulfillment
161-
expect(controller.rankStats).to.have.length(7);
162-
expect(controller.hasRatings).to.equal(true);
163-
expect(controller.moneyEarned).to.equal(60.50);
164-
});
165-
});
166-
167-
describe('inialization with profile api financials endpoint error', function() {
168-
var controller = null;
169-
beforeEach( function(){
170-
$scope = $rootScope.$new();
171-
profileService.getUserFinancials.restore();
172-
sinon.stub(profileService, 'getUserFinancials', function(handle) {
173-
var deferred = $q.defer();
174-
deferred.reject('failed');
175-
return deferred.promise;
176-
});
177-
controller = $controller('HeaderDashboardController', {
178-
NotificationService : notificationService,
179-
UserService : userService,
180-
ProfileService: profileService,
181-
userIdentity: identity
182-
});
183-
$rootScope.$apply();
184-
});
185-
186-
xit('variables should be initialized to correct value', function() {
187-
expect(controller.loading).to.equal(false);
188-
expect(controller.profile).to.exist;
189-
expect(controller.profile.handle).to.equal('albertwang');
190-
expect(controller.rankStats).to.exist;
191-
// there are 7 sub tracks with non null/zero value for one of rank/wins/fulfillment
192-
expect(controller.rankStats).to.have.length(7);
193-
expect(controller.hasRatings).to.equal(true);
194-
expect(controller.moneyEarned).not.to.exist;
143+
it('variables should be initialized to correct value', function() {
144+
expect(controller.profile.$$state.status).to.equal(2);
145+
expect(controller.profile.$$state.value).to.equal('failed');
195146
});
196147
});
197148

app/my-dashboard/my-challenges/my-challenges.spec.js

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ describe('Challenges Widget Controller', function() {
55
var authService, challengeService, userService;
66
var marathons = mockData.getMockMarathons();
77
var challenges = mockData.getMockiOSChallenges();
8+
var marathons = mockData.getMockMarathons();
89

910
beforeEach(function() {
1011
bard.appModule('topcoder');
@@ -49,37 +50,58 @@ describe('Challenges Widget Controller', function() {
4950
deferred.resolve(resp);
5051
return deferred.promise;
5152
});
53+
54+
sinon.stub(challengeService, 'getUserMarathonMatches', function(handle, params) {
55+
var deferred = $q.defer();
56+
deferred.resolve(marathons);
57+
return deferred.promise;
58+
});
59+
60+
sinon.stub(challengeService, 'checkChallengeParticipation', function() {
61+
var deferred = $q.defer();
62+
deferred.resolve(false);
63+
return deferred.promise;
64+
});
65+
5266
});
5367

5468
bard.verifyNoOutstandingHttpRequests();
5569

56-
xdescribe('inialization', function() {
57-
var myChallenges = null;
58-
beforeEach( function(){
59-
$scope = $rootScope.$new();
60-
myChallenges = $controller('MyChallengesWidgetController', {
61-
ChallengeService: challengeService,
62-
UserService: userService,
63-
userIdentity: {handle: 'username'}
64-
});
65-
$rootScope.$apply();
70+
var controller;
71+
beforeEach( function(){
72+
$scope = $rootScope.$new();
73+
controller = $controller('MyChallengesWidgetController', {
74+
ChallengeService: challengeService,
75+
UserService: userService,
76+
userIdentity: {handle: 'username'}
6677
});
78+
$rootScope.$apply();
79+
});
6780

81+
describe('initialization', function() {
6882
it('vm.domain should be initialized to default value', function() {
6983
// default value for domain
70-
expect(myChallenges.domain).to.equal(domain);
84+
expect(controller.domain).to.equal(domain);
7185
});
7286

7387
it('vm.userHasChallenges should be initialized to default value', function() {
7488
// default value for pageIndex
75-
expect(myChallenges.userHasChallenges).to.equal(true);
89+
expect(controller.userHasChallenges).to.equal(true);
7690
});
7791

78-
it('myChallenges.myChallenges should be initialized', function() {
92+
it('controller.myChallenges should be initialized', function() {
7993
// default value for pageIndex
80-
expect(myChallenges.myChallenges).to.exist;
81-
expect(myChallenges.myChallenges.length).to.equal(challenges.length);
94+
expect(controller.myChallenges).to.exist;
95+
expect(controller.myChallenges.length).to.equal(4);
8296
});
8397
});
8498

99+
describe('functions', function() {
100+
it('toggleView should work', function() {
101+
controller.toggleView('foo');
102+
expect(controller.challengeView).to.equal('foo');
103+
});
104+
105+
});
106+
85107
});

app/my-dashboard/programs/programs.spec.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ describe('Programs Controller', function() {
4141
deferred.resolve(resp);
4242
return deferred.promise;
4343
});
44+
45+
sinon.stub(memberCertService, 'registerMember', function() {
46+
var deferred = $q.defer();
47+
var resp = {eventId: 3445, userId: 12345};
48+
deferred.resolve(resp);
49+
return deferred.promise;
50+
});
51+
4452

4553
// mock challenges api
4654
sinon.stub(challengeService, 'getChallenges', function() {
@@ -81,6 +89,17 @@ describe('Programs Controller', function() {
8189
expect(controller.challenges).to.exist;
8290
expect(controller.challenges.length).to.equal(challenges.length);
8391
});
92+
93+
describe('functions', function() {
94+
beforeEach(function() {
95+
controller.registerUser();
96+
$rootScope.$apply();
97+
});
98+
99+
it('registerUser should work', function() {
100+
expect(controller.registered).to.be.equal(true);
101+
});
102+
});
84103
});
85104

86105
describe('inialization with unregistered memeber', function() {

app/my-dashboard/srms/srms.controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
var srms = data[0];
3636
var userSrms = data[1];
3737
var userSrmsMap = {};
38-
var userSrms = userSrms.forEach(function (srm) {
38+
var userSrms = userSrms.map(function (srm) {
3939
var id = srm.id;
4040
userSrmsMap[id] = srm;
4141
});

app/my-dashboard/srms/srms.spec.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,7 @@ describe('SRMs Widget Controller', function() {
3434
sinon.stub(srmService, 'getSRMs', function(params) {
3535
var deferred = $q.defer();
3636
var resp = null;
37-
if (params.filter.indexOf('listType=past') != -1) {
38-
resp = JSON.parse(JSON.stringify(srms));
39-
} else {
40-
resp = JSON.parse(JSON.stringify(srms.slice(1)));
41-
}
37+
resp = JSON.parse(JSON.stringify(srms));
4238
resp.pagination = {
4339
total: resp.length,
4440
pageIndex: 1,
@@ -66,24 +62,24 @@ describe('SRMs Widget Controller', function() {
6662
bard.verifyNoOutstandingHttpRequests();
6763

6864
describe('inialization', function() {
69-
var mySRMs = null;
65+
var controller = null;
7066
beforeEach( function(){
7167
$scope = $rootScope.$new();
72-
mySRMs = $controller('SRMWidgetController', {
68+
controller = $controller('SRMWidgetController', {
7369
SRMService : srmService,
7470
UserService : userService
7571
});
7672
$rootScope.$apply();
7773
});
7874

7975
it('controller should exist', function() {
80-
expect(mySRMs).to.exist;
76+
expect(controller).to.exist;
8177
});
8278

83-
it('mySRMs.srms should be initialized', function() {
84-
expect(mySRMs.srms).to.exist;
85-
expect(mySRMs.srms.length).to.equal(srms.length - 1);
79+
it('controller.srms should be initialized', function() {
80+
expect(controller.srms).to.exist;
81+
expect(controller.srms.length).to.equal(srms.length);
8682
});
8783
});
8884

89-
});
85+
});
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/* jshint -W117, -W030 */
2+
describe('Dashboard Subtrack Stats Controller', function() {
3+
var controller;
4+
var profileService, userStatsService;
5+
var stats = mockData.getMockStats();
6+
var userIdentity = {
7+
userId: 1234567,
8+
handle: 'ut',
9+
10+
};
11+
12+
beforeEach(function() {
13+
bard.appModule('topcoder');
14+
bard.inject(this,
15+
'$controller',
16+
'$rootScope',
17+
'$q',
18+
'ProfileService',
19+
'UserStatsService',
20+
'CONSTANTS',
21+
'Helpers');
22+
23+
profileService = ProfileService;
24+
userStatsService = UserStatsService;
25+
26+
sinon.stub(profileService, 'getUserStats', function() {
27+
var deferred = $q.defer();
28+
deferred.resolve(stats);
29+
return deferred.promise;
30+
});
31+
32+
});
33+
34+
bard.verifyNoOutstandingHttpRequests();
35+
36+
describe('controller', function() {
37+
var controller = null;
38+
beforeEach( function(){
39+
$scope = $rootScope.$new();
40+
controller = $controller('SubtrackStatsController', {
41+
ProfileService : profileService,
42+
UserStatsService : userStatsService,
43+
userIdentity: userIdentity
44+
});
45+
$rootScope.$apply();
46+
});
47+
48+
describe('initialization', function() {
49+
it('should load data', function() {
50+
expect(controller.loading).to.be.equal(false);
51+
});
52+
53+
it('should have ranks', function() {
54+
expect(controller.subtrackRanks.length).to.be.equal(10);
55+
expect(controller.hasRanks).to.be.equal(true);
56+
})
57+
});
58+
59+
});
60+
61+
});

app/services/challenge.service.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@
179179
// TODO placement logic for challenges can be moved to their corresponding user place directive
180180
// process placement for challenges having winningPlacements array in response
181181
if (Array.isArray(challenge.userDetails.winningPlacements)) {
182-
challenge.highestPlacement = _.max(challenge.userDetails.winningPlacements);
182+
challenge.highestPlacement = _.min(challenge.userDetails.winningPlacements);
183183
challenge.wonFirst = challenge.highestPlacement == 1;
184184
if (challenge.highestPlacement === 0) {
185185
challenge.highestPlacement = null;
@@ -189,7 +189,9 @@
189189
if (challenge.track == 'DESIGN' && challenge.userDetails.submissions && challenge.userDetails.submissions.length > 0) {
190190
challenge.thumbnailId = challenge.userDetails.submissions[0].id;
191191

192-
challenge.highestPlacement = _.max(challenge.userDetails.submissions, 'placement').placement;
192+
challenge.highestPlacement = _.min(challenge.userDetails.submissions.filter(function(submission) {
193+
return submission.placement;
194+
}), 'placement').placement;
193195

194196
if (challenge.highestPlacement == 1) {
195197
challenge.wonFirst = true;

0 commit comments

Comments
 (0)