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

Commit b7880d8

Browse files
author
vikasrohit
committed
Merge pull request #600 from appirio-tech/dev
Dev to QA for v1.0.18 @parthshah @nlitwin @tladendo @vic-appirio Merging to get SUP-2754 QAed.
2 parents 95cbe4f + 76cc49c commit b7880d8

File tree

128 files changed

+1325
-63925
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+1325
-63925
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ report
99
.settings
1010
.vscode
1111
styleguide
12+
.awspublish-app.topcoder-dev.com

app/account/login/login.controller.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
$log = $log.getInstance("LoginController");
1111
vm.$stateParams = $stateParams;
1212
vm.passwordReset = false;
13-
vm.currentPasswordDefaultPlaceholder = "Password";
1413
vm.loginErrors = {
1514
USERNAME_NONEXISTANT: false,
1615
WRONG_PASSWORD: false,

app/directives/account/toggle-password/toggle-password.directive.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
templateUrl: 'directives/account/toggle-password/toggle-password.html',
1111
link: function(scope, element, attrs, formController) {
1212
var vm = scope.vm;
13-
vm.currentPasswordField = formController.currentPassword;
14-
vm.currentPasswordPlaceholder = vm.currentPasswordDefaultPlaceholder;
13+
scope.currentPasswordDefaultPlaceholder = attrs.placeholder || 'Password';
14+
scope.currentPasswordPlaceholder = scope.currentPasswordDefaultPlaceholder;
1515
vm.currentPassword = '';
1616

1717
var currentPasswordInput = element.children()[0];
@@ -27,8 +27,7 @@
2727
});
2828

2929
vm.onCPFocus = function(event) {
30-
vm.currentPasswordFocus = true;
31-
vm.currentPasswordPlaceholder = '';
30+
scope.currentPasswordPlaceholder = '';
3231
element.addClass('focus');
3332
}
3433

@@ -38,15 +37,11 @@
3837

3938
// If you are blurring from the password input and clicking the checkbox
4039
if (relatedTarget.attr('type') === 'checkbox' && relatedTarget.attr('id') === 'currentPasswordCheckbox') {
41-
vm.currentPasswordFocus = true;
42-
vm.currentPasswordPlaceholder = '';
40+
scope.currentPasswordPlaceholder = '';
4341
currentPasswordInput.focus();
4442
} else {
45-
// If you are blurring from the password input and clicking anywhere but the checkbox
46-
vm.currentPasswordFocus = false;
47-
4843
if (vm.currentPassword === '' || vm.currentPassword === undefined) {
49-
vm.currentPasswordPlaceholder = vm.currentPasswordDefaultPlaceholder;
44+
scope.currentPasswordPlaceholder = scope.currentPasswordDefaultPlaceholder;
5045
formController.currentPassword.$setPristine();
5146
}
5247
}

app/directives/account/toggle-password/toggle-password.jade

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ input#current-password-input(
77

88
name="currentPassword",
99
type="password",
10-
placeholder="{{vm.currentPasswordPlaceholder}}",
10+
placeholder="{{currentPasswordPlaceholder}}",
1111

1212
required)
1313

14-
label(ng-show="vm.currentPasswordFocus || vm.currentPasswordField.$dirty") #[input(type="checkbox", id="currentPasswordCheckbox", ng-model="focusOnCurrentPasswordInput", ng-change="vm.toggleTypeAttribute()")] Show
14+
label #[input(type="checkbox", id="currentPasswordCheckbox", ng-model="focusOnCurrentPasswordInput", ng-change="vm.toggleTypeAttribute()")] Show

app/directives/account/toggle-password/toggle-password.spec.js

