-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: #1848 filter app lists when using the marketplace in Developer Edition #1851
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,6 +66,7 @@ const appState: ReduxState = { | |
adminId: null, | ||
userCode: 'testUserCode', | ||
userTel: '123', | ||
groups: ['AgencyCloudDeveloperEdition'], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above |
||
}, | ||
}, | ||
isTermAccepted: false, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import { ReduxState } from '@/types/core' | ||
import { | ||
selectClientId, | ||
selectDeveloperId, | ||
selectLoggedUserEmail, | ||
selectFeaturedApps, | ||
selectWebComponentOpen, | ||
|
@@ -37,6 +38,42 @@ describe('selectClientId', () => { | |
}) | ||
}) | ||
|
||
describe('selectDeveloperId', () => { | ||
it('should run correctly when user in AgencyCloudDeveloperEdition group', () => { | ||
const input = { | ||
auth: { | ||
loginSession: { | ||
loginIdentity: { | ||
clientId: '123', | ||
email: '[email protected]', | ||
developerId: '1234', | ||
groups: ['AgencyCloudDeveloperEdition'], | ||
}, | ||
}, | ||
}, | ||
} as ReduxState | ||
const result = selectDeveloperId(input) | ||
expect(result).toEqual('1234') | ||
}) | ||
|
||
it('should run correctly when user NOT in AgencyCloudDeveloperEdition group', () => { | ||
const input = { | ||
auth: { | ||
loginSession: { | ||
loginIdentity: { | ||
clientId: '123', | ||
email: '[email protected]', | ||
developerId: '1234', | ||
groups: [''], | ||
}, | ||
}, | ||
}, | ||
} as ReduxState | ||
const result = selectDeveloperId(input) | ||
expect(result).toEqual(null) | ||
}) | ||
}) | ||
|
||
describe('selectLoggedUserEmail', () => { | ||
it('should run correctly', () => { | ||
const input = { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,11 +6,26 @@ import { WebComponentConfigResult } from '@/services/web-component' | |
import { InstalledAppsState } from '@/reducers/installed-apps' | ||
import { AppSummaryModel } from '@reapit/foundations-ts-definitions' | ||
import { ClientAppSummaryState } from '@/reducers/client/app-summary' | ||
import { selectLoginIdentity } from '@/selector/auth' | ||
import { COGNITO_GROUP_DEVELOPER_EDITION } from '@/constants/api' | ||
|
||
export const selectClientId = (state: ReduxState) => { | ||
return state?.auth?.loginSession?.loginIdentity?.clientId || '' | ||
} | ||
|
||
/** | ||
* Need get developer id to filter apps list if this user belong to | ||
* AgencyCloudDeveloperEdition group, if not just return null | ||
* refer to this ticket https://github.com/reapit/foundations/issues/1848 | ||
*/ | ||
export const selectDeveloperId = (state: ReduxState) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Naming seems ambiguous to me even with comment on the func. Imagine we will need to selectDeveloperId in the future without this logic. Something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @phmngocnghia's comment makes sense, and should add return value type too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
const loginIdentity = selectLoginIdentity(state) | ||
if (loginIdentity?.groups.includes(COGNITO_GROUP_DEVELOPER_EDITION)) { | ||
return state?.auth?.loginSession?.loginIdentity?.developerId || '' | ||
} | ||
return null | ||
} | ||
|
||
export const selectLoggedUserEmail = (state: ReduxState): string => { | ||
return state?.auth?.loginSession?.loginIdentity?.email || '' | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should use const
COGNITO_GROUP_DEVELOPER_EDITION