From f96523a6383b924251cd3f2c77bab05832d8f1db Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Thu, 3 Jul 2025 12:07:16 -0700 Subject: [PATCH] Add error handling test for PDF editor --- .../document-detail.component.spec.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src-ui/src/app/components/document-detail/document-detail.component.spec.ts b/src-ui/src/app/components/document-detail/document-detail.component.spec.ts index 5574ac6ff..203ac18b9 100644 --- a/src-ui/src/app/components/document-detail/document-detail.component.spec.ts +++ b/src-ui/src/app/components/document-detail/document-detail.component.spec.ts @@ -1142,7 +1142,7 @@ describe('DocumentDetailComponent', () => { ).not.toBeUndefined() }) - it('should support pdf editor', () => { + it('should support pdf editor, handle error', () => { let modal: NgbModalRef modalService.activeInstances.subscribe((m) => (modal = m[0])) initNormally() @@ -1151,7 +1151,7 @@ describe('DocumentDetailComponent', () => { modal.componentInstance.documentID = doc.id modal.componentInstance.pages = [{ page: 1, rotate: 0, splitAfter: false }] modal.componentInstance.confirm() - const req = httpTestingController.expectOne( + let req = httpTestingController.expectOne( `${environment.apiBaseUrl}documents/bulk_edit/` ) expect(req.request.body).toEqual({ @@ -1165,6 +1165,17 @@ describe('DocumentDetailComponent', () => { }, }) req.flush(true) + + component.editPdf() + modal.componentInstance.documentID = doc.id + modal.componentInstance.pages = [{ page: 1, rotate: 0, splitAfter: true }] + modal.componentInstance.confirm() + const errorSpy = jest.spyOn(toastService, 'showError') + req = httpTestingController.expectOne( + `${environment.apiBaseUrl}documents/bulk_edit/` + ) + req.error(new ErrorEvent('failed')) + expect(errorSpy).toHaveBeenCalled() }) it('should support keyboard shortcuts', () => {