mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-02-14 00:09:35 -06:00
Last part of frontend coverage
This commit is contained in:
@@ -318,6 +318,27 @@ describe('DocumentDetailComponent', () => {
|
|||||||
component = fixture.componentInstance
|
component = fixture.componentInstance
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function initNormally() {
|
||||||
|
jest
|
||||||
|
.spyOn(activatedRoute, 'paramMap', 'get')
|
||||||
|
.mockReturnValue(of(convertToParamMap({ id: 3, section: 'details' })))
|
||||||
|
jest
|
||||||
|
.spyOn(documentService, 'get')
|
||||||
|
.mockReturnValueOnce(of(Object.assign({}, doc)))
|
||||||
|
jest.spyOn(openDocumentsService, 'getOpenDocument').mockReturnValue(null)
|
||||||
|
jest
|
||||||
|
.spyOn(openDocumentsService, 'openDocument')
|
||||||
|
.mockReturnValueOnce(of(true))
|
||||||
|
jest.spyOn(customFieldsService, 'listAll').mockReturnValue(
|
||||||
|
of({
|
||||||
|
count: customFields.length,
|
||||||
|
all: customFields.map((f) => f.id),
|
||||||
|
results: customFields,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
fixture.detectChanges()
|
||||||
|
}
|
||||||
|
|
||||||
it('should load four tabs via url params', () => {
|
it('should load four tabs via url params', () => {
|
||||||
jest
|
jest
|
||||||
.spyOn(activatedRoute, 'paramMap', 'get')
|
.spyOn(activatedRoute, 'paramMap', 'get')
|
||||||
@@ -1674,6 +1695,7 @@ describe('DocumentDetailComponent', () => {
|
|||||||
const uploadSpy = jest.spyOn(documentService, 'uploadVersion')
|
const uploadSpy = jest.spyOn(documentService, 'uploadVersion')
|
||||||
const versionsSpy = jest.spyOn(documentService, 'getVersions')
|
const versionsSpy = jest.spyOn(documentService, 'getVersions')
|
||||||
const infoSpy = jest.spyOn(toastService, 'showInfo')
|
const infoSpy = jest.spyOn(toastService, 'showInfo')
|
||||||
|
const errorSpy = jest.spyOn(toastService, 'showError')
|
||||||
const finishedSpy = jest.spyOn(
|
const finishedSpy = jest.spyOn(
|
||||||
websocketStatusService,
|
websocketStatusService,
|
||||||
'onDocumentConsumptionFinished'
|
'onDocumentConsumptionFinished'
|
||||||
@@ -1755,28 +1777,17 @@ describe('DocumentDetailComponent', () => {
|
|||||||
component.clearVersionUploadStatus()
|
component.clearVersionUploadStatus()
|
||||||
expect(component.versionUploadState).toBe(UploadState.Idle)
|
expect(component.versionUploadState).toBe(UploadState.Idle)
|
||||||
expect(component.versionUploadError).toBeNull()
|
expect(component.versionUploadError).toBeNull()
|
||||||
})
|
|
||||||
|
|
||||||
function initNormally() {
|
uploadSpy.mockReturnValueOnce(throwError(() => new Error('upload blew up')))
|
||||||
jest
|
component.onVersionFileSelected({
|
||||||
.spyOn(activatedRoute, 'paramMap', 'get')
|
target: createFileInput(
|
||||||
.mockReturnValue(of(convertToParamMap({ id: 3, section: 'details' })))
|
new File(['data'], 'version.pdf', { type: 'application/pdf' })
|
||||||
jest
|
),
|
||||||
.spyOn(documentService, 'get')
|
} as any)
|
||||||
.mockReturnValueOnce(of(Object.assign({}, doc)))
|
expect(component.versionUploadState).toBe(UploadState.Failed)
|
||||||
jest.spyOn(openDocumentsService, 'getOpenDocument').mockReturnValue(null)
|
expect(component.versionUploadError).toBe('upload blew up')
|
||||||
jest
|
expect(errorSpy).toHaveBeenCalled()
|
||||||
.spyOn(openDocumentsService, 'openDocument')
|
})
|
||||||
.mockReturnValueOnce(of(true))
|
|
||||||
jest.spyOn(customFieldsService, 'listAll').mockReturnValue(
|
|
||||||
of({
|
|
||||||
count: customFields.length,
|
|
||||||
all: customFields.map((f) => f.id),
|
|
||||||
results: customFields,
|
|
||||||
})
|
|
||||||
)
|
|
||||||
fixture.detectChanges()
|
|
||||||
}
|
|
||||||
|
|
||||||
it('createDisabled should return true if the user does not have permission to add the specified data type', () => {
|
it('createDisabled should return true if the user does not have permission to add the specified data type', () => {
|
||||||
currentUserCan = false
|
currentUserCan = false
|
||||||
|
|||||||
Reference in New Issue
Block a user