]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Chore: add test for navigation on document load error
authorshamoon <4887959+shamoon@users.noreply.github.com>
Sat, 23 Aug 2025 03:03:06 +0000 (20:03 -0700)
committershamoon <4887959+shamoon@users.noreply.github.com>
Sat, 23 Aug 2025 03:03:06 +0000 (20:03 -0700)
src-ui/src/app/components/document-detail/document-detail.component.spec.ts

index d9c4e64db9af06372e1521ed8cb3e869664d73fe..ed0d2a1255e2ec997cbebdca94fc947cc4815bcd 100644 (file)
@@ -452,6 +452,18 @@ describe('DocumentDetailComponent', () => {
     expect(navigateSpy).toHaveBeenCalledWith(['404'], { replaceUrl: true })
   })
 
+  it('should navigate to 404 if error on load', () => {
+    jest
+      .spyOn(activatedRoute, 'paramMap', 'get')
+      .mockReturnValue(of(convertToParamMap({ id: 3, section: 'details' })))
+    const navigateSpy = jest.spyOn(router, 'navigate')
+    jest
+      .spyOn(documentService, 'get')
+      .mockReturnValue(throwError(() => new Error('not found')))
+    fixture.detectChanges()
+    expect(navigateSpy).toHaveBeenCalledWith(['404'], { replaceUrl: true })
+  })
+
   it('should support save, close and show success toast', () => {
     initNormally()
     component.title = 'Foo Bar'