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

Commit 8e72d82

Browse files
author
vikasrohit
committed
SUP-2754, [Edit Profile] Allow user to hide external links
-- Fixed issue with Pending state cards. It was opening the confirmation popup even the button was disabled. Thanks to Ashish Agarwal for proactively noticing it.
1 parent b6c6319 commit 8e72d82

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@
2525
$scope.deletionDialog = null;
2626

2727
$scope.confirmDeletion = function(account) {
28+
// for non weblink provider, do nothing
29+
if (account.provider !== 'weblink') {
30+
return;
31+
}
32+
// do nothing for pending state cards
33+
if (account.status === 'PENDING') {
34+
return;
35+
}
2836
$scope.deletionDialog = ngDialog.open({
2937
className: 'ngdialog-theme-default tc-dialog',
3038
template: 'directives/external-account/external-link-deletion-confirm.html',

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

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,18 +103,42 @@ describe('External Links Data Directive', function() {
103103
expect(element.isolateScope().linkedAccountsData).to.have.length(8);
104104
});
105105

106-
it('should mark the account for deletion and open the popup ', function() {
107-
var account = {key: 'somekey', provider: 'stackoverflow'};
106+
it('should open the confirmation popup ', function() {
107+
var account = {key: 'somekey', provider: 'weblink'};
108108
element.isolateScope().confirmDeletion(account);
109109
scope.$digest();
110110
// should open the popup
111111
expect(ngDialogSvc.open).to.be.called;
112-
// should not remove anythign from the array of accounts/links
112+
// should not remove anything from the array of accounts/links
113113
expect(element.isolateScope().linkedAccountsData).to.have.length(8);
114114
// $scope.deletionDialog should exist
115115
expect(element.isolateScope().deletionDialog).to.exist;
116116
ngDialogSvc.close();
117117
});
118118

119+
it('should NOT open the popup for pending state card ', function() {
120+
var account = {key: 'somekey', provider: 'weblink', status: 'PENDING'};
121+
element.isolateScope().confirmDeletion(account);
122+
scope.$digest();
123+
// should NOT open the popup
124+
expect(ngDialogSvc.open).not.to.be.called;
125+
// should not remove anything from the array of accounts/links
126+
expect(element.isolateScope().linkedAccountsData).to.have.length(8);
127+
// $scope.deletionDialog should not exist
128+
expect(element.isolateScope().deletionDialog).not.to.exist;
129+
});
130+
131+
it('should NOT open the popup for non weblink external link ', function() {
132+
var account = {key: 'somekey', provider: 'stackoverflow'};
133+
element.isolateScope().confirmDeletion(account);
134+
scope.$digest();
135+
// should NOT open the popup
136+
expect(ngDialogSvc.open).not.to.be.called;
137+
// should not remove anything from the array of accounts/links
138+
expect(element.isolateScope().linkedAccountsData).to.have.length(8);
139+
// $scope.deletionDialog should not exist
140+
expect(element.isolateScope().deletionDialog).not.to.exist;
141+
});
142+
119143
});
120144
});

0 commit comments

Comments
 (0)