]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Add error handling test for PDF editor
authorshamoon <4887959+shamoon@users.noreply.github.com>
Thu, 3 Jul 2025 19:07:16 +0000 (12:07 -0700)
committershamoon <4887959+shamoon@users.noreply.github.com>
Sat, 2 Aug 2025 12:22:55 +0000 (08:22 -0400)
src-ui/src/app/components/document-detail/document-detail.component.spec.ts

index dc49e40706a7158ce0ba25eb9a644e6d3b88b040..0fc1ea5efa2828beeab9bfd8d42c8333170ceb14 100644 (file)
@@ -1158,7 +1158,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()
@@ -1167,7 +1167,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({
@@ -1181,6 +1181,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', () => {