mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
[ACCS-5551] unit test added
This commit is contained in:
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
<label class="adf-property-label"
|
<label class="adf-property-label"
|
||||||
[attr.data-automation-id]="'card-dateitem-label-' + property.key"
|
[attr.data-automation-id]="'card-dateitem-label-' + property.key"
|
||||||
[ngClass]="{'adf-property-label-not-editable' : nonEditableField}"
|
[ngClass]="{'adf-property-label-not-editable' : isNonEditableField}"
|
||||||
*ngIf="showProperty() || isEditable()"
|
*ngIf="showProperty() || isEditable()"
|
||||||
[attr.for]="'card-view-dateitem-' + property.key">
|
[attr.for]="'card-view-dateitem-' + property.key">
|
||||||
{{ property.label | translate }}
|
{{ property.label | translate }}
|
||||||
</label>
|
</label>
|
||||||
<div class="adf-property-value adf-property-value-padding-top"
|
<div class="adf-property-value adf-property-value-padding-top"
|
||||||
[ngClass]="{'adf-property-dateitem-edit-mode' : editable, 'adf-property-label-not-editable' : nonEditableField}">
|
[ngClass]="{'adf-property-dateitem-edit-mode' : editable, 'adf-property-label-not-editable' : isNonEditableField}">
|
||||||
<span *ngIf="!isEditable() && !property.multivalued"
|
<span *ngIf="!isEditable() && !property.multivalued"
|
||||||
[attr.data-automation-id]="'card-' + property.type + '-value-' + property.key">
|
[attr.data-automation-id]="'card-' + property.type + '-value-' + property.key">
|
||||||
<span *ngIf="showProperty()"
|
<span *ngIf="showProperty()"
|
||||||
|
|||||||
+39
@@ -232,6 +232,45 @@ describe('CardViewDateItemComponent', () => {
|
|||||||
expect(clipboardService.copyContentToClipboard).toHaveBeenCalledWith('Jul 10, 2017', 'CORE.METADATA.ACCESSIBILITY.COPY_TO_CLIPBOARD_MESSAGE');
|
expect(clipboardService.copyContentToClipboard).toHaveBeenCalledWith('Jul 10, 2017', 'CORE.METADATA.ACCESSIBILITY.COPY_TO_CLIPBOARD_MESSAGE');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not show divider when editable is true', () => {
|
||||||
|
component.editable = true;
|
||||||
|
spyOn(component, 'showProperty').and.returnValue(true); // Mock showProperty result
|
||||||
|
const result = component.showDivider;
|
||||||
|
expect(result).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not show divider when showProperty returns false', () => {
|
||||||
|
component.editable = false;
|
||||||
|
spyOn(component, 'showProperty').and.returnValue(false);
|
||||||
|
const result = component.showDivider;
|
||||||
|
expect(result).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should show divider when editable is false', () => {
|
||||||
|
component.editable = false;
|
||||||
|
spyOn(component, 'showProperty').and.returnValue(true);
|
||||||
|
const result = component.showDivider;
|
||||||
|
expect(result).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return true for isNonEditableField when editable is true and property.editable is false', () => {
|
||||||
|
component.editable = true;
|
||||||
|
component.property.editable = false;
|
||||||
|
|
||||||
|
const result = component.isNonEditableField;
|
||||||
|
|
||||||
|
expect(result).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return false for isNonEditableField when editable is false and property.editable is true', () => {
|
||||||
|
component.editable = false;
|
||||||
|
component.property.editable = true;
|
||||||
|
|
||||||
|
const result = component.isNonEditableField;
|
||||||
|
|
||||||
|
expect(result).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
describe('clear icon', () => {
|
describe('clear icon', () => {
|
||||||
it('should render the clear icon in case of displayClearAction:true', () => {
|
it('should render the clear icon in case of displayClearAction:true', () => {
|
||||||
component.editable = true;
|
component.editable = true;
|
||||||
|
|||||||
+1
-1
@@ -159,7 +159,7 @@ export class CardViewDateItemComponent extends BaseCardView<CardViewDateItemMode
|
|||||||
return !this.editable && this.showProperty();
|
return !this.editable && this.showProperty();
|
||||||
}
|
}
|
||||||
|
|
||||||
get nonEditableField(): boolean {
|
get isNonEditableField(): boolean {
|
||||||
return this.editable && !this.property.editable;
|
return this.editable && !this.property.editable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -2,7 +2,7 @@
|
|||||||
<div
|
<div
|
||||||
[attr.data-automation-id]="'card-select-label-' + property.key"
|
[attr.data-automation-id]="'card-select-label-' + property.key"
|
||||||
class="adf-property-label"
|
class="adf-property-label"
|
||||||
[ngClass]="{'adf-property-label-not-editable' : nonEditableField}"
|
[ngClass]="{'adf-property-label-not-editable' : isNonEditableField}"
|
||||||
>{{ property.label | translate }}</div>
|
>{{ property.label | translate }}</div>
|
||||||
<div class="adf-property-field">
|
<div class="adf-property-field">
|
||||||
<div
|
<div
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
<mat-select
|
<mat-select
|
||||||
[(value)]="value"
|
[(value)]="value"
|
||||||
panelClass="adf-select-filter"
|
panelClass="adf-select-filter"
|
||||||
[ngClass]="{'adf-property-select-edit-mode' : isEditable(),'adf-property-normal-mode':!isEditable(),'adf-property-label-not-editable' : nonEditableField}"
|
[ngClass]="{'adf-property-select-edit-mode' : isEditable(),'adf-property-normal-mode':!isEditable(),'adf-property-label-not-editable' : isNonEditableField}"
|
||||||
(selectionChange)="onChange($event)"
|
(selectionChange)="onChange($event)"
|
||||||
data-automation-class="select-box"
|
data-automation-class="select-box"
|
||||||
[aria-label]="property.label | translate"
|
[aria-label]="property.label | translate"
|
||||||
|
|||||||
+18
@@ -251,4 +251,22 @@ describe('CardViewSelectItemComponent', () => {
|
|||||||
expect(filterInput).not.toBe(null);
|
expect(filterInput).not.toBe(null);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return true for isNonEditableField when editable is true and property.editable is false', () => {
|
||||||
|
component.editable = true;
|
||||||
|
component.property.editable = false;
|
||||||
|
|
||||||
|
const result = component.isNonEditableField;
|
||||||
|
|
||||||
|
expect(result).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return false for isNonEditableField when editable is false and property.editable is true', () => {
|
||||||
|
component.editable = false;
|
||||||
|
component.property.editable = true;
|
||||||
|
|
||||||
|
const result = component.isNonEditableField;
|
||||||
|
|
||||||
|
expect(result).toBe(false);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
+1
-1
@@ -110,7 +110,7 @@ export class CardViewSelectItemComponent extends BaseCardView<CardViewSelectItem
|
|||||||
return this.appConfig.get<number>('content-metadata.selectFilterLimit', CardViewSelectItemComponent.HIDE_FILTER_LIMIT);
|
return this.appConfig.get<number>('content-metadata.selectFilterLimit', CardViewSelectItemComponent.HIDE_FILTER_LIMIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
get nonEditableField(): boolean {
|
get isNonEditableField(): boolean {
|
||||||
return this.editable && !this.property.editable;
|
return this.editable && !this.property.editable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-7
@@ -5,13 +5,13 @@
|
|||||||
[floatLabel]="'always'"
|
[floatLabel]="'always'"
|
||||||
appearance="standard">
|
appearance="standard">
|
||||||
<mat-label *ngIf="showProperty || isEditable" [attr.data-automation-id]="'card-textitem-label-' + property.key" class="adf-property-label"
|
<mat-label *ngIf="showProperty || isEditable" [attr.data-automation-id]="'card-textitem-label-' + property.key" class="adf-property-label"
|
||||||
[ngClass]="{'adf-property-label-not-editable' : nonEditableField}">
|
[ngClass]="{'adf-property-label-not-editable' : isNonEditableField}">
|
||||||
{{ property.label | translate }}
|
{{ property.label | translate }}
|
||||||
</mat-label>
|
</mat-label>
|
||||||
<input matInput
|
<input matInput
|
||||||
*ngIf="!property.multiline"
|
*ngIf="!property.multiline"
|
||||||
class="adf-property-value"
|
class="adf-property-value"
|
||||||
[ngClass]="{'adf-property-edit-mode' : editable,'adf-property-normal-mode':!editable, 'adf-property-label-not-editable' : nonEditableField}"
|
[ngClass]="{'adf-property-edit-mode' : editable,'adf-property-normal-mode':!editable, 'adf-property-label-not-editable' : isNonEditableField}"
|
||||||
title="{{property.label | translate }}"
|
title="{{property.label | translate }}"
|
||||||
[placeholder]="property.default"
|
[placeholder]="property.default"
|
||||||
[attr.aria-label]="property.label | translate"
|
[attr.aria-label]="property.label | translate"
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
[cdkAutosizeMaxRows]="1"
|
[cdkAutosizeMaxRows]="1"
|
||||||
[cdkAutosizeMaxRows]="5"
|
[cdkAutosizeMaxRows]="5"
|
||||||
class="adf-property-value"
|
class="adf-property-value"
|
||||||
[ngClass]="{'adf-property-edit-mode' : editable,'adf-property-normal-mode':!editable, 'adf-property-label-not-editable' : nonEditableField}"
|
[ngClass]="{'adf-property-edit-mode' : editable,'adf-property-normal-mode':!editable, 'adf-property-label-not-editable' : isNonEditableField}"
|
||||||
[placeholder]="property.default"
|
[placeholder]="property.default"
|
||||||
[attr.aria-label]="property.label | translate"
|
[attr.aria-label]="property.label | translate"
|
||||||
[formControl]="textInput"
|
[formControl]="textInput"
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
<div *ngSwitchCase="'chipsTemplate'"
|
<div *ngSwitchCase="'chipsTemplate'"
|
||||||
class="adf-property-field adf-textitem-chip-list-container">
|
class="adf-property-field adf-textitem-chip-list-container">
|
||||||
<mat-label *ngIf="showLabelForChips" [attr.data-automation-id]="'card-textitem-label-' + property.key" class="adf-property-label"
|
<mat-label *ngIf="showLabelForChips" [attr.data-automation-id]="'card-textitem-label-' + property.key" class="adf-property-label"
|
||||||
[ngClass]="{'adf-property-label-not-editable' : nonEditableField}">
|
[ngClass]="{'adf-property-label-not-editable' : isNonEditableField}">
|
||||||
{{ property.label | translate }}
|
{{ property.label | translate }}
|
||||||
</mat-label>
|
</mat-label>
|
||||||
<mat-chip-list #chipList
|
<mat-chip-list #chipList
|
||||||
@@ -63,7 +63,7 @@
|
|||||||
[floatLabel]="'never'">
|
[floatLabel]="'never'">
|
||||||
<input matInput
|
<input matInput
|
||||||
class="adf-property-value"
|
class="adf-property-value"
|
||||||
[ngClass]="{'adf-property-edit-mode' : editable,'adf-property-normal-mode':!editable, 'adf-property-label-not-editable' : nonEditableField}"
|
[ngClass]="{'adf-property-edit-mode' : editable,'adf-property-normal-mode':!editable, 'adf-property-label-not-editable' : isNonEditableField}"
|
||||||
title="{{property.label | translate }}"
|
title="{{property.label | translate }}"
|
||||||
[placeholder]="editedValue ? '' : property.default | translate"
|
[placeholder]="editedValue ? '' : property.default | translate"
|
||||||
[attr.aria-label]="property.label | translate"
|
[attr.aria-label]="property.label | translate"
|
||||||
@@ -84,14 +84,14 @@
|
|||||||
<mat-form-field class="adf-property-field adf-card-textitem-field" appearance="standard"
|
<mat-form-field class="adf-property-field adf-card-textitem-field" appearance="standard"
|
||||||
[floatLabel]="'never'">
|
[floatLabel]="'never'">
|
||||||
<mat-label *ngIf="showProperty || isEditable" [attr.data-automation-id]="'card-textitem-label-' + property.key" class="adf-property-label"
|
<mat-label *ngIf="showProperty || isEditable" [attr.data-automation-id]="'card-textitem-label-' + property.key" class="adf-property-label"
|
||||||
[ngClass]="{'adf-property-label-not-editable' : nonEditableField}">
|
[ngClass]="{'adf-property-label-not-editable' : isNonEditableField}">
|
||||||
{{ property.label | translate }}
|
{{ property.label | translate }}
|
||||||
</mat-label>
|
</mat-label>
|
||||||
<input matInput
|
<input matInput
|
||||||
[type]=property.inputType
|
[type]=property.inputType
|
||||||
class="adf-property-value"
|
class="adf-property-value"
|
||||||
title="{{property.label | translate }}"
|
title="{{property.label | translate }}"
|
||||||
[ngClass]="{'adf-textitem-clickable-value': !isEditable,'adf-property-edit-mode' : editable,'adf-property-normal-mode':!editable, 'adf-property-label-not-editable' : nonEditableField}"
|
[ngClass]="{'adf-textitem-clickable-value': !isEditable,'adf-property-edit-mode' : editable,'adf-property-normal-mode':!editable, 'adf-property-label-not-editable' : isNonEditableField}"
|
||||||
[placeholder]="property.default"
|
[placeholder]="property.default"
|
||||||
[attr.aria-label]="property.label | translate"
|
[attr.aria-label]="property.label | translate"
|
||||||
[(ngModel)]="editedValue"
|
[(ngModel)]="editedValue"
|
||||||
|
|||||||
+45
@@ -296,6 +296,51 @@ describe('CardViewTextItemComponent', () => {
|
|||||||
const labelElement = fixture.debugElement.query(By.css(`.adf-property-label`));
|
const labelElement = fixture.debugElement.query(By.css(`.adf-property-label`));
|
||||||
expect(labelElement).toBeNull();
|
expect(labelElement).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not show divider when editable is true', () => {
|
||||||
|
component.editable = true;
|
||||||
|
spyOnProperty(component, 'showProperty', 'get').and.returnValue(true);
|
||||||
|
|
||||||
|
const result = component.showDivider;
|
||||||
|
|
||||||
|
expect(result).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not show divider when showProperty returns false', () => {
|
||||||
|
component.editable = false;
|
||||||
|
spyOnProperty(component, 'showProperty', 'get').and.returnValue(false);
|
||||||
|
|
||||||
|
const result = component.showDivider;
|
||||||
|
|
||||||
|
expect(result).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should show divider when editable is false', () => {
|
||||||
|
component.editable = false;
|
||||||
|
spyOnProperty(component, 'showProperty', 'get').and.returnValue(true);
|
||||||
|
|
||||||
|
const result = component.showDivider;
|
||||||
|
|
||||||
|
expect(result).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return true for isNonEditableField when editable is true and property.editable is false', () => {
|
||||||
|
component.editable = true;
|
||||||
|
component.property.editable = false;
|
||||||
|
|
||||||
|
const result = component.isNonEditableField;
|
||||||
|
|
||||||
|
expect(result).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return false for isNonEditableField when editable is false and property.editable is true', () => {
|
||||||
|
component.editable = false;
|
||||||
|
component.property.editable = true;
|
||||||
|
|
||||||
|
const result = component.isNonEditableField;
|
||||||
|
|
||||||
|
expect(result).toBe(false);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('clickable', () => {
|
describe('clickable', () => {
|
||||||
|
|||||||
+1
-1
@@ -237,7 +237,7 @@ export class CardViewTextItemComponent extends BaseCardView<CardViewTextItemMode
|
|||||||
return !this.editable && this.showProperty;
|
return !this.editable && this.showProperty;
|
||||||
}
|
}
|
||||||
|
|
||||||
get nonEditableField(): boolean {
|
get isNonEditableField(): boolean {
|
||||||
return this.editable && !this.property.editable;
|
return this.editable && !this.property.editable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ describe('Custom InfoDrawer', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should render a icon with title', () => {
|
it('should render a icon with title', () => {
|
||||||
component.nodeIcon = "/assets/images/ft_ic_miscellaneous.svg";
|
component.nodeIcon = '/assets/images/ft_ic_miscellaneous.svg';
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
const icon = fixture.debugElement.queryAll(By.css('[info-drawer-node-icon]'));
|
const icon = fixture.debugElement.queryAll(By.css('[info-drawer-node-icon]'));
|
||||||
const srcAttribute = icon[0].nativeElement.getAttribute('src');
|
const srcAttribute = icon[0].nativeElement.getAttribute('src');
|
||||||
@@ -200,7 +200,7 @@ describe('Header visibility InfoDrawer', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should show info drawer header by default', () => {
|
it('should show info drawer header by default', () => {
|
||||||
component.nodeIcon = "/assets/images/ft_ic_miscellaneous.svg";
|
component.nodeIcon = '/assets/images/ft_ic_miscellaneous.svg';
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
const title: any = fixture.debugElement.queryAll(By.css('[info-drawer-title]'));
|
const title: any = fixture.debugElement.queryAll(By.css('[info-drawer-title]'));
|
||||||
const icon = fixture.debugElement.queryAll(By.css('[info-drawer-node-icon]'));
|
const icon = fixture.debugElement.queryAll(By.css('[info-drawer-node-icon]'));
|
||||||
|
|||||||
Reference in New Issue
Block a user