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:
Anamika Dey
2026-07-10 18:53:53 +00:00
committed by GitHub
parent b86e41515e
commit c7bd56f244
3 changed files with 17 additions and 14 deletions
@@ -9,10 +9,9 @@
data-automation-id='adf-password-dialog-input' data-automation-id='adf-password-dialog-input'
type="password" type="password"
placeholder="{{ 'ADF_VIEWER.PDF_DIALOG.PLACEHOLDER' | translate }}" placeholder="{{ 'ADF_VIEWER.PDF_DIALOG.PLACEHOLDER' | translate }}"
[formControl]="passwordFormControl" /> [formControl]="passwordFormControl"
@if (isError()) { [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-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> </mat-form-field>
</form> </form>
</mat-dialog-content> </mat-dialog-content>
@@ -55,21 +55,21 @@ describe('PdfPasswordDialogComponent', () => {
expect(component.passwordFormControl.value).toBe(''); expect(component.passwordFormControl.value).toBe('');
}); });
describe('isError', () => { describe('passwordErrorStateMatcher', () => {
beforeEach(() => { beforeEach(() => {
fixture.detectChanges(); fixture.detectChanges();
}); });
it('should return false', () => { it('should report error state when password is incorrect', () => {
component.data.reason = pdfjsLib.PasswordResponses.NEED_PASSWORD;
expect(component.isError()).toBe(false);
});
it('should return true', () => {
component.data.reason = pdfjsLib.PasswordResponses.INCORRECT_PASSWORD; 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);
}); });
}); });
@@ -19,6 +19,7 @@ import { Component, OnInit, ViewEncapsulation, inject } from '@angular/core';
import { MatButtonModule } from '@angular/material/button'; import { MatButtonModule } from '@angular/material/button';
import { MatDialogRef, MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog'; import { MatDialogRef, MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog';
import { ReactiveFormsModule, UntypedFormControl, Validators } from '@angular/forms'; import { ReactiveFormsModule, UntypedFormControl, Validators } from '@angular/forms';
import { ErrorStateMatcher } from '@angular/material/core';
import { MatFormFieldModule } from '@angular/material/form-field'; import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input'; import { MatInputModule } from '@angular/material/input';
import { TranslatePipe } from '@ngx-translate/core'; import { TranslatePipe } from '@ngx-translate/core';
@@ -38,12 +39,15 @@ export class PdfPasswordDialogComponent implements OnInit {
data = inject(MAT_DIALOG_DATA); data = inject(MAT_DIALOG_DATA);
passwordFormControl: UntypedFormControl; passwordFormControl: UntypedFormControl;
passwordErrorStateMatcher: ErrorStateMatcher = {
isErrorState: () => this.isError()
};
ngOnInit() { ngOnInit() {
this.passwordFormControl = new UntypedFormControl('', [Validators.required]); this.passwordFormControl = new UntypedFormControl('', [Validators.required]);
} }
isError(): boolean { private isError(): boolean {
return this.data.reason === pdfjsLib.PasswordResponses.INCORRECT_PASSWORD; return this.data.reason === pdfjsLib.PasswordResponses.INCORRECT_PASSWORD;
} }