From f549a19fb929591f5fb4a9e1e529dbfb7a75e137 Mon Sep 17 00:00:00 2001 From: tomasz hanaj <12088991+tomaszhanaj@users.noreply.github.com> Date: Tue, 6 Jun 2023 10:41:13 +0200 Subject: [PATCH] [AAE-14469] added constraint for typed value (#8611) * [AAE-14469] added constraint for typed value * [AAE-14469] removed obsolete input property --- .../people/components/people-cloud.component.spec.ts | 6 ++++++ .../lib/people/components/people-cloud.component.ts | 11 ++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/process-services-cloud/src/lib/people/components/people-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/people/components/people-cloud.component.spec.ts index a7a74bb687..b2928ac81a 100644 --- a/lib/process-services-cloud/src/lib/people/components/people-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/people/components/people-cloud.component.spec.ts @@ -262,6 +262,12 @@ describe('PeopleCloudComponent', () => { const errorIcon = element.querySelector('.adf-error-icon').textContent; expect(errorIcon).toEqual('error_outline'); }); + + it('should not search user if typed no character', async () => { + await searchUsers(''); + + expect(searchSpy).not.toHaveBeenCalled(); + }); }); describe('No preselected users', () => { diff --git a/lib/process-services-cloud/src/lib/people/components/people-cloud.component.ts b/lib/process-services-cloud/src/lib/people/components/people-cloud.component.ts index e47eaab312..ee2826c70d 100644 --- a/lib/process-services-cloud/src/lib/people/components/people-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/people/components/people-cloud.component.ts @@ -164,7 +164,7 @@ export class PeopleCloudComponent implements OnInit, OnChanges, OnDestroy { constructor( @Inject(IDENTITY_USER_SERVICE_TOKEN) private identityUserService: IdentityUserServiceInterface, - private logService: LogService) {} + private logService: LogService) { } ngOnInit(): void { this.initSearch(); @@ -188,6 +188,7 @@ export class PeopleCloudComponent implements OnInit, OnChanges, OnDestroy { private initSearch(): void { this.initializeStream(); this.typingUniqueValueNotEmpty$.pipe( + filter((name: string) => name.length >= 1), switchMap((name: string) => this.identityUserService.search(name, { roles: this.roles, withinApplication: this.appName, groups: this.groupsRestriction }) ), @@ -378,8 +379,8 @@ export class PeopleCloudComponent implements OnInit, OnChanges, OnDestroy { private removeUserFromSelected({ id, username, email }: IdentityUserModel): void { const indexToRemove = this.selectedUsers.findIndex(user => user.id === id - && user.username === username - && user.email === email); + && user.username === username + && user.email === email); if (indexToRemove !== -1) { this.selectedUsers.splice(indexToRemove, 1); @@ -388,8 +389,8 @@ export class PeopleCloudComponent implements OnInit, OnChanges, OnDestroy { private removeUserFromValidation({ id, username, email }: IdentityUserModel): void { const indexToRemove = this.invalidUsers.findIndex(user => user.id === id - && user.username === username - && user.email === email); + && user.username === username + && user.email === email); if (indexToRemove !== -1) { this.invalidUsers.splice(indexToRemove, 1);