-
Notifications
You must be signed in to change notification settings - Fork 15
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
fix: Replace public implementation to display delegatee info with platform #3172
Changes from 10 commits
68f4e03
6b5c2a7
c0b09a9
2e03d2f
fd9549f
3ae95c5
27c2f59
60c0c12
3b0d85b
aa2075f
0a085e7
a4b89e1
fbe640a
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import deepFreeze from 'deep-freeze-strict'; | ||
import { Delegator } from 'src/app/core/models/platform/delegator.model'; | ||
|
||
export const delegatorData: Delegator = deepFreeze({ | ||
user_id: '0x1234', | ||
email: '[email protected]', | ||
full_name: 'Vercetti', | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import deepFreeze from 'deep-freeze-strict'; | ||
import { DelegationType } from 'src/app/core/models/platform/delegation-type.enum'; | ||
import { PlatformApiResponse } from 'src/app/core/models/platform/platform-api-response.model'; | ||
import { PlatformEmployee } from 'src/app/core/models/platform/platform-employee.model'; | ||
|
||
export const platformEmployeeData: PlatformEmployee = deepFreeze({ | ||
code: null, | ||
department: { | ||
code: null, | ||
display_name: 'Tech', | ||
id: 'deptCjFrZcE0rH', | ||
name: 'Tech', | ||
sub_department: 'Tech', | ||
}, | ||
department_id: 'deptCjFrZcE0rH', | ||
id: 'ouirDZ7tTLEQ', | ||
org_id: 'orNVthTo2Zyo', | ||
user: { | ||
email: '[email protected]', | ||
full_name: 'Arjun', | ||
id: 'usJZ9bgfNB5n', | ||
}, | ||
user_id: 'usJZ9bgfNB5n', | ||
delegatees: [ | ||
{ | ||
id: 100, | ||
type: DelegationType.PERMANENT, | ||
user_id: '0x1234', | ||
email: '[email protected]', | ||
full_name: 'Vercetti', | ||
start_at: new Date(), | ||
end_at: null, | ||
}, | ||
], | ||
}); | ||
|
||
export const platformEmployeeResponse: PlatformApiResponse<PlatformEmployee> = deepFreeze({ | ||
count: 1, | ||
offset: 10, | ||
data: platformEmployeeData, | ||
}); | ||
|
||
export const platformEmployeeEmptyResponse: PlatformApiResponse<PlatformEmployee> = deepFreeze({ | ||
count: 1, | ||
offset: 10, | ||
data: null, | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,5 @@ export interface EmployeeParams { | |
order: string; | ||
limit: number; | ||
us_email?: string; | ||
us_id: string; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { DelegationType } from './delegation-type.enum'; | ||
|
||
export interface Delegatee { | ||
id: number; | ||
type: DelegationType; | ||
user_id: string; | ||
email: string; | ||
full_name: string; | ||
start_at: Date; | ||
end_at: Date; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export enum DelegationType { | ||
SHORT_TERM, | ||
PERMANENT, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export interface Delegator { | ||
user_id: string; | ||
email: string; | ||
full_name: string; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,14 +26,12 @@ | |
<ion-grid> | ||
<ion-row> | ||
<ion-col size="2"> | ||
<div class="delegated--org-thumb">{{ acc?.us?.full_name | initials | uppercase }}</div> | ||
<div class="delegated--org-thumb">{{ acc?.full_name | initials | uppercase }}</div> | ||
</ion-col> | ||
<ion-col size="10"> | ||
<div class="delegated--org-element-name">{{acc?.us?.full_name}}</div> | ||
<div class="delegated--org-element-us-details">{{acc?.us?.email}}</div> | ||
<div *ngIf="acc?.ou.org_id === currentOrg.id" class="delegated--org-element-us-details"> | ||
{{currentOrg.name}} | ||
</div> | ||
<div class="delegated--org-element-name">{{acc?.full_name}}</div> | ||
<div class="delegated--org-element-us-details">{{acc?.email}}</div> | ||
<div class="delegated--org-element-us-details">{{currentOrg.name}}</div> | ||
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. why have we removed the condition here? @harshal015 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. it'll be anyway visible for all delegators as the API will respond with delegators from same org. 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. can entirely remove the org name as well |
||
</ion-col> | ||
</ion-row> | ||
</ion-grid> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ import { OrgUserService } from 'src/app/core/services/org-user.service'; | |
import { OrgService } from 'src/app/core/services/org.service'; | ||
import { RecentLocalStorageItemsService } from 'src/app/core/services/recent-local-storage-items.service'; | ||
import { DelegatedAccountsPage } from './delegated-accounts.page'; | ||
import { delegatorData } from 'src/app/core/mock-data/platform/v1/delegator.data'; | ||
|
||
describe('DelegatedAccountsPage', () => { | ||
let component: DelegatedAccountsPage; | ||
|
@@ -132,21 +133,19 @@ describe('DelegatedAccountsPage', () => { | |
component.searchDelegatees = getElementRef(fixture, '.delegated--search-input'); | ||
const input = component.searchDelegatees.nativeElement as HTMLInputElement; | ||
activatedRoute.snapshot.params.switchToOwn = null; | ||
orgUserService.findDelegatedAccounts.and.returnValue(of([apiEouRes, eouRes2, eouRes3])); | ||
orgUserService.findDelegatedAccounts.and.returnValue(of([delegatorData])); | ||
orgService.getCurrentOrg.and.returnValue(of(orgData1[0])); | ||
orgUserService.excludeByStatus.and.returnValue([eouRes2, eouRes3]); | ||
|
||
component.ionViewWillEnter(); | ||
tick(500); | ||
|
||
input.value = '[email protected]'; | ||
input.value = '[email protected]'; | ||
input.dispatchEvent(new Event('keyup')); | ||
tick(500); | ||
|
||
expect(component.delegatedAccList).toEqual([eouRes2, eouRes3]); | ||
expect(component.delegatedAccList).toEqual([delegatorData]); | ||
expect(orgUserService.findDelegatedAccounts).toHaveBeenCalledTimes(1); | ||
expect(orgService.getCurrentOrg).toHaveBeenCalledTimes(1); | ||
expect(orgUserService.excludeByStatus).toHaveBeenCalledWith([apiEouRes, eouRes2, eouRes3], 'DISABLED'); | ||
})); | ||
|
||
it('should set delegatee acc list to empty array if no accounts are provided', fakeAsync(() => { | ||
|
@@ -167,7 +166,6 @@ describe('DelegatedAccountsPage', () => { | |
expect(component.delegatedAccList).toEqual([]); | ||
expect(orgUserService.findDelegatedAccounts).toHaveBeenCalledTimes(1); | ||
expect(orgService.getCurrentOrg).toHaveBeenCalledTimes(1); | ||
expect(orgUserService.excludeByStatus).toHaveBeenCalledWith([], 'DISABLED'); | ||
})); | ||
}); | ||
}); |
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.
What happens if acc is undefined or null?
Are we handling the null cases as well?
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.
we are displaying switch accounts page only if its non empty, so it'll always have a value