Lines changed: 138 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,150 @@
22
describe('Toggle Password Directive', function() {
33
var scope;
44
var element;
5-
// var challenge = mockData.getMockChallengeWithUserDetails();
6-
// var spotlightChallenge = mockData.getMockSpotlightChallenges()[0];
75

86
beforeEach(function() {
97
bard.appModule('topcoder');
108
bard.inject(this, '$compile', '$rootScope');
119
scope = $rootScope.$new();
10+
scope.vm = {};
1211
});
1312

1413
bard.verifyNoOutstandingHttpRequests();
14+
15+
describe('Toggle Password Directive', function() {
16+
var togglePassword, controller, formController, passwordFormFieldSpy;
17+
18+
beforeEach(function() {
19+
var form = angular.element('<form><toggle-password /></form>)');
20+
element = form.find('toggle-password');
21+
var formElement = $compile(form)(scope);
22+
scope.$digest();
23+
24+
// controller = element.controller('togglePassword');
25+
formController = form.controller('form');
26+
passwordFormFieldSpy = sinon.spy(formController.currentPassword, '$setPristine');
27+
});
28+
29+
afterEach(function() {
30+
// do nohting
31+
});
32+
33+
it('should have password default placeholder', function() {
34+
expect(scope.currentPasswordDefaultPlaceholder).to.exist.to.equal('Password');
35+
expect(scope.currentPasswordPlaceholder).to.exist.to.equal('Password');
36+
});
37+
38+
it('should not have focus class', function() {
39+
expect(element.hasClass('focus')).to.be.false;
40+
});
41+
42+
it('should trigger click handler ', function() {
43+
var mockFocus = sinon.spy(element.find('input')[0], 'focus');
44+
element.trigger('click');
45+
expect(mockFocus).to.be.calledOnce;
46+
});
47+
48+
it('should trigger focus handler ', function() {
49+
var pwsIntputElement = angular.element(element.find('input')[0]);
50+
pwsIntputElement.triggerHandler('focus');
51+
expect(element.hasClass('focus')).to.be.true;
52+
});
53+
54+
it('should trigger blur handler with form field pristine ', function() {
55+
var pwsIntputElement = angular.element(element.find('input')[0]);
56+
// focus it first
57+
pwsIntputElement.triggerHandler('focus');
58+
// verifies if focus class is added
59+
expect(element.hasClass('focus')).to.be.true;
60+
// now blurs from it
61+
pwsIntputElement.triggerHandler('blur');
62+
// focus class should not be there
63+
expect(element.hasClass('focus')).to.be.false;
64+
// password field's setPristine method should be called once because currentPassword is empty
65+
expect(passwordFormFieldSpy).to.be.calledOnce;
66+
});
67+
68+
it('should trigger blur handler without form field pristine ', function() {
69+
scope.vm.currentPassword = 'some-password';
70+
scope.$digest();
71+
var pwsIntputElement = angular.element(element.find('input')[0]);
72+
// focus it first
73+
pwsIntputElement.triggerHandler('focus');
74+
// verifies if focus class is added
75+
expect(element.hasClass('focus')).to.be.true;
76+
// now blurs from it
77+
pwsIntputElement.triggerHandler('blur');
78+
// focus class should not be there
79+
expect(element.hasClass('focus')).to.be.false;
80+
// password field's setPristine method should not be called because currentPassword is non-empty
81+
expect(passwordFormFieldSpy).not.to.be.called;
82+
});
83+
84+
it('should keep focus on password field on blurring to checkbox ', function() {
85+
86+
var pwsIntputElement = angular.element(element.find('input')[0]);
87+
// focus it first
88+
pwsIntputElement.triggerHandler('focus');
89+
// verifies if focus class is added
90+
expect(element.hasClass('focus')).to.be.true;
91+
// now blurs from it
92+
93+
var e = jQuery.Event("blur");
94+
e.relatedTarget = {
95+
getAttribute: function(name) {
96+
if (name === 'type') return 'checkbox';
97+
if (name === 'id') return 'currentPasswordCheckbox';
98+
}
99+
};
100+
//mock focus event
101+
var mockFocus = sinon.spy(element.find('input')[0], 'focus');
102+
// trigger event
103+
pwsIntputElement.trigger(e);
104+
105+
// focus should be called once
106+
expect(mockFocus).to.be.calledOnce;
107+
// password field placeholde should be empty
108+
expect(scope.currentPasswordPlaceholder).to.exist.to.equal('');
109+
});
110+
111+
it('should change type of input field to be text ', function() {
112+
var pwsIntputElement = angular.element(element.find('input')[0]);
113+
var checkbox = angular.element(element.find('input')[1]);
114+
// before clicking on checkbox, it should have password type
115+
expect(pwsIntputElement.attr('type')).to.equal('password');
116+
checkbox.trigger('click');
117+
// after clicking on checkbox, it should have text type
118+
expect(pwsIntputElement.attr('type')).to.equal('text');
119+
});
120+
121+
it('should change type of input field to be password ', function() {
122+
var pwsIntputElement = angular.element(element.find('input')[0]);
123+
var checkbox = angular.element(element.find('input')[1]);
124+
// before clicking on checkbox, it should have password type
125+
expect(pwsIntputElement.attr('type')).to.equal('password');
126+
checkbox.trigger('click');
127+
// after clicking on checkbox, it should have text type
128+
expect(pwsIntputElement.attr('type')).to.equal('text');
129+
// click again to uncheck the checkbox
130+
checkbox.trigger('click');
131+
// after unchecking the checkbox, it should have password type
132+
expect(pwsIntputElement.attr('type')).to.equal('password');
133+
});
134+
135+
it('should trigger keyup handler with enter/return key ', function() {
136+
var mockBlur = sinon.spy(element.find('input')[0], 'blur');
137+
var e = jQuery.Event("keyup");
138+
e.keyCode = 13;
139+
element.trigger(e);
140+
expect(mockBlur).to.be.calledOnce;
141+
});
142+
143+
it('should NOT trigger keyup handler with non enter/return key ', function() {
144+
var mockBlur = sinon.spy(element.find('input')[0], 'blur');
145+
var e = jQuery.Event("keyup");
146+
e.keyCode = 14;
147+
element.trigger(e);
148+
expect(mockBlur).not.to.be.called;
149+
});
150+
});
15151
});

