mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
AAE-43974 Fix for alfresco-content-app e2e failure (#12055)
* AAE-43974 Fix for alfresco-content-app e2e failure * AAE-43974 Refactored based on review comments * AAE-43974 Removing unit test cases written for isError as it is being tested by passwordErrorStateMatcher * [ci:force] re-trigger CI
This commit is contained in:
+3
-4
@@ -9,10 +9,9 @@
|
||||
data-automation-id='adf-password-dialog-input'
|
||||
type="password"
|
||||
placeholder="{{ 'ADF_VIEWER.PDF_DIALOG.PLACEHOLDER' | translate }}"
|
||||
[formControl]="passwordFormControl" />
|
||||
@if (isError()) {
|
||||
<mat-error data-automation-id='adf-password-dialog-error'><span class="adf-error-text">{{ 'ADF_VIEWER.PDF_DIALOG.ERROR' | translate }}</span></mat-error>
|
||||
}
|
||||
[formControl]="passwordFormControl"
|
||||
[errorStateMatcher]="passwordErrorStateMatcher" />
|
||||
<mat-error data-automation-id='adf-password-dialog-error'><span class="adf-error-text">{{ 'ADF_VIEWER.PDF_DIALOG.ERROR' | translate }}</span></mat-error>
|
||||
</mat-form-field>
|
||||
</form>
|
||||
</mat-dialog-content>
|
||||
|
||||
+9
-9
@@ -55,21 +55,21 @@ describe('PdfPasswordDialogComponent', () => {
|
||||
expect(component.passwordFormControl.value).toBe('');
|
||||
});
|
||||
|
||||
describe('isError', () => {
|
||||
describe('passwordErrorStateMatcher', () => {
|
||||
beforeEach(() => {
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should return false', () => {
|
||||
component.data.reason = pdfjsLib.PasswordResponses.NEED_PASSWORD;
|
||||
|
||||
expect(component.isError()).toBe(false);
|
||||
});
|
||||
|
||||
it('should return true', () => {
|
||||
it('should report error state when password is incorrect', () => {
|
||||
component.data.reason = pdfjsLib.PasswordResponses.INCORRECT_PASSWORD;
|
||||
|
||||
expect(component.isError()).toBe(true);
|
||||
expect(component.passwordErrorStateMatcher.isErrorState(null, null)).toBe(true);
|
||||
});
|
||||
|
||||
it('should not report error state when password is needed', () => {
|
||||
component.data.reason = pdfjsLib.PasswordResponses.NEED_PASSWORD;
|
||||
|
||||
expect(component.passwordErrorStateMatcher.isErrorState(null, null)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
+5
-1
@@ -19,6 +19,7 @@ import { Component, OnInit, ViewEncapsulation, inject } from '@angular/core';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatDialogRef, MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog';
|
||||
import { ReactiveFormsModule, UntypedFormControl, Validators } from '@angular/forms';
|
||||
import { ErrorStateMatcher } from '@angular/material/core';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { TranslatePipe } from '@ngx-translate/core';
|
||||
@@ -38,12 +39,15 @@ export class PdfPasswordDialogComponent implements OnInit {
|
||||
data = inject(MAT_DIALOG_DATA);
|
||||
|
||||
passwordFormControl: UntypedFormControl;
|
||||
passwordErrorStateMatcher: ErrorStateMatcher = {
|
||||
isErrorState: () => this.isError()
|
||||
};
|
||||
|
||||
ngOnInit() {
|
||||
this.passwordFormControl = new UntypedFormControl('', [Validators.required]);
|
||||
}
|
||||
|
||||
isError(): boolean {
|
||||
private isError(): boolean {
|
||||
return this.data.reason === pdfjsLib.PasswordResponses.INCORRECT_PASSWORD;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user