-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #461 from hmcts/bug/exui-1889
EXUI-1889 - Add current user to find person
- Loading branch information
Showing
4 changed files
with
73 additions
and
3 deletions.
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
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,6 +1,7 @@ | ||
import { of } from 'rxjs'; | ||
import { Person, PersonRole, RoleCategory } from '../../models/person.model'; | ||
import { FindAPersonService } from './find-person.service'; | ||
import { Caseworker } from 'exui-common-lib'; | ||
|
||
describe('FindAPersonService', () => { | ||
it('should be Truthy', () => { | ||
|
@@ -167,4 +168,73 @@ describe('FindAPersonService', () => { | |
expect(service.mapCaseworkers(caseworkers, RoleCategory.CASEWORKER)).toEqual(people.slice(0, 3)); | ||
expect(service.mapCaseworkers(caseworkers, RoleCategory.ADMIN)).toEqual(people.slice(3, 4)); | ||
}); | ||
|
||
it('should not filter out current user ', () => { | ||
const caseworkers: Caseworker[] = [ | ||
{ | ||
idamId: '123', | ||
firstName: 'Test', | ||
lastName: 'One', | ||
email: '[email protected]', | ||
roleCategory: 'LEGAL_OPERATIONS' | ||
}, | ||
{ | ||
idamId: '124', | ||
firstName: 'Test', | ||
lastName: 'Two', | ||
email: '[email protected]', | ||
roleCategory: 'LEGAL_OPERATIONS' | ||
}, | ||
{ | ||
idamId: '125', | ||
firstName: 'Test', | ||
lastName: 'Three', | ||
email: '[email protected]', | ||
roleCategory: 'CTSC' | ||
}, | ||
{ | ||
idamId: '126', | ||
firstName: 'Test', | ||
lastName: 'Four', | ||
email: '[email protected]', | ||
roleCategory: 'ADMIN' | ||
} | ||
]; | ||
const mockHttpService = jasmine.createSpyObj('mockHttpService', ['put', 'get', 'post']); | ||
mockHttpService.post.and.returnValue(of()); | ||
const mockSessionStorageService = jasmine.createSpyObj('mockSessionStorageService', ['setItem', 'getItem']); | ||
mockSessionStorageService.getItem.and.returnValues(JSON.stringify(userDetails), undefined, caseworkers); | ||
const service = new FindAPersonService(mockHttpService, mockSessionStorageService); | ||
service.userId = '126'; | ||
|
||
let searchOptions = { searchTerm: 'four', services: ['IA'], userRole: PersonRole.CASEWORKER }; | ||
const filteredUsersSpecificName = service.searchInCaseworkers(caseworkers, searchOptions); | ||
expect(filteredUsersSpecificName).toEqual([ | ||
{ id: '126', name: 'Test Four', email: '[email protected]', domain: 'Admin' } | ||
]); | ||
|
||
searchOptions = { searchTerm: 'test', services: ['IA'], userRole: PersonRole.CASEWORKER }; | ||
const filteredUsersCaseWorker = service.searchInCaseworkers(caseworkers, searchOptions); | ||
expect(filteredUsersCaseWorker).toHaveSize(3); | ||
expect(filteredUsersCaseWorker).toEqual([ | ||
{ email: '[email protected]', name: 'Test One', id: '123', domain: 'Legal Ops' }, | ||
{ email: '[email protected]', name: 'Test Two', id: '124', domain: 'Legal Ops' }, | ||
{ email: '[email protected]', name: 'Test Four', id: '126', domain: 'Admin' } | ||
]); | ||
|
||
searchOptions = { searchTerm: 'test', services: ['IA'], userRole: PersonRole.CTSC }; | ||
const filteredUsersCTSC = service.searchInCaseworkers(caseworkers, searchOptions); | ||
expect(filteredUsersCTSC).toHaveSize(2); | ||
expect(filteredUsersCTSC).toEqual([ | ||
{ email: '[email protected]', name: 'Test Three', id: '125', domain: 'Admin' }, | ||
{ email: '[email protected]', name: 'Test Four', id: '126', domain: 'Admin' } | ||
]); | ||
|
||
searchOptions = { searchTerm: 'test', services: ['IA'], userRole: PersonRole.ADMIN }; | ||
const filteredUsersAdmin = service.searchInCaseworkers(caseworkers, searchOptions); | ||
expect(filteredUsersAdmin).toHaveSize(1); | ||
expect(filteredUsersAdmin).toEqual([ | ||
{ email: '[email protected]', name: 'Test Four', id: '126', domain: 'Admin' } | ||
]); | ||
}); | ||
}); |
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