From a0079dfa6bcc941765f4b9b7c37db7dd51a9c65b Mon Sep 17 00:00:00 2001 From: vikasrohit <vikas.agarwal@appirio.com> Date: Mon, 21 Dec 2015 12:46:01 +0530 Subject: [PATCH 1/2] SUP-2883, URL should be removed after successful adding as web link. -- Fixed --- .../external-account/external-web-links.directive.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/directives/external-account/external-web-links.directive.js b/app/directives/external-account/external-web-links.directive.js index 3367d474b..187d76e98 100644 --- a/app/directives/external-account/external-web-links.directive.js +++ b/app/directives/external-account/external-web-links.directive.js @@ -38,6 +38,9 @@ $log.debug("Web link added: " + JSON.stringify(data)); data.data.provider = data.provider; $scope.linkedAccounts.push(data.data); + // reset the form when it is successfully added + $scope.addWebLinkFrm.$setPristine(); + $scope.url = null; toaster.pop('success', "Success", "Your link has been added. Data from your link will be visible on your profile shortly."); }) .catch(function(resp) { From 82973e8276026c9f6e2a1a8d31ce6dc2dc921281 Mon Sep 17 00:00:00 2001 From: vikasrohit <vikas.agarwal@appirio.com> Date: Mon, 21 Dec 2015 13:22:51 +0530 Subject: [PATCH 2/2] SUP-2883, URL should be removed after successful adding as web link. -- Updated unit tests --- .../external-web-links.directive.spec.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/directives/external-account/external-web-links.directive.spec.js b/app/directives/external-account/external-web-links.directive.spec.js index 6e8997e8b..3385a7706 100644 --- a/app/directives/external-account/external-web-links.directive.spec.js +++ b/app/directives/external-account/external-web-links.directive.spec.js @@ -90,24 +90,29 @@ describe('ExternalWebLinks Directive', function() { }); expect(topcoderLink).to.exist; expect(topcoderLink.status).to.exist.to.equal('PENDING'); + expect(element.isolateScope().url).not.to.exist; expect(toasterSvc.pop).to.have.been.calledWith('success').calledOnce; }); it('should NOT add new weblink to linkedAccounts', function() { + var urlToAdd = 'https://www.topcoder.com'; element.isolateScope().userHandle = 'throwError'; - element.isolateScope().url = 'https://www.topcoder.com'; + element.isolateScope().url = urlToAdd; element.isolateScope().addWebLink(); scope.$digest(); expect(scope.linkedAccounts).to.have.length(1); + expect(element.isolateScope().url).to.exist.to.equal(urlToAdd); expect(toasterSvc.pop).to.have.been.calledWith('error').calledOnce; }); it('should NOT add new weblink to linkedAccounts', function() { + var urlToAdd = 'https://www.topcoder.com'; element.isolateScope().userHandle = 'alreadyExistsError'; - element.isolateScope().url = 'https://www.topcoder.com'; + element.isolateScope().url = urlToAdd; element.isolateScope().addWebLink(); scope.$digest(); expect(scope.linkedAccounts).to.have.length(1); + expect(element.isolateScope().url).to.exist.to.equal(urlToAdd); expect(toasterSvc.pop).to.have.been.calledWith('error').calledOnce; });