mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-08 15:55:31 +01:00
Fix: outdated confirm dialog confirm
This commit is contained in:
parent
51dd95be3d
commit
2e2362e2df
2 changed files with 9 additions and 0 deletions
|
|
@ -968,6 +968,8 @@ describe('DocumentDetailComponent', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should warn when open document does not match doc retrieved from backend on init', () => {
|
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 modalSpy = jest.spyOn(modalService, 'open')
|
||||||
const openDoc = Object.assign({}, doc)
|
const openDoc = Object.assign({}, doc)
|
||||||
// simulate a document being modified elsewhere and db updated
|
// simulate a document being modified elsewhere and db updated
|
||||||
|
|
@ -986,6 +988,10 @@ describe('DocumentDetailComponent', () => {
|
||||||
)
|
)
|
||||||
fixture.detectChanges() // calls ngOnInit
|
fixture.detectChanges() // calls ngOnInit
|
||||||
expect(modalSpy).toHaveBeenCalledWith(ConfirmDialogComponent)
|
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() {
|
function initNormally() {
|
||||||
|
|
|
||||||
|
|
@ -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.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.cancelBtnClass = 'visually-hidden'
|
||||||
modal.componentInstance.btnCaption = $localize`Ok`
|
modal.componentInstance.btnCaption = $localize`Ok`
|
||||||
|
modal.componentInstance.confirmClicked.subscribe(() =>
|
||||||
|
modal.close()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.documentForm.dirty) {
|
if (this.documentForm.dirty) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue