Skip to content
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

AAE-23830 Label for people component #10064

Merged
merged 2 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<adf-cloud-people
[preSelectUsers]="preSelectUsers"
[appName]="appName"
[title]="title"
[readOnly]="field.readOnly"
[validate]="validate"
[searchUserCtrl]="search"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
class="adf-people-cloud"
[class.adf-invalid]="hasError() && isDirty()"
>
<ng-content select="[label]"></ng-content>
<ng-content *ngIf="!title" select="[label]"></ng-content>
<mat-label *ngIf="title">{{ title | translate }}</mat-label>
<mat-chip-grid #userMultipleChipList [disabled]="isReadonly() || isValidationLoading()" data-automation-id="adf-cloud-people-chip-list">
<mat-chip-row
*ngFor="let user of selectedUsers"
Expand All @@ -27,7 +28,6 @@
[formControl]="searchUserCtrl"
[matAutocomplete]="auto"
[matChipInputFor]="userMultipleChipList"
[placeholder]="title | translate"
[required]="required"
(focus)="setFocus(true)"
(blur)="setFocus(false); markAsTouched()"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { HarnessLoader } from '@angular/cdk/testing';
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
import { MatChipGridHarness, MatChipHarness } from '@angular/material/chips/testing';
import { MatInputHarness } from '@angular/material/input/testing';
import { MatFormFieldHarness } from '@angular/material/form-field/testing';

describe('PeopleCloudComponent', () => {
let loader: HarnessLoader;
Expand Down Expand Up @@ -92,21 +93,21 @@ describe('PeopleCloudComponent', () => {
loader = TestbedHarnessEnvironment.loader(fixture);
});

it('should populate placeholder when title is present', () => {
it('should populate label when title is present', async () => {
component.title = 'TITLE_KEY';
fixture.detectChanges();

const inputElement = element.querySelector<HTMLInputElement>('[data-automation-id="adf-people-cloud-search-input"]');
const inputField = await loader.getHarness(MatFormFieldHarness.with({ selector: '.adf-people-cloud' }));

expect(inputElement.placeholder).toEqual('TITLE_KEY');
expect(await inputField.getLabel()).toEqual('TITLE_KEY');
});

it('should not populate placeholder when title is not present', () => {
it('should not populate label when title is not present', async () => {
fixture.detectChanges();

const inputElement = element.querySelector<HTMLInputElement>('[data-automation-id="adf-people-cloud-search-input"]');
const inputField = await loader.getHarness(MatFormFieldHarness.with({ selector: '.adf-people-cloud' }));

expect(inputElement.placeholder).toEqual('');
expect(await inputField.getLabel()).toBeNull();
});

describe('Search user', () => {
Expand Down
Loading