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

Commit a0d3bc5

Browse files
committed
Merge pull request #619 from appirio-tech/feature/sup-2883-remove-url-aftre-adding-weblink
SUP-2883, URL should be removed after successful adding as web link.
2 parents 5bfb378 + 82973e8 commit a0d3bc5

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
$log.debug("Web link added: " + JSON.stringify(data));
3939
data.data.provider = data.provider;
4040
$scope.linkedAccounts.push(data.data);
41+
// reset the form when it is successfully added
42+
$scope.addWebLinkFrm.$setPristine();
43+
$scope.url = null;
4144
toaster.pop('success', "Success", "Your link has been added. Data from your link will be visible on your profile shortly.");
4245
})
4346
.catch(function(resp) {

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,24 +90,29 @@ describe('ExternalWebLinks Directive', function() {
9090
});
9191
expect(topcoderLink).to.exist;
9292
expect(topcoderLink.status).to.exist.to.equal('PENDING');
93+
expect(element.isolateScope().url).not.to.exist;
9394
expect(toasterSvc.pop).to.have.been.calledWith('success').calledOnce;
9495
});
9596

9697
it('should NOT add new weblink to linkedAccounts', function() {
98+
var urlToAdd = 'https://www.topcoder.com';
9799
element.isolateScope().userHandle = 'throwError';
98-
element.isolateScope().url = 'https://www.topcoder.com';
100+
element.isolateScope().url = urlToAdd;
99101
element.isolateScope().addWebLink();
100102
scope.$digest();
101103
expect(scope.linkedAccounts).to.have.length(1);
104+
expect(element.isolateScope().url).to.exist.to.equal(urlToAdd);
102105
expect(toasterSvc.pop).to.have.been.calledWith('error').calledOnce;
103106
});
104107

105108
it('should NOT add new weblink to linkedAccounts', function() {
109+
var urlToAdd = 'https://www.topcoder.com';
106110
element.isolateScope().userHandle = 'alreadyExistsError';
107-
element.isolateScope().url = 'https://www.topcoder.com';
111+
element.isolateScope().url = urlToAdd;
108112
element.isolateScope().addWebLink();
109113
scope.$digest();
110114
expect(scope.linkedAccounts).to.have.length(1);
115+
expect(element.isolateScope().url).to.exist.to.equal(urlToAdd);
111116
expect(toasterSvc.pop).to.have.been.calledWith('error').calledOnce;
112117
});
113118

0 commit comments

Comments
 (0)