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 d8c3d8848..e9f137724 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 @@ -1227,6 +1227,35 @@ describe('DocumentDetailComponent', () => { req.flush(true) }) + it('should require the current password before removing it', () => { + initNormally() + const errorSpy = jest.spyOn(toastService, 'showError') + component.requiresPassword = true + component.password = '' + + component.removePassword() + + expect(errorSpy).toHaveBeenCalled() + httpTestingController.expectNone( + `${environment.apiBaseUrl}documents/bulk_edit/` + ) + }) + + it('should handle failures when removing password protection', () => { + initNormally() + const errorSpy = jest.spyOn(toastService, 'showError') + component.password = 'secret' + + component.removePassword() + const req = httpTestingController.expectOne( + `${environment.apiBaseUrl}documents/bulk_edit/` + ) + req.error(new ErrorEvent('failed')) + + expect(errorSpy).toHaveBeenCalled() + expect(component.networkActive).toBe(false) + }) + it('should support keyboard shortcuts', () => { initNormally()