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

Commit e8773ac

Browse files
author
vikasrohit
authored
Merge pull request #873 from appirio-tech/qa-integration
Qa integration
2 parents 0c17d2d + 77583c9 commit e8773ac

File tree

6 files changed

+22
-72
lines changed

6 files changed

+22
-72
lines changed

app/profile/profile.controller.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import moment from 'moment'
2828
'COPILOT': 'copilot'
2929
}
3030

31-
logger.debug()
3231
vm.status = {
3332
'badges': CONSTANTS.STATE_LOADING,
3433
'stats': CONSTANTS.STATE_LOADING,

app/services/jwtInterceptor.service.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ import { isTokenExpired, getFreshToken } from 'tc-accounts'
2727
.catch(function(err) {
2828
// Server will not or cannot refresh token
2929
logger.debug('Unable to refresh V3 token, redirecting to login')
30-
var next = $state.href('dashboard', {}, {absolute: true})
31-
$window.location = CONSTANTS.ACCOUNTS_APP_URL + '?retUrl=' + encodeURIComponent(next)
3230

3331
return null
3432
})
@@ -82,10 +80,8 @@ import { isTokenExpired, getFreshToken } from 'tc-accounts'
8280

8381
// logger.debug('idToken: ' + idToken)
8482
if (!TcAuthService.isAuthenticated() || idToken == null) {
85-
// logger.debug('redirecting to accounts app')
86-
var next = $state.href('dashboard', {}, {absolute: true})
87-
$window.location = CONSTANTS.ACCOUNTS_APP_URL + '?retUrl=' + encodeURIComponent(next)
88-
return
83+
logger.debug(String.supplant('Skipping authToken for "{url}, UnAuthenticated user"', config))
84+
return null
8985
}
9086

9187
// Note only v3tokens expire

app/services/jwtInterceptor.service.spec.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,28 +78,24 @@ describe('JWT Interceptor Service', function() {
7878
expect(TcAuthService.isAuthenticated).to.be.have.been.calledOnce
7979
})
8080

81-
it('should redirect to login page for other endpoints', function() {
81+
it('should return null as token for other endpoints', function() {
8282
var config = {
8383
method: 'get',
8484
url: apiUrl + '/v3/members/test'
8585
}
86-
service.getToken(config)
87-
expect($window.location).not.null
88-
expect($window.location).to.have.string(CONSTANTS.ACCOUNTS_APP_URL)
86+
var token = service.getToken(config)
8987
expect(TcAuthService.isAuthenticated).to.be.have.been.calledOnce
90-
expect(fakeState.href).to.be.calledWith('dashboard')
88+
expect(token).to.be.null
9189
})
9290

93-
it('should redirect to login page for other endpoints', function() {
91+
it('should return null as token for other endpoints', function() {
9492
var config = {
9593
method: 'get',
9694
url: apiUrl + '/v3.0.0-BETA/members/test'
9795
}
98-
service.getToken(config)
99-
expect($window.location).not.null
100-
expect($window.location).to.have.string(CONSTANTS.ACCOUNTS_APP_URL)
96+
var token = service.getToken(config)
10197
expect(TcAuthService.isAuthenticated).to.be.have.been.calledOnce
102-
expect(fakeState.href).to.be.calledWith('dashboard')
98+
expect(token).to.be.null
10399
})
104100

105101
afterEach(function() {

app/skill-picker/skill-picker.controller.js

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import _ from 'lodash'
66

77
angular.module('tc.skill-picker').controller('SkillPickerController', SkillPickerController)
88

9-
SkillPickerController.$inject = ['$scope', 'CONSTANTS', 'ProfileService', '$state', 'userProfile', 'featuredSkills', 'logger', 'toaster', 'MemberCertService', '$q', 'UserPreferencesService']
9+
SkillPickerController.$inject = ['$scope', 'CONSTANTS', 'ProfileService', '$state', 'userProfile', 'featuredSkills', 'logger', 'toaster', 'MemberCertService', '$q']
1010

11-
function SkillPickerController($scope, CONSTANTS, ProfileService, $state, userProfile, featuredSkills, logger, toaster, MemberCertService, $q, UserPreferencesService) {
11+
function SkillPickerController($scope, CONSTANTS, ProfileService, $state, userProfile, featuredSkills, logger, toaster, MemberCertService, $q) {
1212
var vm = this
1313
vm.ASSET_PREFIX = CONSTANTS.ASSET_PREFIX
1414
vm.IOS_PROGRAM_ID = CONSTANTS.SWIFT_PROGRAM_ID
@@ -32,7 +32,6 @@ import _ from 'lodash'
3232
* Activates the controller.
3333
*/
3434
function activate() {
35-
addToMailingList()
3635
initCommunities()
3736
checkCommunityStatus()
3837
}
@@ -138,25 +137,6 @@ import _ from 'lodash'
138137
}
139138
}
140139

141-
function addToMailingList() {
142-
return UserPreferencesService.getEmailPreferences(userProfile).then(function(subscription) {
143-
logger.debug(subscription)
144-
if (!subscription) {
145-
return UserPreferencesService.saveEmailPreferences(userProfile).then(function(resp) {
146-
logger.debug(resp)
147-
}).catch(function(err) {
148-
// no error to user
149-
//TODO some error alert to community admin
150-
logger.debug('error in adding user to member list')
151-
})
152-
}
153-
}).catch(function(err) {
154-
// no error to user
155-
//TODO some error alert to community admin
156-
logger.debug('error in adding user to member list')
157-
})
158-
}
159-
160140
/**
161141
* Persists the user's altered information.
162142
*/

app/skill-picker/skill-picker.spec.js

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -138,39 +138,6 @@ describe('Skill Picker Controller', function() {
138138
CONSTANTS.SWIFT_PROGRAM_ID = origSwiftProgId
139139
})
140140

141-
it('should call mailchimp service to add subscription', function() {
142-
expect(vm).to.exist
143-
// getEmailPreferences should always be called
144-
expect(userPrefSvc.getEmailPreferences).to.be.calledOnce
145-
// saveEmailPreferences should be called once if not subscribed
146-
// getEmailPreferences service mock returns null for mockProfile.userId
147-
expect(userPrefSvc.saveEmailPreferences).to.be.calledOnce
148-
})
149-
150-
it('should not call mailchimp service to add subscription', function() {
151-
// reset getEmailPreferences, saveEmailPreferences spy's called count
152-
userPrefSvc.getEmailPreferences.reset()
153-
userPrefSvc.saveEmailPreferences.reset()
154-
var scope = $rootScope.$new()
155-
156-
var profile = angular.copy(mockProfile)
157-
// update userId to return valid object in service mock
158-
profile.userId = 12345
159-
vm = $controller('SkillPickerController', {
160-
$scope: scope,
161-
userProfile: profile,
162-
featuredSkills: [],
163-
$state: state
164-
})
165-
$rootScope.$digest()
166-
expect(vm).to.exist
167-
// getEmailPreferences should always be called
168-
expect(userPrefSvc.getEmailPreferences).to.be.calledOnce
169-
// saveEmailPreferences should not be called if already subscribed
170-
// getEmailPreferences service mock returns valid object for userId 12345
171-
expect(userPrefSvc.saveEmailPreferences).not.to.be.called
172-
})
173-
174141
it('should add skill ', function() {
175142
vm.toggleSkill(409)
176143
expect(vm.mySkills).to.exist.have.length(1)

webpack.config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,18 @@ const config = require('appirio-tech-webpack-config')({
3737
}
3838
})
3939

40+
if (process.env.ENV === 'DEV') {
41+
config.devServer = config.devServer ? config.devServer : {}
42+
config.devServer.proxy = [
43+
{
44+
path: /\/members\/.*/,
45+
bypass: function(req, res, proxyOptions) {
46+
return '/index.html'
47+
}
48+
}
49+
]
50+
}
51+
4052
if (CI) config.output.publicPath = process.env.ASSET_PREFIX
4153

4254
if (accountsAppURL) {

0 commit comments

Comments
 (0)