Skip to content

Commit

Permalink
AAE-20282 fix submit button enabled when required people/groups widge…
Browse files Browse the repository at this point in the history
…t empty (#9334)
  • Loading branch information
DudaRobert committed Feb 14, 2024
1 parent 2175b4b commit 1b3b419
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,23 @@ describe('GroupCloudWidgetComponent', () => {

expect(element.querySelector('.adf-invalid')).toBeTruthy();
});

it('should be invalid after deselecting all groups', async () => {
widget.onChangedGroup([{id: 'test-id', name: 'test-name'}]);
fixture.detectChanges();
await fixture.whenStable();

expect(element.querySelector('.adf-error-text')).toBeFalsy();

const removeGroupIcon = element.querySelector('[data-automation-id="adf-cloud-group-chip-remove-icon-test-name"]');
removeGroupIcon.dispatchEvent(new Event('click'));

fixture.detectChanges();
await fixture.whenStable();

expect(element.querySelector('.adf-error-text')).toBeTruthy();
expect(element.querySelector('.adf-error-text').textContent).toContain('ADF_CLOUD_GROUPS.ERROR.NOT_FOUND');
});
});

describe('when is readOnly', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ export class GroupCloudWidgetComponent extends WidgetComponent implements OnInit
});
}

ngOnDestroy() {
ngOnDestroy(): void {
this.onDestroy$.next(true);
this.onDestroy$.complete();
}

onChangedGroup(groups) {
this.field.value = [...groups];
onChangedGroup(groups: IdentityGroupModel[]): void {
this.field.value = groups?.length ? [...groups] : null;
this.onFieldChanged(this.field);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,23 @@ describe('PeopleCloudWidgetComponent', () => {

expect(element.querySelector('.adf-invalid')).toBeTruthy();
});

it('should be invalid after deselecting all people', async () => {
widget.onChangedUser([{id: 'test-id', username: 'test-name'}]);
fixture.detectChanges();
await fixture.whenStable();

expect(element.querySelector('.adf-error-text')).toBeFalsy();

const removeGroupIcon = element.querySelector('[data-automation-id="adf-people-cloud-chip-remove-icon-test-name"]');
removeGroupIcon.dispatchEvent(new Event('click'));

fixture.detectChanges();
await fixture.whenStable();

expect(element.querySelector('.adf-error-text')).toBeTruthy();
expect(element.querySelector('.adf-error-text').textContent).toContain('ADF_CLOUD_USERS.ERROR.NOT_FOUND');
});
});

describe('when is readOnly', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ export class PeopleCloudWidgetComponent extends WidgetComponent implements OnIni
}
}

ngOnDestroy() {
ngOnDestroy(): void {
this.onDestroy$.next(true);
this.onDestroy$.complete();
}

onChangedUser(users) {
this.field.value = [...users];
onChangedUser(users: IdentityUserModel[]): void {
this.field.value = users?.length ? [...users] : null;
this.onFieldChanged(this.field);
}

Expand Down

0 comments on commit 1b3b419

Please sign in to comment.