From 8bd17cf76b50f8a3c7587b718f97c8b36d67e0ef Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Sat, 9 Aug 2025 21:32:10 -0700 Subject: [PATCH] Close document if delete original chosen --- .../document-detail/document-detail.component.spec.ts | 11 +++++++---- .../document-detail/document-detail.component.ts | 3 +++ 2 files changed, 10 insertions(+), 4 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 0fc1ea5ef..748150959 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 @@ -1161,6 +1161,8 @@ describe('DocumentDetailComponent', () => { it('should support pdf editor, handle error', () => { let modal: NgbModalRef modalService.activeInstances.subscribe((m) => (modal = m[0])) + const closeSpy = jest.spyOn(openDocumentsService, 'closeDocument') + const errorSpy = jest.spyOn(toastService, 'showError') initNormally() component.editPdf() expect(modal).not.toBeUndefined() @@ -1180,18 +1182,19 @@ describe('DocumentDetailComponent', () => { include_metadata: true, }, }) - req.flush(true) + req.error(new ErrorEvent('failed')) + expect(errorSpy).toHaveBeenCalled() component.editPdf() modal.componentInstance.documentID = doc.id modal.componentInstance.pages = [{ page: 1, rotate: 0, splitAfter: true }] + modal.componentInstance.deleteOriginal = 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() + req.flush(true) + expect(closeSpy).toHaveBeenCalled() }) it('should support keyboard shortcuts', () => { diff --git a/src-ui/src/app/components/document-detail/document-detail.component.ts b/src-ui/src/app/components/document-detail/document-detail.component.ts index cbc4027e0..45fb9fc83 100644 --- a/src-ui/src/app/components/document-detail/document-detail.component.ts +++ b/src-ui/src/app/components/document-detail/document-detail.component.ts @@ -1378,6 +1378,9 @@ export class DocumentDetailComponent $localize`PDF edit operation for "${this.document.title}" will begin in the background.` ) modal.close() + if (modal.componentInstance.deleteOriginal) { + this.openDocumentService.closeDocument(this.document) + } }, error: (error) => { if (modal) { -- 2.47.2