Skip to content

Commit

Permalink
[MNT-24657] cr fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nikita-web-ua committed Dec 4, 2024
1 parent 52f19aa commit 6c74f99
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
id="people-widget-content">
<mat-form-field>
<label class="adf-label" [attr.for]="field.id">{{field.name | translate }}<span class="adf-asterisk" *ngIf="isRequired()">*</span></label>
<mat-chip-grid #chipGrid aria-label="People selection" data-automation-id="adf-people-widget-chip-list">
<mat-chip-grid #chipGrid [attr.aria-label]="'ADF_PROCESS_LIST.START_PROCESS.FORM.LABEL.SELECTED_PEOPLE' | translate">
<mat-chip-row
*ngFor="let user of selectedUsers"
(removed)="onRemove(user)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ describe('PeopleWidgetComponent', () => {
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]
Expand Down Expand Up @@ -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');
});

Expand Down Expand Up @@ -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();
Expand All @@ -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();
});
Expand Down Expand Up @@ -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');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion lib/process-services/src/lib/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down

0 comments on commit 6c74f99

Please sign in to comment.