mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -05:00
frontend unit tests
toasts component testing conditional import of angular setup-jest for vscode-jest support Update jest.config.js Create open-documents.service.spec.ts Add unit tests for all REST services settings service test Remove component from settings service test Create permissions.service.spec.ts upload documents service tests Update package.json Create toast.service.spec.ts Tasks service test Statistics widget component tests Update permissions.service.ts Create app.component.spec.ts settings component testing tasks component unit testing Management list component generic tests Some management component tests document notes component unit tests Create document-list.component.spec.ts Create save-view-config-dialog.component.spec.ts Create filter-editor.component.spec.ts small and large document cards unit testing Create bulk-editor.component.spec.ts document detail unit tests saving work on documentdetail component spec Create document-asn.component.spec.ts dashboard & widgets unit testing Fix ResizeObserver mock common component unit tests fix some merge errors Update app-frame.component.spec.ts Create page-header.component.spec.ts input component unit tests FilterableDropdownComponent unit testing and found minor errors update taskservice unit tests Edit dialogs unit tests Create date-dropdown.component.spec.ts Remove selectors from guard tests confirm dialog component tests app frame component test Miscellaneous component tests Update document-list-view.service.spec.ts directives unit tests Remove unused resizeobserver mock guard unit tests Update query-params.spec.ts try to fix flaky playwright filter rules utils & testing Interceptor unit tests Pipes unit testing Utils unit tests Update upload-documents.service.spec.ts consumer status service tests Update setup-jest.ts Create document-list-view.service.spec.ts Update app-routing.module.ts
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
import { HttpTestingController } from '@angular/common/http/testing'
|
||||
import { Subscription } from 'rxjs'
|
||||
import { TestBed } from '@angular/core/testing'
|
||||
import { environment } from 'src/environments/environment'
|
||||
import { AbstractNameFilterService } from './abstract-name-filter-service'
|
||||
import { commonAbstractPaperlessServiceTests } from './abstract-paperless-service.spec'
|
||||
|
||||
let httpTestingController: HttpTestingController
|
||||
let service: AbstractNameFilterService<any>
|
||||
let subscription: Subscription
|
||||
|
||||
export const commonAbstractNameFilterPaperlessServiceTests = (
|
||||
endpoint,
|
||||
ServiceClass
|
||||
) => {
|
||||
commonAbstractPaperlessServiceTests(endpoint, ServiceClass)
|
||||
|
||||
describe(`Common name filter service tests for ${endpoint}`, () => {
|
||||
test('should call appropriate api endpoint for list filtering', () => {
|
||||
const page = 2
|
||||
const pageSize = 50
|
||||
const sortField = 'name'
|
||||
const sortReverse = true
|
||||
const nameFilter = 'hello'
|
||||
const fullPerms = true
|
||||
subscription = service
|
||||
.listFiltered(
|
||||
page,
|
||||
pageSize,
|
||||
sortField,
|
||||
sortReverse,
|
||||
nameFilter,
|
||||
fullPerms
|
||||
)
|
||||
.subscribe()
|
||||
const req = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}${endpoint}/?page=${page}&page_size=${pageSize}&ordering=-${sortField}&name__icontains=${nameFilter}&full_perms=true`
|
||||
)
|
||||
expect(req.request.method).toEqual('GET')
|
||||
req.flush([])
|
||||
})
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
// Dont need to setup again
|
||||
// TestBed.configureTestingModule({
|
||||
// providers: [ServiceClass],
|
||||
// imports: [HttpClientTestingModule],
|
||||
// teardown: { destroyAfterEach: true },
|
||||
// })
|
||||
|
||||
httpTestingController = TestBed.inject(HttpTestingController)
|
||||
service = TestBed.inject(ServiceClass)
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
subscription?.unsubscribe()
|
||||
// httpTestingController.verify()
|
||||
})
|
||||
}
|
116
src-ui/src/app/services/rest/abstract-paperless-service.spec.ts
Normal file
116
src-ui/src/app/services/rest/abstract-paperless-service.spec.ts
Normal file
@@ -0,0 +1,116 @@
|
||||
import {
|
||||
HttpClientTestingModule,
|
||||
HttpTestingController,
|
||||
} from '@angular/common/http/testing'
|
||||
import { AbstractPaperlessService } from './abstract-paperless-service'
|
||||
import { Subscription } from 'rxjs'
|
||||
import { TestBed } from '@angular/core/testing'
|
||||
import { environment } from 'src/environments/environment'
|
||||
|
||||
let httpTestingController: HttpTestingController
|
||||
let service: AbstractPaperlessService<any>
|
||||
let subscription: Subscription
|
||||
|
||||
export const commonAbstractPaperlessServiceTests = (endpoint, ServiceClass) => {
|
||||
describe(`Common service tests for ${endpoint}`, () => {
|
||||
test('should call appropriate api endpoint for list all', () => {
|
||||
subscription = service.listAll().subscribe()
|
||||
const req = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}${endpoint}/?page=1&page_size=100000`
|
||||
)
|
||||
expect(req.request.method).toEqual('GET')
|
||||
req.flush([])
|
||||
})
|
||||
|
||||
test('should call appropriate api endpoint for get a single object', () => {
|
||||
const id = 0
|
||||
subscription = service.get(id).subscribe()
|
||||
const req = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}${endpoint}/${id}/`
|
||||
)
|
||||
expect(req.request.method).toEqual('GET')
|
||||
req.flush([])
|
||||
})
|
||||
|
||||
test('should call appropriate api endpoint for create a single object', () => {
|
||||
const o = {
|
||||
name: 'Name',
|
||||
}
|
||||
subscription = service.create(o).subscribe()
|
||||
const req = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}${endpoint}/`
|
||||
)
|
||||
expect(req.request.method).toEqual('POST')
|
||||
req.flush([])
|
||||
})
|
||||
|
||||
test('should call appropriate api endpoint for delete a single object', () => {
|
||||
const id = 10
|
||||
const o = {
|
||||
name: 'Name',
|
||||
id,
|
||||
}
|
||||
subscription = service.delete(o).subscribe()
|
||||
const req = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}${endpoint}/${id}/`
|
||||
)
|
||||
expect(req.request.method).toEqual('DELETE')
|
||||
req.flush([])
|
||||
})
|
||||
|
||||
test('should call appropriate api endpoint for update a single object', () => {
|
||||
const id = 10
|
||||
const o = {
|
||||
name: 'Name',
|
||||
id,
|
||||
}
|
||||
|
||||
// some services need to call listAll first
|
||||
subscription = service.listAll().subscribe()
|
||||
let req = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}${endpoint}/?page=1&page_size=100000`
|
||||
)
|
||||
req.flush({
|
||||
results: [o],
|
||||
})
|
||||
subscription.unsubscribe()
|
||||
|
||||
subscription = service.update(o).subscribe()
|
||||
req = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}${endpoint}/${id}/`
|
||||
)
|
||||
expect(req.request.method).toEqual('PUT')
|
||||
req.flush([])
|
||||
})
|
||||
|
||||
test('should call appropriate api endpoint for patch a single object', () => {
|
||||
const id = 10
|
||||
const o = {
|
||||
name: 'Name',
|
||||
id,
|
||||
}
|
||||
subscription = service.patch(o).subscribe()
|
||||
const req = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}${endpoint}/${id}/`
|
||||
)
|
||||
expect(req.request.method).toEqual('PATCH')
|
||||
req.flush([])
|
||||
})
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [ServiceClass],
|
||||
imports: [HttpClientTestingModule],
|
||||
teardown: { destroyAfterEach: true },
|
||||
})
|
||||
|
||||
httpTestingController = TestBed.inject(HttpTestingController)
|
||||
service = TestBed.inject(ServiceClass)
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
subscription?.unsubscribe()
|
||||
// httpTestingController.verify()
|
||||
})
|
||||
}
|
@@ -10,9 +10,9 @@ export abstract class AbstractPaperlessService<T extends ObjectWithId> {
|
||||
|
||||
constructor(protected http: HttpClient, private resourceName: string) {}
|
||||
|
||||
protected getResourceUrl(id?: number, action?: string): string {
|
||||
protected getResourceUrl(id: number = null, action: string = null): string {
|
||||
let url = `${this.baseUrl}${this.resourceName}/`
|
||||
if (id) {
|
||||
if (id !== null) {
|
||||
url += `${id}/`
|
||||
}
|
||||
if (action) {
|
||||
|
@@ -0,0 +1,7 @@
|
||||
import { CorrespondentService } from './correspondent.service'
|
||||
import { commonAbstractNameFilterPaperlessServiceTests } from './abstract-name-filter-service.spec'
|
||||
|
||||
commonAbstractNameFilterPaperlessServiceTests(
|
||||
'correspondents',
|
||||
CorrespondentService
|
||||
)
|
79
src-ui/src/app/services/rest/document-notes.service.spec.ts
Normal file
79
src-ui/src/app/services/rest/document-notes.service.spec.ts
Normal file
@@ -0,0 +1,79 @@
|
||||
import { HttpTestingController } from '@angular/common/http/testing'
|
||||
import { Subscription } from 'rxjs'
|
||||
import { TestBed } from '@angular/core/testing'
|
||||
import { environment } from 'src/environments/environment'
|
||||
import { commonAbstractPaperlessServiceTests } from './abstract-paperless-service.spec'
|
||||
import { MailFilterAttachmentType } from 'src/app/data/paperless-mail-rule'
|
||||
import { MailMetadataTitleOption } from 'src/app/data/paperless-mail-rule'
|
||||
import { MailAction } from 'src/app/data/paperless-mail-rule'
|
||||
import { DocumentNotesService } from './document-notes.service'
|
||||
|
||||
let httpTestingController: HttpTestingController
|
||||
let service: DocumentNotesService
|
||||
let subscription: Subscription
|
||||
const documentId = 12
|
||||
const endpoint = 'documents'
|
||||
const endpoint2 = 'notes'
|
||||
const notes = [
|
||||
{
|
||||
created: new Date(),
|
||||
note: 'contents 1',
|
||||
user: 1,
|
||||
},
|
||||
{
|
||||
created: new Date(),
|
||||
note: 'contents 2',
|
||||
user: 1,
|
||||
},
|
||||
{
|
||||
created: new Date(),
|
||||
note: 'contents 3',
|
||||
user: 2,
|
||||
},
|
||||
]
|
||||
|
||||
// run common tests
|
||||
commonAbstractPaperlessServiceTests(endpoint, DocumentNotesService)
|
||||
|
||||
describe(`Additional service tests for DocumentNotesService`, () => {
|
||||
test('should call correct api endpoint on get notes', () => {
|
||||
subscription = service.getNotes(documentId).subscribe()
|
||||
const req = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}${endpoint}/${documentId}/${endpoint2}/`
|
||||
)
|
||||
expect(req.request.method).toEqual('GET')
|
||||
})
|
||||
|
||||
test('should call correct api endpoint on add note', () => {
|
||||
const content = 'some new text'
|
||||
subscription = service.addNote(documentId, content).subscribe()
|
||||
const req = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}${endpoint}/${documentId}/${endpoint2}/`
|
||||
)
|
||||
expect(req.request.method).toEqual('POST')
|
||||
expect(req.request.body).toEqual({
|
||||
note: content,
|
||||
})
|
||||
})
|
||||
|
||||
test('should call correct api endpoint on delete note', () => {
|
||||
const noteId = 11
|
||||
subscription = service.deleteNote(documentId, noteId).subscribe()
|
||||
const req = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}${endpoint}/${documentId}/${endpoint2}/?id=${noteId}`
|
||||
)
|
||||
expect(req.request.method).toEqual('DELETE')
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
// Dont need to setup again
|
||||
|
||||
httpTestingController = TestBed.inject(HttpTestingController)
|
||||
service = TestBed.inject(DocumentNotesService)
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
subscription?.unsubscribe()
|
||||
httpTestingController.verify()
|
||||
})
|
||||
})
|
@@ -0,0 +1,7 @@
|
||||
import { DocumentTypeService } from './document-type.service'
|
||||
import { commonAbstractNameFilterPaperlessServiceTests } from './abstract-name-filter-service.spec'
|
||||
|
||||
commonAbstractNameFilterPaperlessServiceTests(
|
||||
'document_types',
|
||||
DocumentTypeService
|
||||
)
|
247
src-ui/src/app/services/rest/document.service.spec.ts
Normal file
247
src-ui/src/app/services/rest/document.service.spec.ts
Normal file
@@ -0,0 +1,247 @@
|
||||
import {
|
||||
HttpClientTestingModule,
|
||||
HttpTestingController,
|
||||
} from '@angular/common/http/testing'
|
||||
import { Subscription } from 'rxjs'
|
||||
import { TestBed } from '@angular/core/testing'
|
||||
import { environment } from 'src/environments/environment'
|
||||
import { DocumentService } from './document.service'
|
||||
import { FILTER_TITLE } from 'src/app/data/filter-rule-type'
|
||||
|
||||
let httpTestingController: HttpTestingController
|
||||
let service: DocumentService
|
||||
let subscription: Subscription
|
||||
const endpoint = 'documents'
|
||||
const documents = [
|
||||
{
|
||||
id: 1,
|
||||
title: 'Doc 1',
|
||||
content: 'some content',
|
||||
tags: [1, 2, 3],
|
||||
correspondent: 11,
|
||||
document_type: 3,
|
||||
storage_path: 8,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
title: 'Doc 2',
|
||||
content: 'some content',
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
title: 'Doc 3',
|
||||
content: 'some content',
|
||||
},
|
||||
]
|
||||
|
||||
describe(`DocumentService`, () => {
|
||||
// common tests e.g. commonAbstractPaperlessServiceTests differ slightly
|
||||
it('should call appropriate api endpoint for list all', () => {
|
||||
subscription = service.listAll().subscribe()
|
||||
const req = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}${endpoint}/?page=1&page_size=100000`
|
||||
)
|
||||
expect(req.request.method).toEqual('GET')
|
||||
})
|
||||
|
||||
it('should call appropriate api endpoint for get a single document', () => {
|
||||
subscription = service.get(documents[0].id).subscribe()
|
||||
const req = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}${endpoint}/${documents[0].id}/?full_perms=true`
|
||||
)
|
||||
expect(req.request.method).toEqual('GET')
|
||||
})
|
||||
|
||||
it('should call appropriate api endpoint for create a single document', () => {
|
||||
subscription = service.create(documents[0]).subscribe()
|
||||
const req = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}${endpoint}/`
|
||||
)
|
||||
expect(req.request.method).toEqual('POST')
|
||||
})
|
||||
|
||||
it('should call appropriate api endpoint for delete a single document', () => {
|
||||
subscription = service.delete(documents[0]).subscribe()
|
||||
const req = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}${endpoint}/${documents[0].id}/`
|
||||
)
|
||||
expect(req.request.method).toEqual('DELETE')
|
||||
})
|
||||
|
||||
it('should call appropriate api endpoint for update a single document', () => {
|
||||
subscription = service.update(documents[0]).subscribe()
|
||||
const req = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}${endpoint}/${documents[0].id}/`
|
||||
)
|
||||
expect(req.request.method).toEqual('PUT')
|
||||
})
|
||||
|
||||
it('should call appropriate api endpoint for patch a single document', () => {
|
||||
subscription = service.patch(documents[0]).subscribe()
|
||||
const req = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}${endpoint}/${documents[0].id}/`
|
||||
)
|
||||
expect(req.request.method).toEqual('PATCH')
|
||||
})
|
||||
|
||||
it('should call appropriate api endpoint for listing all documents ids in a filter set', () => {
|
||||
subscription = service
|
||||
.listAllFilteredIds([
|
||||
{
|
||||
rule_type: FILTER_TITLE,
|
||||
value: 'apple',
|
||||
},
|
||||
])
|
||||
.subscribe()
|
||||
const req = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}${endpoint}/?page=1&page_size=100000&fields=id&title__icontains=apple`
|
||||
)
|
||||
expect(req.request.method).toEqual('GET')
|
||||
})
|
||||
|
||||
it('should call appropriate api endpoint for uploading a document', () => {
|
||||
subscription = service.uploadDocument(documents[0]).subscribe()
|
||||
const req = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}${endpoint}/post_document/`
|
||||
)
|
||||
expect(req.request.method).toEqual('POST')
|
||||
})
|
||||
|
||||
it('should call appropriate api endpoint for getting metadata', () => {
|
||||
subscription = service.getMetadata(documents[0].id).subscribe()
|
||||
const req = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}${endpoint}/${documents[0].id}/metadata/`
|
||||
)
|
||||
expect(req.request.method).toEqual('GET')
|
||||
})
|
||||
|
||||
it('should call appropriate api endpoint for getting selection data', () => {
|
||||
const ids = [documents[0].id]
|
||||
subscription = service.getSelectionData(ids).subscribe()
|
||||
const req = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}${endpoint}/selection_data/`
|
||||
)
|
||||
expect(req.request.method).toEqual('POST')
|
||||
expect(req.request.body).toEqual({
|
||||
documents: ids,
|
||||
})
|
||||
})
|
||||
|
||||
it('should call appropriate api endpoint for getting suggestions', () => {
|
||||
subscription = service.getSuggestions(documents[0].id).subscribe()
|
||||
const req = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}${endpoint}/${documents[0].id}/suggestions/`
|
||||
)
|
||||
expect(req.request.method).toEqual('GET')
|
||||
})
|
||||
|
||||
it('should call appropriate api endpoint for bulk download', () => {
|
||||
const ids = [1, 2, 3]
|
||||
const content = 'both'
|
||||
const useFilenameFormatting = false
|
||||
subscription = service
|
||||
.bulkDownload(ids, content, useFilenameFormatting)
|
||||
.subscribe()
|
||||
const req = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}${endpoint}/bulk_download/`
|
||||
)
|
||||
expect(req.request.method).toEqual('POST')
|
||||
expect(req.request.body).toEqual({
|
||||
documents: ids,
|
||||
content,
|
||||
follow_formatting: useFilenameFormatting,
|
||||
})
|
||||
})
|
||||
|
||||
it('should call appropriate api endpoint for bulk edit', () => {
|
||||
const ids = [1, 2, 3]
|
||||
const method = 'modify_tags'
|
||||
const parameters = {
|
||||
add_tags: [15],
|
||||
remove_tags: [6],
|
||||
}
|
||||
subscription = service.bulkEdit(ids, method, parameters).subscribe()
|
||||
const req = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}${endpoint}/bulk_edit/`
|
||||
)
|
||||
expect(req.request.method).toEqual('POST')
|
||||
expect(req.request.body).toEqual({
|
||||
documents: ids,
|
||||
method,
|
||||
parameters,
|
||||
})
|
||||
})
|
||||
|
||||
it('should return the correct preview URL for a single document', () => {
|
||||
let url = service.getPreviewUrl(documents[0].id)
|
||||
expect(url).toEqual(
|
||||
`${environment.apiBaseUrl}${endpoint}/${documents[0].id}/preview/`
|
||||
)
|
||||
url = service.getPreviewUrl(documents[0].id, true)
|
||||
expect(url).toEqual(
|
||||
`${environment.apiBaseUrl}${endpoint}/${documents[0].id}/preview/?original=true`
|
||||
)
|
||||
})
|
||||
|
||||
it('should return the correct thumb URL for a single document', () => {
|
||||
let url = service.getThumbUrl(documents[0].id)
|
||||
expect(url).toEqual(
|
||||
`${environment.apiBaseUrl}${endpoint}/${documents[0].id}/thumb/`
|
||||
)
|
||||
})
|
||||
|
||||
it('should return the correct download URL for a single document', () => {
|
||||
let url = service.getDownloadUrl(documents[0].id)
|
||||
expect(url).toEqual(
|
||||
`${environment.apiBaseUrl}${endpoint}/${documents[0].id}/download/`
|
||||
)
|
||||
url = service.getDownloadUrl(documents[0].id, true)
|
||||
expect(url).toEqual(
|
||||
`${environment.apiBaseUrl}${endpoint}/${documents[0].id}/download/?original=true`
|
||||
)
|
||||
})
|
||||
|
||||
it('should add observables to document', () => {
|
||||
subscription = service
|
||||
.listFiltered(1, 25, 'title', false, [])
|
||||
.subscribe((result) => {
|
||||
expect(result.results).toHaveLength(3)
|
||||
const doc = result.results[0]
|
||||
expect(doc.correspondent$).not.toBeNull()
|
||||
expect(doc.document_type$).not.toBeNull()
|
||||
expect(doc.tags$).not.toBeNull()
|
||||
expect(doc.storage_path$).not.toBeNull()
|
||||
})
|
||||
httpTestingController
|
||||
.expectOne(
|
||||
`${environment.apiBaseUrl}${endpoint}/?page=1&page_size=25&ordering=title`
|
||||
)
|
||||
.flush({
|
||||
results: documents,
|
||||
})
|
||||
})
|
||||
|
||||
it('should set search query', () => {
|
||||
const searchQuery = 'hello'
|
||||
service.searchQuery = searchQuery
|
||||
let url = service.getPreviewUrl(documents[0].id)
|
||||
expect(url).toEqual(
|
||||
`${environment.apiBaseUrl}${endpoint}/${documents[0].id}/preview/#search="${searchQuery}"`
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [DocumentService],
|
||||
imports: [HttpClientTestingModule],
|
||||
})
|
||||
|
||||
httpTestingController = TestBed.inject(HttpTestingController)
|
||||
service = TestBed.inject(DocumentService)
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
subscription?.unsubscribe()
|
||||
httpTestingController.verify()
|
||||
})
|
192
src-ui/src/app/services/rest/group.service.spec.ts
Normal file
192
src-ui/src/app/services/rest/group.service.spec.ts
Normal file
@@ -0,0 +1,192 @@
|
||||
import { HttpTestingController } from '@angular/common/http/testing'
|
||||
import { Subscription } from 'rxjs'
|
||||
import { TestBed } from '@angular/core/testing'
|
||||
import { environment } from 'src/environments/environment'
|
||||
import { GroupService } from './group.service'
|
||||
import { commonAbstractNameFilterPaperlessServiceTests } from './abstract-name-filter-service.spec'
|
||||
|
||||
let httpTestingController: HttpTestingController
|
||||
let service: GroupService
|
||||
let subscription: Subscription
|
||||
const endpoint = 'groups'
|
||||
const group = {
|
||||
name: 'Group Name',
|
||||
id: 1,
|
||||
user_count: 1,
|
||||
permissions: [
|
||||
'change_savedview',
|
||||
'change_schedule',
|
||||
'change_failure',
|
||||
'delete_token',
|
||||
'add_mailrule',
|
||||
'view_failure',
|
||||
'view_groupresult',
|
||||
'add_note',
|
||||
'change_taskresult',
|
||||
'view_tag',
|
||||
'view_user',
|
||||
'add_tag',
|
||||
'change_processedmail',
|
||||
'change_session',
|
||||
'view_taskattributes',
|
||||
'delete_groupresult',
|
||||
'delete_correspondent',
|
||||
'delete_schedule',
|
||||
'delete_contenttype',
|
||||
'view_chordcounter',
|
||||
'view_success',
|
||||
'delete_documenttype',
|
||||
'add_tokenproxy',
|
||||
'delete_paperlesstask',
|
||||
'add_log',
|
||||
'view_mailaccount',
|
||||
'add_uisettings',
|
||||
'view_savedview',
|
||||
'view_uisettings',
|
||||
'delete_storagepath',
|
||||
'delete_frontendsettings',
|
||||
'change_paperlesstask',
|
||||
'view_taskresult',
|
||||
'delete_processedmail',
|
||||
'view_processedmail',
|
||||
'view_session',
|
||||
'delete_chordcounter',
|
||||
'view_note',
|
||||
'delete_session',
|
||||
'view_document',
|
||||
'change_mailaccount',
|
||||
'delete_taskattributes',
|
||||
'add_groupobjectpermission',
|
||||
'view_mailrule',
|
||||
'change_savedviewfilterrule',
|
||||
'change_log',
|
||||
'change_comment',
|
||||
'add_mailaccount',
|
||||
'add_frontendsettings',
|
||||
'add_userobjectpermission',
|
||||
'delete_note',
|
||||
'view_token',
|
||||
'add_failure',
|
||||
'delete_user',
|
||||
'add_success',
|
||||
'view_ormq',
|
||||
'view_tokenproxy',
|
||||
'delete_uisettings',
|
||||
'change_groupobjectpermission',
|
||||
'add_logentry',
|
||||
'add_ormq',
|
||||
'view_frontendsettings',
|
||||
'view_schedule',
|
||||
'change_taskattributes',
|
||||
'view_documenttype',
|
||||
'view_logentry',
|
||||
'change_correspondent',
|
||||
'add_groupresult',
|
||||
'delete_groupobjectpermission',
|
||||
'change_mailrule',
|
||||
'change_permission',
|
||||
'delete_log',
|
||||
'view_userobjectpermission',
|
||||
'view_correspondent',
|
||||
'delete_document',
|
||||
'change_uisettings',
|
||||
'change_storagepath',
|
||||
'change_document',
|
||||
'delete_tokenproxy',
|
||||
'change_note',
|
||||
'delete_permission',
|
||||
'change_contenttype',
|
||||
'add_token',
|
||||
'change_success',
|
||||
'delete_logentry',
|
||||
'view_savedviewfilterrule',
|
||||
'delete_task',
|
||||
'add_savedview',
|
||||
'add_paperlesstask',
|
||||
'add_task',
|
||||
'change_documenttype',
|
||||
'add_documenttype',
|
||||
'change_token',
|
||||
'view_task',
|
||||
'view_permission',
|
||||
'change_task',
|
||||
'delete_userobjectpermission',
|
||||
'change_group',
|
||||
'add_group',
|
||||
'change_tag',
|
||||
'change_chordcounter',
|
||||
'add_storagepath',
|
||||
'delete_group',
|
||||
'add_taskattributes',
|
||||
'delete_mailaccount',
|
||||
'delete_tag',
|
||||
'add_schedule',
|
||||
'delete_failure',
|
||||
'delete_mailrule',
|
||||
'add_savedviewfilterrule',
|
||||
'change_ormq',
|
||||
'change_logentry',
|
||||
'add_taskresult',
|
||||
'view_group',
|
||||
'delete_comment',
|
||||
'add_contenttype',
|
||||
'add_document',
|
||||
'change_tokenproxy',
|
||||
'delete_success',
|
||||
'add_comment',
|
||||
'delete_ormq',
|
||||
'add_processedmail',
|
||||
'view_paperlesstask',
|
||||
'delete_savedview',
|
||||
'change_user',
|
||||
'add_session',
|
||||
'view_groupobjectpermission',
|
||||
'add_user',
|
||||
'add_correspondent',
|
||||
'delete_taskresult',
|
||||
'view_contenttype',
|
||||
'view_storagepath',
|
||||
'add_permission',
|
||||
'change_userobjectpermission',
|
||||
'delete_savedviewfilterrule',
|
||||
'change_groupresult',
|
||||
'add_chordcounter',
|
||||
'view_log',
|
||||
'view_comment',
|
||||
'change_frontendsettings',
|
||||
],
|
||||
}
|
||||
|
||||
// run common tests
|
||||
commonAbstractNameFilterPaperlessServiceTests(endpoint, GroupService)
|
||||
|
||||
describe('Additional service tests for GroupService', () => {
|
||||
it('should retain permissions on update', () => {
|
||||
subscription = service.listAll().subscribe()
|
||||
let req = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}${endpoint}/?page=1&page_size=100000`
|
||||
)
|
||||
req.flush({
|
||||
results: [group],
|
||||
})
|
||||
subscription.unsubscribe()
|
||||
|
||||
subscription = service.update(group).subscribe()
|
||||
req = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}${endpoint}/${group.id}/`
|
||||
)
|
||||
expect(req.request.body.permissions).toHaveLength(group.permissions.length)
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
// Dont need to setup again
|
||||
|
||||
httpTestingController = TestBed.inject(HttpTestingController)
|
||||
service = TestBed.inject(GroupService)
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
subscription?.unsubscribe()
|
||||
httpTestingController.verify()
|
||||
})
|
||||
})
|
47
src-ui/src/app/services/rest/log.service.spec.ts
Normal file
47
src-ui/src/app/services/rest/log.service.spec.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import {
|
||||
HttpClientTestingModule,
|
||||
HttpTestingController,
|
||||
} from '@angular/common/http/testing'
|
||||
import { Subscription } from 'rxjs'
|
||||
import { TestBed } from '@angular/core/testing'
|
||||
import { environment } from 'src/environments/environment'
|
||||
import { LogService } from './log.service'
|
||||
|
||||
let httpTestingController: HttpTestingController
|
||||
let service: LogService
|
||||
let subscription: Subscription
|
||||
const endpoint = 'logs'
|
||||
|
||||
describe('LogService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [LogService],
|
||||
imports: [HttpClientTestingModule],
|
||||
})
|
||||
|
||||
httpTestingController = TestBed.inject(HttpTestingController)
|
||||
service = TestBed.inject(LogService)
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
subscription?.unsubscribe()
|
||||
httpTestingController.verify()
|
||||
})
|
||||
|
||||
it('should call correct api endpoint on logs list', () => {
|
||||
subscription = service.list().subscribe()
|
||||
const req = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}${endpoint}/`
|
||||
)
|
||||
expect(req.request.method).toEqual('GET')
|
||||
})
|
||||
|
||||
it('should call correct api endpoint on logs get', () => {
|
||||
const id: string = 'mail'
|
||||
subscription = service.get(id).subscribe()
|
||||
const req = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}${endpoint}/${id}/`
|
||||
)
|
||||
expect(req.request.method).toEqual('GET')
|
||||
})
|
||||
})
|
80
src-ui/src/app/services/rest/mail-account.service.spec.ts
Normal file
80
src-ui/src/app/services/rest/mail-account.service.spec.ts
Normal file
@@ -0,0 +1,80 @@
|
||||
import { HttpTestingController } from '@angular/common/http/testing'
|
||||
import { Subscription } from 'rxjs'
|
||||
import { TestBed } from '@angular/core/testing'
|
||||
import { environment } from 'src/environments/environment'
|
||||
import { commonAbstractPaperlessServiceTests } from './abstract-paperless-service.spec'
|
||||
import { MailAccountService } from './mail-account.service'
|
||||
import { IMAPSecurity } from 'src/app/data/paperless-mail-account'
|
||||
|
||||
let httpTestingController: HttpTestingController
|
||||
let service: MailAccountService
|
||||
let subscription: Subscription
|
||||
const endpoint = 'mail_accounts'
|
||||
const mail_accounts = [
|
||||
{
|
||||
name: 'Mail Account',
|
||||
id: 1,
|
||||
imap_server: 'imap.example.com',
|
||||
imap_port: 443,
|
||||
imap_security: IMAPSecurity.SSL,
|
||||
username: 'user',
|
||||
password: 'pass',
|
||||
is_token: false,
|
||||
},
|
||||
{
|
||||
name: 'Mail Account 2',
|
||||
id: 2,
|
||||
imap_server: 'imap.example.com',
|
||||
imap_port: 443,
|
||||
imap_security: IMAPSecurity.SSL,
|
||||
username: 'user',
|
||||
password: 'pass',
|
||||
is_token: false,
|
||||
},
|
||||
{
|
||||
name: 'Mail Account 3',
|
||||
id: 3,
|
||||
imap_server: 'imap.example.com',
|
||||
imap_port: 443,
|
||||
imap_security: IMAPSecurity.SSL,
|
||||
username: 'user',
|
||||
password: 'pass',
|
||||
is_token: false,
|
||||
},
|
||||
]
|
||||
|
||||
// run common tests
|
||||
commonAbstractPaperlessServiceTests(endpoint, MailAccountService)
|
||||
|
||||
describe(`Additional service tests for MailAccountService`, () => {
|
||||
it('should correct api endpoint on test account', () => {
|
||||
subscription = service.test(mail_accounts[0]).subscribe()
|
||||
const req = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}${endpoint}/test/`
|
||||
)
|
||||
expect(req.request.method).toEqual('POST')
|
||||
})
|
||||
|
||||
it('should support patchMany', () => {
|
||||
subscription = service.patchMany(mail_accounts).subscribe()
|
||||
mail_accounts.forEach((mail_account) => {
|
||||
const reqs = httpTestingController.match(
|
||||
`${environment.apiBaseUrl}${endpoint}/${mail_account.id}/`
|
||||
)
|
||||
expect(reqs).toHaveLength(1)
|
||||
expect(reqs[0].request.method).toEqual('PATCH')
|
||||
})
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
// Dont need to setup again
|
||||
|
||||
httpTestingController = TestBed.inject(HttpTestingController)
|
||||
service = TestBed.inject(MailAccountService)
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
subscription?.unsubscribe()
|
||||
httpTestingController.verify()
|
||||
})
|
||||
})
|
92
src-ui/src/app/services/rest/mail-rule.service.spec.ts
Normal file
92
src-ui/src/app/services/rest/mail-rule.service.spec.ts
Normal file
@@ -0,0 +1,92 @@
|
||||
import { HttpTestingController } from '@angular/common/http/testing'
|
||||
import { Subscription } from 'rxjs'
|
||||
import { TestBed } from '@angular/core/testing'
|
||||
import { environment } from 'src/environments/environment'
|
||||
import { commonAbstractPaperlessServiceTests } from './abstract-paperless-service.spec'
|
||||
import { MailRuleService } from './mail-rule.service'
|
||||
import { MailFilterAttachmentType } from 'src/app/data/paperless-mail-rule'
|
||||
import { MailMetadataTitleOption } from 'src/app/data/paperless-mail-rule'
|
||||
import { MailAction } from 'src/app/data/paperless-mail-rule'
|
||||
|
||||
let httpTestingController: HttpTestingController
|
||||
let service: MailRuleService
|
||||
let subscription: Subscription
|
||||
const endpoint = 'mail_rules'
|
||||
const mail_rules = [
|
||||
{
|
||||
name: 'Mail Rule',
|
||||
id: 1,
|
||||
account: 1,
|
||||
order: 1,
|
||||
folder: 'INBOX',
|
||||
filter_from: null,
|
||||
filter_to: null,
|
||||
filter_subject: null,
|
||||
filter_body: null,
|
||||
filter_attachment_filename: null,
|
||||
maximum_age: 30,
|
||||
attachment_type: MailFilterAttachmentType.Everything,
|
||||
action: MailAction.MarkRead,
|
||||
assign_title_from: MailMetadataTitleOption.FromSubject,
|
||||
},
|
||||
{
|
||||
name: 'Mail Rule 2',
|
||||
id: 2,
|
||||
account: 1,
|
||||
order: 1,
|
||||
folder: 'INBOX',
|
||||
filter_from: null,
|
||||
filter_to: null,
|
||||
filter_subject: null,
|
||||
filter_body: null,
|
||||
filter_attachment_filename: null,
|
||||
maximum_age: 30,
|
||||
attachment_type: MailFilterAttachmentType.Everything,
|
||||
action: MailAction.Delete,
|
||||
assign_title_from: MailMetadataTitleOption.FromSubject,
|
||||
},
|
||||
{
|
||||
name: 'Mail Rule 3',
|
||||
id: 3,
|
||||
account: 1,
|
||||
order: 1,
|
||||
folder: 'INBOX',
|
||||
filter_from: null,
|
||||
filter_to: null,
|
||||
filter_subject: null,
|
||||
filter_body: null,
|
||||
filter_attachment_filename: null,
|
||||
maximum_age: 30,
|
||||
attachment_type: MailFilterAttachmentType.Everything,
|
||||
action: MailAction.Flag,
|
||||
assign_title_from: MailMetadataTitleOption.FromSubject,
|
||||
},
|
||||
]
|
||||
|
||||
// run common tests
|
||||
commonAbstractPaperlessServiceTests(endpoint, MailRuleService)
|
||||
|
||||
describe(`Additional service tests for MailRuleService`, () => {
|
||||
it('should support patchMany', () => {
|
||||
subscription = service.patchMany(mail_rules).subscribe()
|
||||
mail_rules.forEach((mail_rule) => {
|
||||
const reqs = httpTestingController.match(
|
||||
`${environment.apiBaseUrl}${endpoint}/${mail_rule.id}/`
|
||||
)
|
||||
expect(reqs).toHaveLength(1)
|
||||
expect(reqs[0].request.method).toEqual('PATCH')
|
||||
})
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
// Dont need to setup again
|
||||
|
||||
httpTestingController = TestBed.inject(HttpTestingController)
|
||||
service = TestBed.inject(MailRuleService)
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
subscription?.unsubscribe()
|
||||
httpTestingController.verify()
|
||||
})
|
||||
})
|
38
src-ui/src/app/services/rest/remote-version.service.spec.ts
Normal file
38
src-ui/src/app/services/rest/remote-version.service.spec.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import {
|
||||
HttpClientTestingModule,
|
||||
HttpTestingController,
|
||||
} from '@angular/common/http/testing'
|
||||
import { Subscription } from 'rxjs'
|
||||
import { TestBed } from '@angular/core/testing'
|
||||
import { environment } from 'src/environments/environment'
|
||||
import { RemoteVersionService } from './remote-version.service'
|
||||
|
||||
let httpTestingController: HttpTestingController
|
||||
let service: RemoteVersionService
|
||||
let subscription: Subscription
|
||||
const endpoint = 'remote_version'
|
||||
|
||||
describe('RemoteVersionService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [RemoteVersionService],
|
||||
imports: [HttpClientTestingModule],
|
||||
})
|
||||
|
||||
httpTestingController = TestBed.inject(HttpTestingController)
|
||||
service = TestBed.inject(RemoteVersionService)
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
subscription?.unsubscribe()
|
||||
httpTestingController.verify()
|
||||
})
|
||||
|
||||
it('should call correct api endpoint on update check', () => {
|
||||
subscription = service.checkForUpdates().subscribe()
|
||||
const req = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}${endpoint}/`
|
||||
)
|
||||
expect(req.request.method).toEqual('GET')
|
||||
})
|
||||
})
|
81
src-ui/src/app/services/rest/saved-view.service.spec.ts
Normal file
81
src-ui/src/app/services/rest/saved-view.service.spec.ts
Normal file
@@ -0,0 +1,81 @@
|
||||
import { HttpTestingController } from '@angular/common/http/testing'
|
||||
import { Subscription } from 'rxjs'
|
||||
import { TestBed } from '@angular/core/testing'
|
||||
import { environment } from 'src/environments/environment'
|
||||
import { commonAbstractPaperlessServiceTests } from './abstract-paperless-service.spec'
|
||||
import { SavedViewService } from './saved-view.service'
|
||||
|
||||
let httpTestingController: HttpTestingController
|
||||
let service: SavedViewService
|
||||
let subscription: Subscription
|
||||
const endpoint = 'saved_views'
|
||||
const saved_views = [
|
||||
{
|
||||
name: 'Saved View',
|
||||
id: 1,
|
||||
show_on_dashboard: true,
|
||||
show_in_sidebar: true,
|
||||
sort_field: 'name',
|
||||
sort_reverse: true,
|
||||
filter_rules: [],
|
||||
},
|
||||
{
|
||||
name: 'Saved View 2',
|
||||
id: 2,
|
||||
show_on_dashboard: false,
|
||||
show_in_sidebar: false,
|
||||
sort_field: 'name',
|
||||
sort_reverse: true,
|
||||
filter_rules: [],
|
||||
},
|
||||
{
|
||||
name: 'Saved View 3',
|
||||
id: 3,
|
||||
show_on_dashboard: true,
|
||||
show_in_sidebar: false,
|
||||
sort_field: 'name',
|
||||
sort_reverse: true,
|
||||
filter_rules: [],
|
||||
},
|
||||
]
|
||||
|
||||
// run common tests
|
||||
commonAbstractPaperlessServiceTests(endpoint, SavedViewService)
|
||||
|
||||
describe(`Additional service tests for SavedViewService`, () => {
|
||||
it('should retrieve saved views and sort them', () => {
|
||||
service.initialize()
|
||||
const req = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}${endpoint}/?page=1&page_size=100000`
|
||||
)
|
||||
req.flush({
|
||||
results: saved_views,
|
||||
})
|
||||
expect(service.allViews).toHaveLength(3)
|
||||
expect(service.dashboardViews).toHaveLength(2)
|
||||
expect(service.sidebarViews).toHaveLength(1)
|
||||
})
|
||||
|
||||
it('should support patchMany', () => {
|
||||
subscription = service.patchMany(saved_views).subscribe()
|
||||
saved_views.forEach((saved_view) => {
|
||||
const reqs = httpTestingController.match(
|
||||
`${environment.apiBaseUrl}${endpoint}/${saved_view.id}/`
|
||||
)
|
||||
expect(reqs).toHaveLength(1)
|
||||
expect(reqs[0].request.method).toEqual('PATCH')
|
||||
})
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
// Dont need to setup again
|
||||
|
||||
httpTestingController = TestBed.inject(HttpTestingController)
|
||||
service = TestBed.inject(SavedViewService)
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
subscription?.unsubscribe()
|
||||
httpTestingController.verify()
|
||||
})
|
||||
})
|
39
src-ui/src/app/services/rest/search.service.spec.ts
Normal file
39
src-ui/src/app/services/rest/search.service.spec.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import {
|
||||
HttpClientTestingModule,
|
||||
HttpTestingController,
|
||||
} from '@angular/common/http/testing'
|
||||
import { Subscription } from 'rxjs'
|
||||
import { TestBed } from '@angular/core/testing'
|
||||
import { environment } from 'src/environments/environment'
|
||||
import { SearchService } from './search.service'
|
||||
|
||||
let httpTestingController: HttpTestingController
|
||||
let service: SearchService
|
||||
let subscription: Subscription
|
||||
const endpoint = 'search/autocomplete'
|
||||
|
||||
describe('SearchService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [SearchService],
|
||||
imports: [HttpClientTestingModule],
|
||||
})
|
||||
|
||||
httpTestingController = TestBed.inject(HttpTestingController)
|
||||
service = TestBed.inject(SearchService)
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
subscription?.unsubscribe()
|
||||
httpTestingController.verify()
|
||||
})
|
||||
|
||||
it('should call correct api endpoint on autocomplete', () => {
|
||||
const term = 'apple'
|
||||
subscription = service.autocomplete(term).subscribe()
|
||||
const req = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}${endpoint}/?term=${term}`
|
||||
)
|
||||
expect(req.request.method).toEqual('GET')
|
||||
})
|
||||
})
|
@@ -0,0 +1,7 @@
|
||||
import { StoragePathService } from './storage-path.service'
|
||||
import { commonAbstractNameFilterPaperlessServiceTests } from './abstract-name-filter-service.spec'
|
||||
|
||||
commonAbstractNameFilterPaperlessServiceTests(
|
||||
'storage_paths',
|
||||
StoragePathService
|
||||
)
|
4
src-ui/src/app/services/rest/tag.service.spec.ts
Normal file
4
src-ui/src/app/services/rest/tag.service.spec.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import { TagService } from './tag.service'
|
||||
import { commonAbstractNameFilterPaperlessServiceTests } from './abstract-name-filter-service.spec'
|
||||
|
||||
commonAbstractNameFilterPaperlessServiceTests('tags', TagService)
|
193
src-ui/src/app/services/rest/user.service.spec.ts
Normal file
193
src-ui/src/app/services/rest/user.service.spec.ts
Normal file
@@ -0,0 +1,193 @@
|
||||
import { HttpTestingController } from '@angular/common/http/testing'
|
||||
import { Subscription } from 'rxjs'
|
||||
import { TestBed } from '@angular/core/testing'
|
||||
import { environment } from 'src/environments/environment'
|
||||
import { commonAbstractNameFilterPaperlessServiceTests } from './abstract-name-filter-service.spec'
|
||||
import { UserService } from './user.service'
|
||||
|
||||
let httpTestingController: HttpTestingController
|
||||
let service: UserService
|
||||
let subscription: Subscription
|
||||
const endpoint = 'users'
|
||||
const user = {
|
||||
username: 'username',
|
||||
id: 1,
|
||||
user_permissions: [
|
||||
'change_savedview',
|
||||
'change_schedule',
|
||||
'change_failure',
|
||||
'delete_token',
|
||||
'add_mailrule',
|
||||
'view_failure',
|
||||
'view_groupresult',
|
||||
'add_note',
|
||||
'change_taskresult',
|
||||
'view_tag',
|
||||
'view_user',
|
||||
'add_tag',
|
||||
'change_processedmail',
|
||||
'change_session',
|
||||
'view_taskattributes',
|
||||
'delete_groupresult',
|
||||
'delete_correspondent',
|
||||
'delete_schedule',
|
||||
'delete_contenttype',
|
||||
'view_chordcounter',
|
||||
'view_success',
|
||||
'delete_documenttype',
|
||||
'add_tokenproxy',
|
||||
'delete_paperlesstask',
|
||||
'add_log',
|
||||
'view_mailaccount',
|
||||
'add_uisettings',
|
||||
'view_savedview',
|
||||
'view_uisettings',
|
||||
'delete_storagepath',
|
||||
'delete_frontendsettings',
|
||||
'change_paperlesstask',
|
||||
'view_taskresult',
|
||||
'delete_processedmail',
|
||||
'view_processedmail',
|
||||
'view_session',
|
||||
'delete_chordcounter',
|
||||
'view_note',
|
||||
'delete_session',
|
||||
'view_document',
|
||||
'change_mailaccount',
|
||||
'delete_taskattributes',
|
||||
'add_groupobjectpermission',
|
||||
'view_mailrule',
|
||||
'change_savedviewfilterrule',
|
||||
'change_log',
|
||||
'change_comment',
|
||||
'add_mailaccount',
|
||||
'add_frontendsettings',
|
||||
'add_userobjectpermission',
|
||||
'delete_note',
|
||||
'view_token',
|
||||
'add_failure',
|
||||
'delete_user',
|
||||
'add_success',
|
||||
'view_ormq',
|
||||
'view_tokenproxy',
|
||||
'delete_uisettings',
|
||||
'change_groupobjectpermission',
|
||||
'add_logentry',
|
||||
'add_ormq',
|
||||
'view_frontendsettings',
|
||||
'view_schedule',
|
||||
'change_taskattributes',
|
||||
'view_documenttype',
|
||||
'view_logentry',
|
||||
'change_correspondent',
|
||||
'add_groupresult',
|
||||
'delete_groupobjectpermission',
|
||||
'change_mailrule',
|
||||
'change_permission',
|
||||
'delete_log',
|
||||
'view_userobjectpermission',
|
||||
'view_correspondent',
|
||||
'delete_document',
|
||||
'change_uisettings',
|
||||
'change_storagepath',
|
||||
'change_document',
|
||||
'delete_tokenproxy',
|
||||
'change_note',
|
||||
'delete_permission',
|
||||
'change_contenttype',
|
||||
'add_token',
|
||||
'change_success',
|
||||
'delete_logentry',
|
||||
'view_savedviewfilterrule',
|
||||
'delete_task',
|
||||
'add_savedview',
|
||||
'add_paperlesstask',
|
||||
'add_task',
|
||||
'change_documenttype',
|
||||
'add_documenttype',
|
||||
'change_token',
|
||||
'view_task',
|
||||
'view_permission',
|
||||
'change_task',
|
||||
'delete_userobjectpermission',
|
||||
'change_group',
|
||||
'add_group',
|
||||
'change_tag',
|
||||
'change_chordcounter',
|
||||
'add_storagepath',
|
||||
'delete_group',
|
||||
'add_taskattributes',
|
||||
'delete_mailaccount',
|
||||
'delete_tag',
|
||||
'add_schedule',
|
||||
'delete_failure',
|
||||
'delete_mailrule',
|
||||
'add_savedviewfilterrule',
|
||||
'change_ormq',
|
||||
'change_logentry',
|
||||
'add_taskresult',
|
||||
'view_group',
|
||||
'delete_comment',
|
||||
'add_contenttype',
|
||||
'add_document',
|
||||
'change_tokenproxy',
|
||||
'delete_success',
|
||||
'add_comment',
|
||||
'delete_ormq',
|
||||
'add_processedmail',
|
||||
'view_paperlesstask',
|
||||
'delete_savedview',
|
||||
'change_user',
|
||||
'add_session',
|
||||
'view_groupobjectpermission',
|
||||
'add_user',
|
||||
'add_correspondent',
|
||||
'delete_taskresult',
|
||||
'view_contenttype',
|
||||
'view_storagepath',
|
||||
'add_permission',
|
||||
'change_userobjectpermission',
|
||||
'delete_savedviewfilterrule',
|
||||
'change_groupresult',
|
||||
'add_chordcounter',
|
||||
'view_log',
|
||||
'view_comment',
|
||||
'change_frontendsettings',
|
||||
],
|
||||
}
|
||||
|
||||
// run common tests
|
||||
commonAbstractNameFilterPaperlessServiceTests(endpoint, UserService)
|
||||
|
||||
describe('Additional service tests for UserService', () => {
|
||||
it('should retain permissions on update', () => {
|
||||
subscription = service.listAll().subscribe()
|
||||
let req = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}${endpoint}/?page=1&page_size=100000`
|
||||
)
|
||||
req.flush({
|
||||
results: [user],
|
||||
})
|
||||
subscription.unsubscribe()
|
||||
|
||||
subscription = service.update(user).subscribe()
|
||||
req = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}${endpoint}/${user.id}/`
|
||||
)
|
||||
expect(req.request.body.user_permissions).toHaveLength(
|
||||
user.user_permissions.length
|
||||
)
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
// Dont need to setup again
|
||||
|
||||
httpTestingController = TestBed.inject(HttpTestingController)
|
||||
service = TestBed.inject(UserService)
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
subscription?.unsubscribe()
|
||||
httpTestingController.verify()
|
||||
})
|
||||
})
|
Reference in New Issue
Block a user