Feature: live preview of storage path (#7870)

This commit is contained in:
shamoon
2024-10-09 16:35:36 -07:00
committed by GitHub
parent 8dd355f6bf
commit 024b60638a
15 changed files with 426 additions and 54 deletions

View File

@@ -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')
})
})

View File

@@ -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,
})
}
}