AAE-21336 Display selected external property in preview state (#9475)

This commit is contained in:
Tomasz Gnyp
2024-03-26 11:29:23 +01:00
committed by GitHub
parent dbe33e9a58
commit 7cca017c12
4 changed files with 37 additions and 2 deletions

View File

@@ -22,6 +22,14 @@
[id]="field.id"
[formControl]="propertyControl"
>
<ng-container *ngIf="previewState">
<label class="adf-display-external-property-widget-preview"
data-automation-id="adf-display-external-property-widget-preview"
>
{{ field.externalProperty }}
</label>
</ng-container>
</mat-form-field>
<ng-container *ngIf="!previewState">

View File

@@ -5,5 +5,9 @@
.adf-label {
top: 20px;
}
&-preview {
color: var(--adf-display-external-property-widget-preview-selection-color);
}
}
}

View File

@@ -25,6 +25,7 @@ import { DisplayExternalPropertyWidgetComponent } from './display-external-prope
import { FormCloudService } from '../../../services/form-cloud.service';
import { TranslateModule } from '@ngx-translate/core';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { By } from '@angular/platform-browser';
describe('DisplayExternalPropertyWidgetComponent', () => {
let loader: HarnessLoader;
@@ -71,6 +72,20 @@ describe('DisplayExternalPropertyWidgetComponent', () => {
expect(await input.getValue()).toBe('banana');
});
it('should NOT display external property name in NO preview state', () => {
widget.field = new FormFieldModel(new FormModel({ taskId: '<id>' }), {
type: FormFieldTypes.DISPLAY_EXTERNAL_PROPERTY,
readOnly: true,
externalProperty: 'fruitName',
value: 'banana'
});
fixture.detectChanges();
const externalPropertyPreview = fixture.debugElement.query(By.css('[data-automation-id="adf-display-external-property-widget-preview"]'));
expect(externalPropertyPreview).toBeFalsy();
});
describe('when property load fails', () => {
beforeEach(() => {
widget.field = new FormFieldModel(new FormModel({ taskId: '<id>' }), {
@@ -96,7 +111,7 @@ describe('DisplayExternalPropertyWidgetComponent', () => {
beforeEach(() => {
widget.field = new FormFieldModel(new FormModel({ taskId: '<id>' }), {
type: FormFieldTypes.DISPLAY_EXTERNAL_PROPERTY,
externalProperty: true,
externalProperty: 'fruitName',
value: null
});
@@ -112,6 +127,11 @@ describe('DisplayExternalPropertyWidgetComponent', () => {
it('should NOT log the error', () => {
expect(logServiceSpy).not.toHaveBeenCalled();
});
it('should display external property name', () => {
const externalPropertyPreview = fixture.debugElement.query(By.css('[data-automation-id="adf-display-external-property-widget-preview"]'));
expect(externalPropertyPreview.nativeElement.textContent.trim()).toBe('fruitName');
});
});
describe('when is required', () => {