forked from carbon-design-system/carbon-for-ibm-dotcom
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(profile): change profile api endpoint (carbon-design-system#4909)
### Related Ticket(s) Change profile endpoint on Carbon Masthead for signed in state carbon-design-system#4701 ### Description Change profile endpoint which no longer allows for jsonp to get around CORS errors. Set the new preprod profile endpoint as default. ### Changelog **Changed** - use `axios` for the profile calls - set default host endpoint to preprod url **Removed** - `jsonp` package - no longer needed <!-- React and Web Component deploy previews are enabled by default. --> <!-- To enable additional available deploy previews, apply the following --> <!-- labels for the corresponding package: --> <!-- *** "package: services": Services --> <!-- *** "package: utilities": Utilities --> <!-- *** "package: styles": Carbon Expressive --> <!-- *** "RTL": React / Web Components (RTL) --> <!-- *** "feature flag": React / Web Components (experimental) -->
- Loading branch information
1 parent
9ac7c98
commit 09c6b09
Showing
15 changed files
with
123 additions
and
149 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/** | ||
* @license | ||
* | ||
* Copyright IBM Corp. 2020 | ||
* Copyright IBM Corp. 2020, 2021 | ||
* | ||
* This source code is licensed under the Apache-2.0 license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
|
@@ -10,10 +10,10 @@ | |
import configureMockStore from 'redux-mock-store'; | ||
import { AnyAction } from 'redux'; | ||
import thunk, { ThunkDispatch } from 'redux-thunk'; | ||
import ProfileAPI from '@carbon/ibmdotcom-services/es/services/Profile/Profile.js'; | ||
import { USER_AUTHENTICATION_STATUS, PROFILE_API_ACTION, ProfileAPIState } from '../../types/profileAPI'; | ||
import convertValue from '../../../tests/utils/convert-value'; | ||
import { setUserStatus, monitorUserStatus } from '../profileAPI'; | ||
// import ProfileAPI from '@carbon/ibmdotcom-services/es/services/Profile/Profile.js'; | ||
import { PROFILE_API_ACTION, ProfileAPIState } from '../../types/profileAPI'; | ||
// import convertValue from '../../../tests/utils/convert-value'; | ||
import { setUserStatus } from '../profileAPI'; | ||
|
||
jest.mock('@carbon/ibmdotcom-services/es/services/Profile/Profile'); | ||
|
||
|
@@ -25,45 +25,42 @@ const mockStore = configureMockStore< | |
describe('Redux actions for `ProfileAPI`', () => { | ||
it('dispatches the action to set user authentication status', () => { | ||
const store = mockStore(); | ||
store.dispatch(setUserStatus({ user: USER_AUTHENTICATION_STATUS.AUTHENTICATED })); | ||
store.dispatch(setUserStatus({ user: '[email protected]' })); | ||
expect(store.getActions()).toEqual([ | ||
{ | ||
type: PROFILE_API_ACTION.SET_USER_STATUS, | ||
status: { user: USER_AUTHENTICATION_STATUS.AUTHENTICATED }, | ||
status: { user: '[email protected]' }, | ||
}, | ||
]); | ||
}); | ||
|
||
it('dispatches the action to monitor user authentication status', () => { | ||
ProfileAPI.monitorUserStatus.mockImplementation(callback => { | ||
callback(null, { user: USER_AUTHENTICATION_STATUS.AUTHENTICATED }); | ||
callback(null, { user: USER_AUTHENTICATION_STATUS.UNAUTHENTICATED }); | ||
}); | ||
const store = mockStore(); | ||
store.dispatch(monitorUserStatus()); | ||
expect(convertValue(store.getActions())).toEqual([ | ||
{ | ||
type: PROFILE_API_ACTION.SET_USER_STATUS, | ||
status: { user: USER_AUTHENTICATION_STATUS.AUTHENTICATED }, | ||
}, | ||
{ | ||
type: PROFILE_API_ACTION.SET_USER_STATUS, | ||
status: { user: USER_AUTHENTICATION_STATUS.UNAUTHENTICATED }, | ||
}, | ||
]); | ||
}); | ||
// it('dispatches the action to get user authentication status', async () => { | ||
// ProfileAPI.getUserStatus.mockResolvedValue({ user: 'Unauthenticated' }); | ||
// const store = mockStore(); | ||
// await store.dispatch(ProfileAPI.getUserStatus()); | ||
// expect(convertValue(store.getActions())).toEqual([ | ||
// { | ||
// type: PROFILE_API_ACTION.SET_REQUEST_USER_STATUS_IN_PROGRESS, | ||
// request: 'PROMISE', | ||
// }, | ||
// { | ||
// type: PROFILE_API_ACTION.SET_USER_STATUS, | ||
// status: { user: 'Unauthenticated' }, | ||
// }, | ||
// ]); | ||
// }); | ||
|
||
it('dispatches the action of error in monitoring user authentication status', () => { | ||
ProfileAPI.monitorUserStatus.mockImplementation(callback => { | ||
callback(new Error('error-monitoruserstatus')); | ||
}); | ||
const store = mockStore(); | ||
store.dispatch(monitorUserStatus()); | ||
expect(convertValue(store.getActions())).toEqual([ | ||
{ | ||
type: PROFILE_API_ACTION.SET_ERROR_MONITOR_USER_STATUS, | ||
error: 'error-monitoruserstatus', | ||
}, | ||
]); | ||
}); | ||
// it('dispatches the action of error in monitoring user authentication status', () => { | ||
// ProfileAPI.getUserStatus.mockImplementation(callback => { | ||
// callback(new Error('error-getuserstatus')); | ||
// }); | ||
// const store = mockStore(); | ||
// store.dispatch(getUserStatus()); | ||
// expect(convertValue(store.getActions())).toEqual([ | ||
// { | ||
// type: PROFILE_API_ACTION.SET_ERROR_REQUEST_USER_STATUS, | ||
// error: 'error-getuserstatus', | ||
// }, | ||
// ]); | ||
// }); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,33 @@ | ||
/** | ||
* @license | ||
* | ||
* Copyright IBM Corp. 2020 | ||
* Copyright IBM Corp. 2020, 2021 | ||
* | ||
* This source code is licensed under the Apache-2.0 license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import { USER_AUTHENTICATION_STATUS, PROFILE_API_ACTION, ProfileAPIState } from '../../types/profileAPI'; | ||
import { PROFILE_API_ACTION, ProfileAPIState } from '../../types/profileAPI'; | ||
import { ProfileAPIActions } from '../../actions/profileAPI'; | ||
import convertValue from '../../../tests/utils/convert-value'; | ||
import reducer from '../profileAPI'; | ||
|
||
describe('Redux reducers for `ProfileAPI`', () => { | ||
it('should return the state unmodified for unknown action', () => { | ||
const state = { status: { user: USER_AUTHENTICATION_STATUS.AUTHENTICATED } }; | ||
const state = { status: { user: '[email protected]' } }; | ||
expect(reducer(state, {} as ProfileAPIActions)).toEqual(state); | ||
}); | ||
|
||
it('should support setting error in monitoring user authentication status', () => { | ||
expect( | ||
convertValue( | ||
reducer({} as ProfileAPIState, { | ||
type: PROFILE_API_ACTION.SET_ERROR_MONITOR_USER_STATUS, | ||
type: PROFILE_API_ACTION.SET_ERROR_REQUEST_USER_STATUS, | ||
error: new Error('error-user-status'), | ||
}) | ||
) | ||
).toEqual({ | ||
errorMonitorUserStatus: 'error-user-status', | ||
errorGetUserStatus: 'error-user-status', | ||
}); | ||
}); | ||
|
||
|
@@ -36,11 +36,11 @@ describe('Redux reducers for `ProfileAPI`', () => { | |
convertValue( | ||
reducer({} as ProfileAPIState, { | ||
type: PROFILE_API_ACTION.SET_USER_STATUS, | ||
status: { user: USER_AUTHENTICATION_STATUS.AUTHENTICATED }, | ||
status: { user: '[email protected]' }, | ||
}) | ||
) | ||
).toEqual({ | ||
status: { user: USER_AUTHENTICATION_STATUS.AUTHENTICATED }, | ||
status: { user: '[email protected]' }, | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.