mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-12 17:04:46 +00:00
[ACA-4633] Fix error script dropdown sometimes not having a label (#2899)
This commit is contained in:
parent
2397c816cf
commit
b4503c1de9
@ -7,7 +7,11 @@
|
|||||||
{{ 'ACA_FOLDER_RULES.RULE_DETAILS.OPTIONS.IS_ASYNCHRONOUS' | translate }}
|
{{ 'ACA_FOLDER_RULES.RULE_DETAILS.OPTIONS.IS_ASYNCHRONOUS' | translate }}
|
||||||
</mat-checkbox>
|
</mat-checkbox>
|
||||||
|
|
||||||
<mat-form-field [ngClass]="{ 'hide-error-script-dropdown': hideErrorScriptDropdown }">
|
<mat-form-field
|
||||||
|
data-automation-id="rule-option-form-field-errorScript"
|
||||||
|
floatLabel="always"
|
||||||
|
[ngClass]="{ 'hide-error-script-dropdown': hideErrorScriptDropdown }">
|
||||||
|
|
||||||
<mat-select
|
<mat-select
|
||||||
formControlName="errorScript"
|
formControlName="errorScript"
|
||||||
placeholder="{{ 'ACA_FOLDER_RULES.RULE_DETAILS.OPTIONS.ERROR_SCRIPT' | translate}}"
|
placeholder="{{ 'ACA_FOLDER_RULES.RULE_DETAILS.OPTIONS.ERROR_SCRIPT' | translate}}"
|
||||||
@ -23,6 +27,7 @@
|
|||||||
</ng-template>
|
</ng-template>
|
||||||
|
|
||||||
</mat-select>
|
</mat-select>
|
||||||
|
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ import { RuleOptionsUiComponent } from './rule-options.ui-component';
|
|||||||
import { CoreTestingModule } from '@alfresco/adf-core';
|
import { CoreTestingModule } from '@alfresco/adf-core';
|
||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { errorScriptConstraintMock } from '../../mock/actions.mock';
|
import { errorScriptConstraintMock } from '../../mock/actions.mock';
|
||||||
|
import { MAT_FORM_FIELD_DEFAULT_OPTIONS } from '@angular/material/form-field';
|
||||||
|
|
||||||
describe('RuleOptionsUiComponent', () => {
|
describe('RuleOptionsUiComponent', () => {
|
||||||
let fixture: ComponentFixture<RuleOptionsUiComponent>;
|
let fixture: ComponentFixture<RuleOptionsUiComponent>;
|
||||||
@ -46,7 +47,8 @@ describe('RuleOptionsUiComponent', () => {
|
|||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||||
imports: [FormsModule, ReactiveFormsModule, CoreTestingModule],
|
imports: [FormsModule, ReactiveFormsModule, CoreTestingModule],
|
||||||
declarations: [RuleOptionsUiComponent]
|
declarations: [RuleOptionsUiComponent],
|
||||||
|
providers: [{ provide: MAT_FORM_FIELD_DEFAULT_OPTIONS, useValue: { floatLabel: 'never' } }]
|
||||||
});
|
});
|
||||||
|
|
||||||
fixture = TestBed.createComponent(RuleOptionsUiComponent);
|
fixture = TestBed.createComponent(RuleOptionsUiComponent);
|
||||||
@ -133,4 +135,20 @@ describe('RuleOptionsUiComponent', () => {
|
|||||||
expect((matOptions[1].nativeElement as HTMLElement).innerText.trim()).toBe('Script 1');
|
expect((matOptions[1].nativeElement as HTMLElement).innerText.trim()).toBe('Script 1');
|
||||||
expect((matOptions[2].nativeElement as HTMLElement).innerText.trim()).toBe('Script 2');
|
expect((matOptions[2].nativeElement as HTMLElement).innerText.trim()).toBe('Script 2');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should always show a label for the error script dropdown even when MAT_FORM_FIELD_DEFAULT_OPTIONS sets floatLabel to never', () => {
|
||||||
|
component.writeValue({
|
||||||
|
isEnabled: true,
|
||||||
|
isInheritable: false,
|
||||||
|
isAsynchronous: true,
|
||||||
|
errorScript: ''
|
||||||
|
});
|
||||||
|
component.errorScriptConstraint = errorScriptConstraintMock;
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const matFormField = fixture.debugElement.query(By.css(`[data-automation-id="rule-option-form-field-errorScript"] .mat-form-field-label`));
|
||||||
|
fixture.detectChanges();
|
||||||
|
expect(matFormField).not.toBeNull();
|
||||||
|
expect(matFormField.componentInstance['floatLabel']).toBe('always');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user