mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
[AAE-9314] Fix preselected user display in completed task (#7688)
* [AAE-9314] Fix preselected user display in completed task * [AAE-9314] add unit tests * Trigger travis
This commit is contained in:
parent
e529d3bd74
commit
93c5619e23
@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { FormFieldModel, FormFieldTypes, FormModel, setupTestBed } from '@alfresco/adf-core';
|
||||
import { FormFieldModel, FormFieldTypes, FormModel, IdentityGroupModel, setupTestBed } from '@alfresco/adf-core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { GroupCloudWidgetComponent } from './group-cloud.widget';
|
||||
import { ProcessServiceCloudTestingModule } from '../../../../testing/process-service-cloud.testing.module';
|
||||
@ -65,7 +65,7 @@ describe('GroupCloudWidgetComponent', () => {
|
||||
expect(asterisk.textContent).toEqual('*');
|
||||
});
|
||||
|
||||
it('should be invalid if no default option after interaction', async () => {
|
||||
it('should be invalid if no option is selected after interaction', async () => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
@ -81,6 +81,58 @@ describe('GroupCloudWidgetComponent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('when is readOnly', () => {
|
||||
|
||||
it('should single chip be disabled', async () => {
|
||||
const mockSpaghetti: IdentityGroupModel[] = [{
|
||||
id: 'bolognese',
|
||||
name: 'Bolognese'
|
||||
}];
|
||||
|
||||
widget.field = new FormFieldModel( new FormModel({ taskId: '<id>'}, null, true), {
|
||||
type: FormFieldTypes.GROUP,
|
||||
value: mockSpaghetti
|
||||
});
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const disabledFormField: HTMLElement = element.querySelector('.mat-form-field-disabled');
|
||||
expect(disabledFormField).toBeTruthy();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const disabledGroupChip: HTMLElement = element.querySelector('.mat-chip-disabled');
|
||||
expect(disabledGroupChip).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should multi chips be disabled', async () => {
|
||||
const mockSpaghetti: IdentityGroupModel[] = [
|
||||
{ id: 'bolognese', name: 'Bolognese' },
|
||||
{ id: 'carbonara', name: 'Carbonara' }
|
||||
];
|
||||
|
||||
widget.field = new FormFieldModel( new FormModel({ taskId: '<id>'}, null, true), {
|
||||
type: FormFieldTypes.GROUP,
|
||||
value: mockSpaghetti
|
||||
});
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const disabledFormField: HTMLElement = element.querySelector('.mat-form-field-disabled');
|
||||
expect(disabledFormField).toBeTruthy();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const disabledGroupChips = element.querySelectorAll('.mat-chip-disabled');
|
||||
expect(disabledGroupChips.item(0)).toBeTruthy();
|
||||
expect(disabledGroupChips.item(1)).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('when form model has left labels', () => {
|
||||
|
||||
it('should have left labels classes on leftLabels true', async () => {
|
||||
|
@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { FormFieldModel, FormFieldTypes, FormModel, IdentityUserService, setupTestBed } from '@alfresco/adf-core';
|
||||
import { FormFieldModel, FormFieldTypes, FormModel, IdentityUserModel, IdentityUserService, setupTestBed } from '@alfresco/adf-core';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { PeopleCloudWidgetComponent } from './people-cloud.widget';
|
||||
@ -84,7 +84,7 @@ describe('PeopleCloudWidgetComponent', () => {
|
||||
expect(asterisk.textContent).toEqual('*');
|
||||
});
|
||||
|
||||
it('should be invalid if no default option after interaction', async () => {
|
||||
it('should be invalid if no option is selected after interaction', async () => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
@ -100,6 +100,59 @@ describe('PeopleCloudWidgetComponent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('when is readOnly', () => {
|
||||
|
||||
it('should single chip be disabled', async () => {
|
||||
const mockSpaghetti: IdentityUserModel[] = [{
|
||||
id: 'bolognese',
|
||||
username: 'Bolognese',
|
||||
email: 'bolognese@example.com'
|
||||
}];
|
||||
|
||||
widget.field = new FormFieldModel( new FormModel({ taskId: '<id>'}, null, true), {
|
||||
type: FormFieldTypes.GROUP,
|
||||
value: mockSpaghetti
|
||||
});
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const disabledFormField: HTMLElement = element.querySelector('.mat-form-field-disabled');
|
||||
expect(disabledFormField).toBeTruthy();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const disabledGroupChip: HTMLElement = element.querySelector('.mat-chip-disabled');
|
||||
expect(disabledGroupChip).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should multi chips be disabled', async () => {
|
||||
const mockSpaghetti: IdentityUserModel[] = [
|
||||
{ id: 'bolognese', username: 'Bolognese', email: 'bolognese@example.com' },
|
||||
{ id: 'carbonara', username: 'Carbonara', email: 'carbonara@example.com' }
|
||||
];
|
||||
|
||||
widget.field = new FormFieldModel( new FormModel({ taskId: '<id>'}, null, true), {
|
||||
type: FormFieldTypes.GROUP,
|
||||
value: mockSpaghetti
|
||||
});
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const disabledFormField: HTMLElement = element.querySelector('.mat-form-field-disabled');
|
||||
expect(disabledFormField).toBeTruthy();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const disabledGroupChips = element.querySelectorAll('.mat-chip-disabled');
|
||||
expect(disabledGroupChips.item(0)).toBeTruthy();
|
||||
expect(disabledGroupChips.item(1)).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('when form model has left labels', () => {
|
||||
|
||||
it('should have left labels classes on leftLabels true', async () => {
|
||||
|
@ -27,7 +27,6 @@ import {
|
||||
SimpleChanges,
|
||||
OnChanges,
|
||||
OnDestroy,
|
||||
ChangeDetectionStrategy,
|
||||
SimpleChange
|
||||
} from '@angular/core';
|
||||
import { FormControl } from '@angular/forms';
|
||||
@ -50,7 +49,6 @@ import { ComponentSelectionMode } from '../../types';
|
||||
])
|
||||
])
|
||||
],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class GroupCloudComponent implements OnInit, OnChanges, OnDestroy {
|
||||
|
@ -26,7 +26,6 @@ import {
|
||||
SimpleChanges,
|
||||
OnChanges,
|
||||
OnDestroy,
|
||||
ChangeDetectionStrategy,
|
||||
ViewChild, ElementRef, SimpleChange
|
||||
} from '@angular/core';
|
||||
import { Observable, of, BehaviorSubject, Subject } from 'rxjs';
|
||||
@ -54,7 +53,6 @@ import { ComponentSelectionMode } from '../../types';
|
||||
])
|
||||
],
|
||||
providers: [FullNamePipe],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user