app/directives/badges/badge-tooltip.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ describe('Badge Tooltip Directive', function() {
66
var spotlightChallenge = mockData.getMockSpotlightChallenges()[0];
77

88
beforeEach(function() {
9-
bard.appModule('topcoder');
9+
bard.appModule('tcUIComponents');
1010
bard.inject(this, '$compile', '$rootScope');
1111
scope = $rootScope.$new();
1212
});
1313

1414
bard.verifyNoOutstandingHttpRequests();
1515

16-
describe('Badge Tooltip', function() {
16+
xdescribe('Badge Tooltip', function() {
1717
var tooltip;
1818

1919
beforeEach(function() {

app/directives/empty-state-placeholder/empty-state-placeholder.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* jshint -W117, -W030 */
2-
describe('Empty State Placeholder Directive', function() {
2+
xdescribe('Empty State Placeholder Directive', function() {
33
var scope;
44
var element;
55
var emptyStateService;
@@ -94,4 +94,4 @@ describe('Empty State Placeholder Directive', function() {
9494
expect(controller.show).to.exist.to.equal(false);
9595
});
9696
});
97-
});
97+
});

app/directives/external-account/external-account.directive.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* jshint -W117, -W030 */
2-
describe('External Accounts Directive', function() {
2+
xdescribe('External Accounts Directive', function() {
33
var scope;
44
var element;
55
var toasterSvc;

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
.external-link-list
2-
div.external-link-tile(ng-repeat="account in linkedAccountsData")
2+
div.external-link-tile(ng-repeat="account in linkedAccountsData", ng-class="{'external-link-tile--editable' : editable}")
33
.top
4+
.ext-link-tile_edit-header(ng-show="editable && account.provider === 'weblink'")
5+
.ext-link-tile_edit-header_delete(ng-click="confirmDeletion(account)", ng-class="{'ext-link-tile_edit-header_delete--disabled': account.deletingAccount || account.status === 'PENDING'}")
46
div.logo
57
i.fa(ng-class="(account|providerData:'className') || 'fa-globe'")
68
h2 {{account|providerData:"displayName"}}
79

8-
div.bottom(ng-switch="account.provider")
10+
div.bottom(ng-if="account.deletingAccount")
11+
.section-loading
12+
div.bottom(ng-switch="account.provider", ng-if="!account.deletingAccount")
913

1014
div(ng-switch-when="github")
1115
.handle {{account.data.handle}}
@@ -102,4 +106,4 @@
102106
p.link-title(data-ellipsis, ng-bind="account.title", ng-hide="account.status === 'PENDING'")
103107
p.link-title(ng-show="account.status === 'PENDING'") Loading data. This will take a few minutes.
104108

105-
a.link-url(ng-href="{{account.URL}}", ng-bind="account.URL")
109+
a.link-url(ng-href="{{account.URL | urlProtocol}}", ng-bind="account.URL")
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.deletion-confirmation
2+
.deletion-confirmation-title Heads Up!
3+
.deletion-confirmation-message Are you sure you want to delete the external link #[span.deletion-confirmation-account-title "{{vm.account.title}}"]? This action can't be undone later.
4+
.deletion-confirmation-buttons
5+
.deletion-confirmation-button-yes
6+
button.tc-btn.tc-btn-s.tc-btn-ghost(ng-click="vm.deleteAccount() && closeThisDialog()") Yes, Delete Link
7+
.deletion-confirmation-button-no
8+
button.tc-btn.tc-btn-s(ng-click="closeThisDialog()") Cancel
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
(function () {
2+
3+
angular
4+
.module('tcUIComponents')
5+
.controller('ExternalLinkDeletionController', ExternalLinkDeletionController);
6+
7+
ExternalLinkDeletionController.$inject = ['ExternalWebLinksService', '$q', '$log', 'toaster', 'ngDialog', 'userHandle', 'account', 'linkedAccountsData'];
8+
9+
function ExternalLinkDeletionController(ExternalWebLinksService, $q, $log, toaster, ngDialog, userHandle, account, linkedAccountsData) {
10+
var vm = this;
11+
vm.account = account;
12+
$log = $log.getInstance("ExternalLinkDeletionController");
13+
14+
vm.deleteAccount = function() {
15+
$log.debug('Deleting Account...');
16+
if (account && account.deletingAccount) {
17+
$log.debug('Another deletion is already in progress.');
18+
return;
19+
}
20+
if (account && account.provider === 'weblink') {
21+
account.deletingAccount = true;
22+
$log.debug('Deleting weblink...');
23+
return ExternalWebLinksService.removeLink(userHandle, account.key).then(function(data) {
24+
account.deletingAccount = false;
25+
$log.debug("Web link removed: " + JSON.stringify(data));
26+
var toRemove = _.findIndex(linkedAccountsData, function(la) {
27+
return la.provider === 'weblink' && la.key === account.key;
28+
});
29+
if (toRemove > -1) {
30+
// remove from the linkedAccountsData array
31+
linkedAccountsData.splice(toRemove, 1);
32+
}
33+
toaster.pop('success', "Success", "Your link has been removed.");
34+
})
35+
.catch(function(resp) {
36+
var msg = resp.msg;
37+
if (resp.status === 'WEBLINK_NOT_EXIST') {
38+
$log.info("Weblink does not exist");
39+
msg = "Weblink is not linked to your account. If you think this is an error please contact <a href=\"mailTo:[email protected]\">[email protected]</a>.";
40+
} else {
41+
$log.error("Fatal error: _unlink: " + msg);
42+
msg = "Sorry! We are unable to remove your weblink. If problem persists, please contact <a href=\"mailTo:[email protected]\">[email protected]</a>";
43+
}
44+
45+
account.deletingAccount = false;
46+
toaster.pop('error', "Whoops!", msg);
47+
});
48+
}
49+
}
50+
}
51+
})();

0 commit comments

Comments
 (0)