mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-08-28 01:26:14 +00:00
Merge branch 'dev' into feature-ai
This commit is contained in:
@@ -495,6 +495,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'
|
||||
@@ -1443,4 +1455,19 @@ describe('DocumentDetailComponent', () => {
|
||||
component.openEmailDocument()
|
||||
expect(modalSpy).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('should set previewText', () => {
|
||||
initNormally()
|
||||
const previewText = 'Hello world, this is a test'
|
||||
httpTestingController.expectOne(component.previewUrl).flush(previewText)
|
||||
expect(component.previewText).toEqual(previewText)
|
||||
})
|
||||
|
||||
it('should set previewText to error message if preview fails', () => {
|
||||
initNormally()
|
||||
httpTestingController
|
||||
.expectOne(component.previewUrl)
|
||||
.flush('fail', { status: 500, statusText: 'Server Error' })
|
||||
expect(component.previewText).toContain('An error occurred loading content')
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user