]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Fix: outdated confirm dialog confirm
authorshamoon <4887959+shamoon@users.noreply.github.com>
Tue, 16 Jan 2024 23:18:26 +0000 (15:18 -0800)
committershamoon <4887959+shamoon@users.noreply.github.com>
Tue, 16 Jan 2024 23:18:26 +0000 (15:18 -0800)
src-ui/src/app/components/document-detail/document-detail.component.spec.ts
src-ui/src/app/components/document-detail/document-detail.component.ts

index 51a77fb91031b8fc00f8b992dc76dc829c0005a8..e2a148bb9077a4cab68b506b32f9b55d4716370f 100644 (file)
@@ -968,6 +968,8 @@ describe('DocumentDetailComponent', () => {
   })
 
   it('should warn when open document does not match doc retrieved from backend on init', () => {
+    let openModal: NgbModalRef
+    modalService.activeInstances.subscribe((modals) => (openModal = modals[0]))
     const modalSpy = jest.spyOn(modalService, 'open')
     const openDoc = Object.assign({}, doc)
     // simulate a document being modified elsewhere and db updated
@@ -986,6 +988,10 @@ describe('DocumentDetailComponent', () => {
     )
     fixture.detectChanges() // calls ngOnInit
     expect(modalSpy).toHaveBeenCalledWith(ConfirmDialogComponent)
+    const closeSpy = jest.spyOn(openModal, 'close')
+    const confirmDialog = openModal.componentInstance as ConfirmDialogComponent
+    confirmDialog.confirmClicked.next(confirmDialog)
+    expect(closeSpy).toHaveBeenCalled()
   })
 
   function initNormally() {
index 16eb9599c5c96328e39eebbb66b5d48e61c71be8..0e79b3deb1c8cc2be263542adc91a19a9ab36ee2 100644 (file)
@@ -309,6 +309,9 @@ export class DocumentDetailComponent
               modal.componentInstance.message = $localize`Saving the document here may overwrite other changes that were made. To restore the existing version, discard your changes or close the document.`
               modal.componentInstance.cancelBtnClass = 'visually-hidden'
               modal.componentInstance.btnCaption = $localize`Ok`
+              modal.componentInstance.confirmClicked.subscribe(() =>
+                modal.close()
+              )
             }
 
             if (this.documentForm.dirty) {