mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-30 18:27:45 -05:00
Feature: live preview of storage path (#7870)
This commit is contained in:
@@ -1,7 +1,35 @@
|
||||
import { StoragePathService } from './storage-path.service'
|
||||
import { commonAbstractNameFilterPaperlessServiceTests } from './abstract-name-filter-service.spec'
|
||||
import { Subscription } from 'rxjs'
|
||||
import { HttpTestingController } from '@angular/common/http/testing'
|
||||
import { TestBed } from '@angular/core/testing'
|
||||
import { environment } from 'src/environments/environment'
|
||||
|
||||
let httpTestingController: HttpTestingController
|
||||
let service: StoragePathService
|
||||
let subscription: Subscription
|
||||
const endpoint = 'storage_paths'
|
||||
|
||||
commonAbstractNameFilterPaperlessServiceTests(
|
||||
'storage_paths',
|
||||
StoragePathService
|
||||
)
|
||||
|
||||
describe(`Additional service tests for StoragePathservice`, () => {
|
||||
beforeEach(() => {
|
||||
httpTestingController = TestBed.inject(HttpTestingController)
|
||||
service = TestBed.inject(StoragePathService)
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
subscription?.unsubscribe()
|
||||
httpTestingController.verify()
|
||||
})
|
||||
|
||||
it('should support testing path', () => {
|
||||
subscription = service.testPath('path', 11).subscribe()
|
||||
httpTestingController
|
||||
.expectOne(`${environment.apiBaseUrl}${endpoint}/test/`)
|
||||
.flush('ok')
|
||||
})
|
||||
})
|
||||
|
@@ -2,6 +2,7 @@ import { HttpClient } from '@angular/common/http'
|
||||
import { Injectable } from '@angular/core'
|
||||
import { StoragePath } from 'src/app/data/storage-path'
|
||||
import { AbstractNameFilterService } from './abstract-name-filter-service'
|
||||
import { Observable } from 'rxjs'
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
@@ -10,4 +11,11 @@ export class StoragePathService extends AbstractNameFilterService<StoragePath> {
|
||||
constructor(http: HttpClient) {
|
||||
super(http, 'storage_paths')
|
||||
}
|
||||
|
||||
public testPath(path: string, documentID: number): Observable<any> {
|
||||
return this.http.post<string>(`${this.getResourceUrl()}test/`, {
|
||||
path,
|
||||
document: documentID,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user