-
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
feat: Migrate /v2/spender_employees to platform #3562
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b5b7bad
feat: migrate /v2/spender_employees to platform
Z3RO-O 2d7d02d
removed unused service import
Z3RO-O 7b87dcb
removed id.asc
Z3RO-O aa07f7a
fix: unit tests for migrate /v2/spender_employees to platform (#3573)
Z3RO-O 4958a28
pr review fixes
Z3RO-O 67bf5af
pr review fixes
Z3RO-O File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 |
---|---|---|
|
@@ -2,132 +2,141 @@ import deepFreeze from 'deep-freeze-strict'; | |
|
||
import { Employee } from '../models/spender/employee.model'; | ||
|
||
export const selectedItem: Record<string, boolean> = deepFreeze({ | ||
'[email protected]': true, | ||
'[email protected]': true, | ||
'[email protected]': true, | ||
'[email protected]': true, | ||
'[email protected]': true, | ||
'[email protected]': true, | ||
}); | ||
|
||
export const selectedOptionRes: Partial<Employee> = deepFreeze({ | ||
ou_id: 'oubQzXeZbwbS', | ||
ou_org_id: 'orNVthTo2Zyo', | ||
ou_roles: '["FYLER","APPROVER","HOD","HOP","AUDITOR","FINANCE"]', | ||
ou_status: '"ACTIVE"', | ||
us_email: '[email protected]', | ||
us_full_name: 'AA', | ||
us_id: 'usTdvbcxOqjs', | ||
id: 'oubQzXeZbwbS', | ||
roles: '["FYLER","APPROVER","HOD","HOP","AUDITOR","FINANCE"]', | ||
is_enabled: true, | ||
has_accepted_invite: true, | ||
email: '[email protected]', | ||
full_name: 'AA', | ||
user_id: 'usTdvbcxOqjs', | ||
is_selected: false, | ||
}); | ||
|
||
export const filteredOptionsRes: Partial<Employee>[] = deepFreeze([ | ||
{ | ||
ou_id: 'oubQzXeZbwbS', | ||
ou_org_id: 'orNVthTo2Zyo', | ||
ou_roles: '["FYLER","APPROVER","HOD","HOP","AUDITOR","FINANCE"]', | ||
ou_status: '"ACTIVE"', | ||
us_email: '[email protected]', | ||
us_full_name: 'AA', | ||
us_id: 'usTdvbcxOqjs', | ||
id: 'oubQzXeZbwbS', | ||
roles: '["FYLER","APPROVER","HOD","HOP","AUDITOR","FINANCE"]', | ||
is_enabled: true, | ||
has_accepted_invite: true, | ||
email: '[email protected]', | ||
full_name: 'AA', | ||
user_id: 'usTdvbcxOqjs', | ||
is_selected: true, | ||
}, | ||
{ | ||
ou_id: 'oumDNNh9CfNY', | ||
ou_org_id: 'orNVthTo2Zyo', | ||
ou_roles: '["FYLER","FINANCE","ADMIN","APPROVER"]', | ||
ou_status: '"PENDING_DETAILS"', | ||
us_email: '[email protected]', | ||
us_full_name: 'Aastha', | ||
us_id: 'usqeLyJzMvjv', | ||
id: 'oumDNNh9CfNY', | ||
roles: '["FYLER","FINANCE","ADMIN","APPROVER"]', | ||
is_enabled: true, | ||
has_accepted_invite: false, | ||
email: '[email protected]', | ||
full_name: 'Aastha', | ||
user_id: 'usqeLyJzMvjv', | ||
is_selected: false, | ||
}, | ||
{ | ||
ou_id: 'ouPoW69slRBp', | ||
ou_org_id: 'orNVthTo2Zyo', | ||
ou_roles: '["FYLER","APPROVER","HOD","HOP","ADMIN","PAYMENT_PROCESSOR"]', | ||
ou_status: '"ACTIVE"', | ||
us_email: '[email protected]', | ||
us_full_name: 'Aastha B', | ||
us_id: 'usRjTPO4r69K', | ||
id: 'ouPoW69slRBp', | ||
roles: '["FYLER","APPROVER","HOD","HOP","ADMIN","PAYMENT_PROCESSOR"]', | ||
is_enabled: true, | ||
has_accepted_invite: true, | ||
email: '[email protected]', | ||
full_name: 'Aastha B', | ||
user_id: 'usRjTPO4r69K', | ||
is_selected: false, | ||
}, | ||
{ | ||
ou_id: 'ouE7qv3Y45oz', | ||
ou_org_id: 'orNVthTo2Zyo', | ||
ou_roles: '["FYLER","APPROVER","FINANCE","HOP"]', | ||
ou_status: '"ACTIVE"', | ||
us_email: '[email protected]', | ||
us_full_name: 'abcdd', | ||
us_id: 'usQx07v17BX5', | ||
id: 'ouE7qv3Y45oz', | ||
roles: '["FYLER","APPROVER","FINANCE","HOP"]', | ||
is_enabled: true, | ||
has_accepted_invite: true, | ||
email: '[email protected]', | ||
full_name: 'abcdd', | ||
user_id: 'usQx07v17BX5', | ||
is_selected: false, | ||
}, | ||
{ | ||
ou_id: 'ouKmdituKMi9', | ||
ou_org_id: 'orNVthTo2Zyo', | ||
ou_roles: '["APPROVER","FYLER","AUDITOR","HOP","HOD","ADMIN"]', | ||
ou_status: '"ACTIVE"', | ||
us_email: '[email protected]', | ||
us_full_name: 'Abhishek', | ||
us_id: 'usrLNunqplye', | ||
id: 'ouKmdituKMi9', | ||
roles: '["APPROVER","FYLER","AUDITOR","HOP","HOD","ADMIN"]', | ||
is_enabled: true, | ||
has_accepted_invite: true, | ||
email: '[email protected]', | ||
full_name: 'Abhishek', | ||
user_id: 'usrLNunqplye', | ||
is_selected: false, | ||
}, | ||
{ | ||
ou_id: 'ouTi8ul9u51y', | ||
ou_org_id: 'orNVthTo2Zyo', | ||
ou_roles: '["FYLER"]', | ||
ou_status: '"PENDING_DETAILS"', | ||
us_email: '[email protected]', | ||
us_full_name: 'Abhishek', | ||
us_id: 'usi3jriNhseA', | ||
id: 'ouTi8ul9u51y', | ||
roles: '["FYLER"]', | ||
is_enabled: true, | ||
has_accepted_invite: false, | ||
email: '[email protected]', | ||
full_name: 'Abhishek', | ||
user_id: 'usi3jriNhseA', | ||
is_selected: false, | ||
}, | ||
]); | ||
|
||
export const filteredDataRes: Partial<Employee>[] = deepFreeze([ | ||
{ | ||
us_email: '[email protected]', | ||
email: '[email protected]', | ||
is_selected: true, | ||
}, | ||
{ | ||
us_email: '[email protected]', | ||
email: '[email protected]', | ||
is_selected: true, | ||
}, | ||
{ | ||
us_email: '[email protected]', | ||
email: '[email protected]', | ||
is_selected: true, | ||
}, | ||
{ | ||
us_email: '[email protected]', | ||
email: '[email protected]', | ||
is_selected: true, | ||
}, | ||
{ | ||
us_email: '[email protected]', | ||
email: '[email protected]', | ||
is_selected: true, | ||
}, | ||
]); | ||
|
||
export const searchedUserListRes: Partial<Employee>[] = deepFreeze([ | ||
{ | ||
ou_id: 'oubQzXeZbwbS', | ||
ou_org_id: 'orNVthTo2Zyo', | ||
ou_roles: '["FYLER","APPROVER","HOD","HOP"]', | ||
ou_status: '"ACTIVE"', | ||
us_email: '[email protected]', | ||
us_full_name: 'AA23', | ||
us_id: 'usTdvbcxOqjs', | ||
id: 'oubQzXeZbwbS', | ||
roles: '["FYLER","APPROVER","HOD","HOP"]', | ||
is_enabled: true, | ||
has_accepted_invite: true, | ||
email: '[email protected]', | ||
full_name: 'AA23', | ||
user_id: 'usTdvbcxOqjs', | ||
is_selected: true, | ||
}, | ||
{ | ||
ou_id: 'ouXYHXfr4w0b', | ||
ou_org_id: 'orNVthTo2Zyo', | ||
ou_roles: '["FYLER","APPROVER","HOP"]', | ||
ou_status: '"PENDING_DETAILS"', | ||
us_email: '[email protected]', | ||
us_full_name: 'AAA', | ||
us_id: 'usBBavu872gu', | ||
id: 'ouXYHXfr4w0b', | ||
roles: '["FYLER","APPROVER","HOP"]', | ||
is_enabled: true, | ||
has_accepted_invite: false, | ||
email: '[email protected]', | ||
full_name: 'AAA', | ||
user_id: 'usBBavu872gu', | ||
is_selected: true, | ||
}, | ||
{ | ||
ou_id: 'ouX8dwsbLCLv', | ||
ou_org_id: 'orNVthTo2Zyo', | ||
ou_roles: '["FINANCE","ADMIN","APPROVER","FYLER","VERIFIER","PAYMENT_PROCESSOR","AUDITOR","HOP","HOD","OWNER"]', | ||
ou_status: '"ACTIVE"', | ||
us_email: '[email protected]', | ||
us_full_name: 'Abhishek Jain', | ||
us_id: 'usvKA4X8Ugcr', | ||
id: 'ouX8dwsbLCLv', | ||
roles: '["FINANCE","ADMIN","APPROVER","FYLER","VERIFIER","PAYMENT_PROCESSOR","AUDITOR","HOP","HOD","OWNER"]', | ||
is_enabled: true, | ||
has_accepted_invite: true, | ||
email: '[email protected]', | ||
full_name: 'Abhishek Jain', | ||
user_id: 'usvKA4X8Ugcr', | ||
is_selected: false, | ||
}, | ||
]); |
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,10 +1,10 @@ | ||
export interface Employee { | ||
ou_id: string; | ||
ou_org_id: string; | ||
ou_roles: string; | ||
ou_status: string; | ||
us_email: string; | ||
us_full_name: string; | ||
us_id: string; | ||
id: string; | ||
roles: string; | ||
is_enabled: boolean; | ||
has_accepted_invite: boolean; | ||
email: string; | ||
full_name: string; | ||
user_id: string; | ||
is_selected?: boolean; // used to show checkmarks while selecting employee | ||
} | ||
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 |
---|---|---|
|
@@ -14,7 +14,6 @@ import { | |
accessTokenData, | ||
accessTokenWithProxyOrgUserId, | ||
} from '../test-data/org-user.service.spec.data'; | ||
import { ApiV2Service } from './api-v2.service'; | ||
import { ApiService } from './api.service'; | ||
import { AuthService } from './auth.service'; | ||
import { DataTransformService } from './data-transform.service'; | ||
|
@@ -31,12 +30,10 @@ describe('OrgUserService', () => { | |
let apiService: jasmine.SpyObj<ApiService>; | ||
let authService: jasmine.SpyObj<AuthService>; | ||
let dataTransformService: jasmine.SpyObj<DataTransformService>; | ||
let apiV2Service: jasmine.SpyObj<ApiV2Service>; | ||
let spenderPlatformV1ApiService: jasmine.SpyObj<SpenderPlatformV1ApiService>; | ||
|
||
beforeEach(() => { | ||
const apiServiceSpy = jasmine.createSpyObj('ApiService', ['get', 'post']); | ||
const apiv2ServiceSpy = jasmine.createSpyObj('ApiV2Service', ['get']); | ||
const spenderPlatformV1ApiServiceSpy = jasmine.createSpyObj('spenderPlatformV1ApiService', ['get']); | ||
const jwtHelperServiceSpy = jasmine.createSpyObj('JwtHelperService', ['decodeToken']); | ||
const tokenServiceSpy = jasmine.createSpyObj('TokenService', ['getAccessToken']); | ||
|
@@ -50,10 +47,6 @@ describe('OrgUserService', () => { | |
provide: ApiService, | ||
useValue: apiServiceSpy, | ||
}, | ||
{ | ||
provide: ApiV2Service, | ||
useValue: apiv2ServiceSpy, | ||
}, | ||
{ | ||
provide: SpenderPlatformV1ApiService, | ||
useValue: spenderPlatformV1ApiServiceSpy, | ||
|
@@ -78,7 +71,6 @@ describe('OrgUserService', () => { | |
}); | ||
orgUserService = TestBed.inject(OrgUserService); | ||
apiService = TestBed.inject(ApiService) as jasmine.SpyObj<ApiService>; | ||
apiV2Service = TestBed.inject(ApiV2Service) as jasmine.SpyObj<ApiV2Service>; | ||
spenderPlatformV1ApiService = TestBed.inject( | ||
SpenderPlatformV1ApiService | ||
) as jasmine.SpyObj<SpenderPlatformV1ApiService>; | ||
|
@@ -113,50 +105,50 @@ describe('OrgUserService', () => { | |
}); | ||
|
||
it('should be able to get employees by params', (done) => { | ||
apiV2Service.get.and.returnValue(of(employeesRes)); | ||
spenderPlatformV1ApiService.get.and.returnValue(of(employeesRes)); | ||
const params = { | ||
limit: 5, | ||
order: 'us_full_name.asc,ou_id', | ||
ou_id: 'not.eq.ouX8dwsbLCLv', | ||
ou_org_id: 'eq.orNVthTo2Zyo', | ||
ou_roles: 'like.%ADMIN%', | ||
ou_status: 'eq."ACTIVE"', | ||
select: 'us_full_name,us_email', | ||
order: 'full_name.asc', | ||
id: 'neq.ouX8dwsbLCLv', | ||
roles: 'like.%ADMIN%', | ||
is_enabled: 'eq.true', | ||
has_accepted_invite: 'eq.true', | ||
select: 'full_name,email', | ||
}; | ||
orgUserService.getEmployeesByParams(params).subscribe((res) => { | ||
expect(res).toEqual(employeesRes); | ||
expect(apiV2Service.get).toHaveBeenCalledWith('/spender_employees', { params }); | ||
expect(spenderPlatformV1ApiService.get).toHaveBeenCalledWith('/employees', { params }); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should be able to get employees by search with OR param', (done) => { | ||
const params = { | ||
order: 'us_full_name.asc,us_email.asc,ou_id', | ||
us_email: 'in.([email protected])', | ||
or: '(ou_status.like.*"ACTIVE",ou_status.like.*"PENDING_DETAILS")', | ||
and: '(or(ou_status.like.*"ACTIVE",ou_status.like.*"PENDING_DETAILS"),or(ou_status.like.*"ACTIVE",ou_status.like.*"PENDING_DETAILS"))', | ||
order: 'full_name.asc,email.asc', | ||
email: 'in.([email protected])', | ||
or: '(is_enabled.eq.true)', | ||
and: '(or(is_enabled.eq.true),or(is_enabled.eq.true))', | ||
}; | ||
apiV2Service.get.and.returnValue(of(employeesParamsRes)); | ||
spenderPlatformV1ApiService.get.and.returnValue(of(employeesParamsRes)); | ||
|
||
orgUserService.getEmployeesBySearch(params).subscribe((res) => { | ||
expect(res).toEqual(employeesParamsRes.data); | ||
expect(apiV2Service.get).toHaveBeenCalledWith('/spender_employees', { params }); | ||
expect(spenderPlatformV1ApiService.get).toHaveBeenCalledWith('/employees', { params }); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should be able to get employees by search without OR param', (done) => { | ||
const params = { | ||
order: 'us_full_name.asc,us_email.asc,ou_id', | ||
us_email: 'in.([email protected])', | ||
and: '(or(ou_status.like.*"ACTIVE",ou_status.like.*"PENDING_DETAILS"),or(ou_status.like.*"ACTIVE",ou_status.like.*"PENDING_DETAILS"))', | ||
order: 'full_name.asc,email.asc,id', | ||
email: 'in.([email protected])', | ||
and: '(or(is_enabled.eq.true),or(is_enabled.eq.true))', | ||
}; | ||
apiV2Service.get.and.returnValue(of(employeesParamsRes)); | ||
spenderPlatformV1ApiService.get.and.returnValue(of(employeesParamsRes)); | ||
|
||
orgUserService.getEmployeesBySearch(params).subscribe((res) => { | ||
expect(res).toEqual(employeesParamsRes.data); | ||
expect(apiV2Service.get).toHaveBeenCalledWith('/spender_employees', { params }); | ||
expect(spenderPlatformV1ApiService.get).toHaveBeenCalledWith('/employees', { params }); | ||
done(); | ||
}); | ||
}); | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
💡 Verification agent
🧩 Analysis chain
Model restructured with blockbuster impact!
Mind it! This is not just a minor change, this is a complete model transformation! The old prefixed properties (
ou_id
,ou_org_id
,ou_roles
,ou_status
,us_email
,us_full_name
,us_id
) have been replaced with cleaner, more direct properties.The new boolean properties
is_enabled
andhas_accepted_invite
provide better type safety than the previous string-based status. This change is as impactful as my slow-motion walk into a fight scene - powerful and purposeful!One concern though: verify that all references to this model throughout the application have been updated to match this new structure.
🏁 Script executed:
Length of output: 65924
Heads up, my friend—blockbuster transformation achieved, but some shadows of the old remain!
Your new Employee model is as powerful as a Rajini punch—with cleaner, direct properties and improved type safety. However, the grep shows that many parts of the codebase (especially in test-data, mock-data, and related models) still reference the old property names like
ou_id
,us_email
,us_full_name
, and so on. For example:src/app/core/mock-data/employee.data.ts
andsrc/app/core/test-data/status.service.spec.data.ts
still contain these old identifiers.Please update these references accordingly to harmonize the entire codebase with your new structure, or ensure a proper migration layer exists to handle the old keys safely.
Keep rocking like a superstar!