From 6c74f99d238ec3d35564f6d725d9754fc3bed4ca Mon Sep 17 00:00:00 2001 From: Mykyta Maliarchuk Date: Wed, 4 Dec 2024 13:49:04 +0100 Subject: [PATCH] [MNT-24657] cr fixes --- .../src/lib/form/widgets/people/people.widget.html | 2 +- .../src/lib/form/widgets/people/people.widget.spec.ts | 11 +++++++---- .../src/lib/form/widgets/people/people.widget.ts | 2 +- lib/process-services/src/lib/i18n/en.json | 3 ++- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/process-services/src/lib/form/widgets/people/people.widget.html b/lib/process-services/src/lib/form/widgets/people/people.widget.html index ae843b14526..e5e74474be3 100644 --- a/lib/process-services/src/lib/form/widgets/people/people.widget.html +++ b/lib/process-services/src/lib/form/widgets/people/people.widget.html @@ -4,7 +4,7 @@ id="people-widget-content"> - + { let translationService: TranslateService; let peopleProcessService: PeopleProcessService; + const getChipById = async (id: string) => + loader.getHarness(MatChipHarness.with({ selector: `[data-automation-id="adf-people-widget-chip-${id}"]` })); + beforeEach(() => { TestBed.configureTestingModule({ imports: [CoreTestingModule] @@ -90,7 +93,7 @@ describe('PeopleWidgetComponent', () => { fixture.detectChanges(); await fixture.whenStable(); - const chip = await loader.getHarness(MatChipHarness.with({ selector: '[data-automation-id="adf-people-widget-chip-people-id"]' })); + const chip = await getChipById('people-id'); expect(await chip.getText()).toBe('John Doe'); }); @@ -134,7 +137,7 @@ describe('PeopleWidgetComponent', () => { fixture.detectChanges(); await fixture.whenStable(); - const chip = await loader.getHarness(MatChipHarness.with({ selector: '[data-automation-id="adf-people-widget-chip-people-id"]' })); + const chip = await getChipById('people-id'); expect(await chip.getText()).toBe('John Doe'); expect(await chip.isDisabled()).toBe(true); expect((element.querySelector('input') as HTMLInputElement).disabled).toBeTruthy(); @@ -153,7 +156,7 @@ describe('PeopleWidgetComponent', () => { fixture.detectChanges(); await fixture.whenStable(); - const chip = await loader.getHarness(MatChipHarness.with({ selector: '[data-automation-id="adf-people-widget-chip-people-id"]' })); + const chip = await getChipById('people-id'); const cancelIcon = await chip.getRemoveButton(); expect(cancelIcon).toBeDefined(); }); @@ -194,7 +197,7 @@ describe('PeopleWidgetComponent', () => { fixture.detectChanges(); await fixture.whenStable(); - const chip = await loader.getHarness(MatChipHarness.with({ selector: '[data-automation-id="adf-people-widget-chip-people-id"]' })); + const chip = await getChipById('people-id'); expect(await chip.getText()).toBe('John Doe'); }); diff --git a/lib/process-services/src/lib/form/widgets/people/people.widget.ts b/lib/process-services/src/lib/form/widgets/people/people.widget.ts index d59f904f1ee..1d6e89720a8 100644 --- a/lib/process-services/src/lib/form/widgets/people/people.widget.ts +++ b/lib/process-services/src/lib/form/widgets/people/people.widget.ts @@ -168,7 +168,7 @@ export class PeopleWidgetComponent extends WidgetComponent implements OnInit { } isUserAlreadySelected(user: LightUserRepresentation): boolean { - if (this.selectedUsers && this.selectedUsers.length > 0) { + if (this.selectedUsers?.length > 0) { const result = this.selectedUsers.find((selectedUser) => selectedUser.id === user.id); return !!result; diff --git a/lib/process-services/src/lib/i18n/en.json b/lib/process-services/src/lib/i18n/en.json index c940fa89502..7c562095a97 100644 --- a/lib/process-services/src/lib/i18n/en.json +++ b/lib/process-services/src/lib/i18n/en.json @@ -281,7 +281,8 @@ "LABEL": { "SELECT_APPLICATION": "Select Application", "TYPE": "Select Process", - "NAME": "Process Name" + "NAME": "Process Name", + "SELECTED_PEOPLE": "Selected people" }, "TYPE_PLACEHOLDER": "Choose one...", "ACTION": {