|
|
|
|
@@ -126,13 +126,10 @@ describe('DocumentListViewService', () => {
|
|
|
|
|
expect(documentListViewService.currentPage).toEqual(1)
|
|
|
|
|
documentListViewService.reload()
|
|
|
|
|
const req = httpTestingController.expectOne(
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true`
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true&include_selection_data=true`
|
|
|
|
|
)
|
|
|
|
|
expect(req.request.method).toEqual('GET')
|
|
|
|
|
req.flush(full_results)
|
|
|
|
|
httpTestingController.expectOne(
|
|
|
|
|
`${environment.apiBaseUrl}documents/selection_data/`
|
|
|
|
|
)
|
|
|
|
|
expect(req.request.method).toEqual('GET')
|
|
|
|
|
expect(documentListViewService.isReloading).toBeFalsy()
|
|
|
|
|
expect(documentListViewService.activeSavedViewId).toBeNull()
|
|
|
|
|
@@ -144,12 +141,12 @@ describe('DocumentListViewService', () => {
|
|
|
|
|
it('should handle error on page request out of range', () => {
|
|
|
|
|
documentListViewService.currentPage = 50
|
|
|
|
|
let req = httpTestingController.expectOne(
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=50&page_size=50&ordering=-created&truncate_content=true`
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=50&page_size=50&ordering=-created&truncate_content=true&include_selection_data=true`
|
|
|
|
|
)
|
|
|
|
|
expect(req.request.method).toEqual('GET')
|
|
|
|
|
req.flush([], { status: 404, statusText: 'Unexpected error' })
|
|
|
|
|
req = httpTestingController.expectOne(
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true`
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true&include_selection_data=true`
|
|
|
|
|
)
|
|
|
|
|
expect(req.request.method).toEqual('GET')
|
|
|
|
|
expect(documentListViewService.currentPage).toEqual(1)
|
|
|
|
|
@@ -166,7 +163,7 @@ describe('DocumentListViewService', () => {
|
|
|
|
|
]
|
|
|
|
|
documentListViewService.setFilterRules(filterRulesAny)
|
|
|
|
|
let req = httpTestingController.expectOne(
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true&tags__id__in=${tags__id__in}`
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true&include_selection_data=true&tags__id__in=${tags__id__in}`
|
|
|
|
|
)
|
|
|
|
|
expect(req.request.method).toEqual('GET')
|
|
|
|
|
req.flush(
|
|
|
|
|
@@ -174,13 +171,13 @@ describe('DocumentListViewService', () => {
|
|
|
|
|
{ status: 404, statusText: 'Unexpected error' }
|
|
|
|
|
)
|
|
|
|
|
req = httpTestingController.expectOne(
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true`
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true&include_selection_data=true`
|
|
|
|
|
)
|
|
|
|
|
expect(req.request.method).toEqual('GET')
|
|
|
|
|
// reset the list
|
|
|
|
|
documentListViewService.setFilterRules([])
|
|
|
|
|
req = httpTestingController.expectOne(
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true`
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true&include_selection_data=true`
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
@@ -188,7 +185,7 @@ describe('DocumentListViewService', () => {
|
|
|
|
|
documentListViewService.currentPage = 1
|
|
|
|
|
documentListViewService.sortField = 'custom_field_999'
|
|
|
|
|
let req = httpTestingController.expectOne(
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-custom_field_999&truncate_content=true`
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-custom_field_999&truncate_content=true&include_selection_data=true`
|
|
|
|
|
)
|
|
|
|
|
expect(req.request.method).toEqual('GET')
|
|
|
|
|
req.flush(
|
|
|
|
|
@@ -197,7 +194,7 @@ describe('DocumentListViewService', () => {
|
|
|
|
|
)
|
|
|
|
|
// resets itself
|
|
|
|
|
req = httpTestingController.expectOne(
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true`
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true&include_selection_data=true`
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
@@ -212,7 +209,7 @@ describe('DocumentListViewService', () => {
|
|
|
|
|
]
|
|
|
|
|
documentListViewService.setFilterRules(filterRulesAny)
|
|
|
|
|
let req = httpTestingController.expectOne(
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true&tags__id__in=${tags__id__in}`
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true&include_selection_data=true&tags__id__in=${tags__id__in}`
|
|
|
|
|
)
|
|
|
|
|
expect(req.request.method).toEqual('GET')
|
|
|
|
|
req.flush('Generic error', { status: 404, statusText: 'Unexpected error' })
|
|
|
|
|
@@ -220,7 +217,7 @@ describe('DocumentListViewService', () => {
|
|
|
|
|
// reset the list
|
|
|
|
|
documentListViewService.setFilterRules([])
|
|
|
|
|
req = httpTestingController.expectOne(
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true`
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true&include_selection_data=true`
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
@@ -229,7 +226,7 @@ describe('DocumentListViewService', () => {
|
|
|
|
|
expect(documentListViewService.sortReverse).toBeTruthy()
|
|
|
|
|
documentListViewService.setSort('added', false)
|
|
|
|
|
let req = httpTestingController.expectOne(
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=added&truncate_content=true`
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=added&truncate_content=true&include_selection_data=true`
|
|
|
|
|
)
|
|
|
|
|
expect(req.request.method).toEqual('GET')
|
|
|
|
|
expect(documentListViewService.sortField).toEqual('added')
|
|
|
|
|
@@ -237,12 +234,12 @@ describe('DocumentListViewService', () => {
|
|
|
|
|
|
|
|
|
|
documentListViewService.sortField = 'created'
|
|
|
|
|
req = httpTestingController.expectOne(
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=created&truncate_content=true`
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=created&truncate_content=true&include_selection_data=true`
|
|
|
|
|
)
|
|
|
|
|
expect(documentListViewService.sortField).toEqual('created')
|
|
|
|
|
documentListViewService.sortReverse = true
|
|
|
|
|
req = httpTestingController.expectOne(
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true`
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true&include_selection_data=true`
|
|
|
|
|
)
|
|
|
|
|
expect(req.request.method).toEqual('GET')
|
|
|
|
|
expect(documentListViewService.sortReverse).toBeTruthy()
|
|
|
|
|
@@ -262,7 +259,7 @@ describe('DocumentListViewService', () => {
|
|
|
|
|
const req = httpTestingController.expectOne(
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=${page}&page_size=${
|
|
|
|
|
documentListViewService.pageSize
|
|
|
|
|
}&ordering=${reverse ? '-' : ''}${sort}&truncate_content=true`
|
|
|
|
|
}&ordering=${reverse ? '-' : ''}${sort}&truncate_content=true&include_selection_data=true`
|
|
|
|
|
)
|
|
|
|
|
expect(req.request.method).toEqual('GET')
|
|
|
|
|
expect(documentListViewService.currentPage).toEqual(page)
|
|
|
|
|
@@ -279,7 +276,7 @@ describe('DocumentListViewService', () => {
|
|
|
|
|
}
|
|
|
|
|
documentListViewService.loadFromQueryParams(convertToParamMap(params))
|
|
|
|
|
let req = httpTestingController.expectOne(
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=${documentListViewService.currentPage}&page_size=${documentListViewService.pageSize}&ordering=-added&truncate_content=true&tags__id__all=${tags__id__all}`
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=${documentListViewService.currentPage}&page_size=${documentListViewService.pageSize}&ordering=-added&truncate_content=true&include_selection_data=true&tags__id__all=${tags__id__all}`
|
|
|
|
|
)
|
|
|
|
|
expect(req.request.method).toEqual('GET')
|
|
|
|
|
expect(documentListViewService.filterRules).toEqual([
|
|
|
|
|
@@ -289,15 +286,12 @@ describe('DocumentListViewService', () => {
|
|
|
|
|
},
|
|
|
|
|
])
|
|
|
|
|
req.flush(full_results)
|
|
|
|
|
httpTestingController.expectOne(
|
|
|
|
|
`${environment.apiBaseUrl}documents/selection_data/`
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('should use filter rules to update query params', () => {
|
|
|
|
|
documentListViewService.setFilterRules(filterRules)
|
|
|
|
|
const req = httpTestingController.expectOne(
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=${documentListViewService.currentPage}&page_size=${documentListViewService.pageSize}&ordering=-created&truncate_content=true&tags__id__all=${tags__id__all}`
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=${documentListViewService.currentPage}&page_size=${documentListViewService.pageSize}&ordering=-created&truncate_content=true&include_selection_data=true&tags__id__all=${tags__id__all}`
|
|
|
|
|
)
|
|
|
|
|
expect(req.request.method).toEqual('GET')
|
|
|
|
|
})
|
|
|
|
|
@@ -306,34 +300,26 @@ describe('DocumentListViewService', () => {
|
|
|
|
|
documentListViewService.currentPage = 2
|
|
|
|
|
let req = httpTestingController.expectOne((request) =>
|
|
|
|
|
request.urlWithParams.startsWith(
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=2&page_size=50&ordering=-created&truncate_content=true`
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=2&page_size=50&ordering=-created&truncate_content=true&include_selection_data=true`
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
expect(req.request.method).toEqual('GET')
|
|
|
|
|
req.flush(full_results)
|
|
|
|
|
req = httpTestingController.expectOne(
|
|
|
|
|
`${environment.apiBaseUrl}documents/selection_data/`
|
|
|
|
|
)
|
|
|
|
|
req.flush([])
|
|
|
|
|
|
|
|
|
|
documentListViewService.setFilterRules(filterRules, true)
|
|
|
|
|
|
|
|
|
|
const filteredReqs = httpTestingController.match(
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true&tags__id__all=${tags__id__all}`
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true&include_selection_data=true&tags__id__all=${tags__id__all}`
|
|
|
|
|
)
|
|
|
|
|
expect(filteredReqs).toHaveLength(1)
|
|
|
|
|
filteredReqs[0].flush(full_results)
|
|
|
|
|
req = httpTestingController.expectOne(
|
|
|
|
|
`${environment.apiBaseUrl}documents/selection_data/`
|
|
|
|
|
)
|
|
|
|
|
req.flush([])
|
|
|
|
|
expect(documentListViewService.currentPage).toEqual(1)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('should support quick filter', () => {
|
|
|
|
|
documentListViewService.quickFilter(filterRules)
|
|
|
|
|
const req = httpTestingController.expectOne(
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=${documentListViewService.currentPage}&page_size=${documentListViewService.pageSize}&ordering=-created&truncate_content=true&tags__id__all=${tags__id__all}`
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=${documentListViewService.currentPage}&page_size=${documentListViewService.pageSize}&ordering=-created&truncate_content=true&include_selection_data=true&tags__id__all=${tags__id__all}`
|
|
|
|
|
)
|
|
|
|
|
expect(req.request.method).toEqual('GET')
|
|
|
|
|
})
|
|
|
|
|
@@ -356,21 +342,21 @@ describe('DocumentListViewService', () => {
|
|
|
|
|
convertToParamMap(params)
|
|
|
|
|
)
|
|
|
|
|
let req = httpTestingController.expectOne(
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=${page}&page_size=${documentListViewService.pageSize}&ordering=-added&truncate_content=true&tags__id__all=${tags__id__all}`
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=${page}&page_size=${documentListViewService.pageSize}&ordering=-added&truncate_content=true&include_selection_data=true&tags__id__all=${tags__id__all}`
|
|
|
|
|
)
|
|
|
|
|
expect(req.request.method).toEqual('GET')
|
|
|
|
|
// reset the list
|
|
|
|
|
documentListViewService.currentPage = 1
|
|
|
|
|
req = httpTestingController.expectOne(
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-added&truncate_content=true&tags__id__all=9`
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-added&truncate_content=true&include_selection_data=true&tags__id__all=9`
|
|
|
|
|
)
|
|
|
|
|
documentListViewService.setFilterRules([])
|
|
|
|
|
req = httpTestingController.expectOne(
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-added&truncate_content=true`
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-added&truncate_content=true&include_selection_data=true`
|
|
|
|
|
)
|
|
|
|
|
documentListViewService.sortField = 'created'
|
|
|
|
|
req = httpTestingController.expectOne(
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true`
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true&include_selection_data=true`
|
|
|
|
|
)
|
|
|
|
|
documentListViewService.activateSavedView(null)
|
|
|
|
|
})
|
|
|
|
|
@@ -378,21 +364,18 @@ describe('DocumentListViewService', () => {
|
|
|
|
|
it('should support navigating next / previous', () => {
|
|
|
|
|
documentListViewService.setFilterRules([])
|
|
|
|
|
let req = httpTestingController.expectOne(
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true`
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true&include_selection_data=true`
|
|
|
|
|
)
|
|
|
|
|
expect(documentListViewService.currentPage).toEqual(1)
|
|
|
|
|
documentListViewService.pageSize = 3
|
|
|
|
|
req = httpTestingController.expectOne(
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=3&ordering=-created&truncate_content=true`
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=3&ordering=-created&truncate_content=true&include_selection_data=true`
|
|
|
|
|
)
|
|
|
|
|
expect(req.request.method).toEqual('GET')
|
|
|
|
|
req.flush({
|
|
|
|
|
count: 3,
|
|
|
|
|
results: documents.slice(0, 3),
|
|
|
|
|
})
|
|
|
|
|
httpTestingController
|
|
|
|
|
.expectOne(`${environment.apiBaseUrl}documents/selection_data/`)
|
|
|
|
|
.flush([])
|
|
|
|
|
expect(documentListViewService.hasNext(documents[0].id)).toBeTruthy()
|
|
|
|
|
expect(documentListViewService.hasPrevious(documents[0].id)).toBeFalsy()
|
|
|
|
|
documentListViewService.getNext(documents[0].id).subscribe((docId) => {
|
|
|
|
|
@@ -439,7 +422,7 @@ describe('DocumentListViewService', () => {
|
|
|
|
|
expect(documentListViewService.currentPage).toEqual(1)
|
|
|
|
|
documentListViewService.pageSize = 3
|
|
|
|
|
httpTestingController.match(
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=3&ordering=-created&truncate_content=true`
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=3&ordering=-created&truncate_content=true&include_selection_data=true`
|
|
|
|
|
)
|
|
|
|
|
jest
|
|
|
|
|
.spyOn(documentListViewService, 'getLastPage')
|
|
|
|
|
@@ -454,7 +437,7 @@ describe('DocumentListViewService', () => {
|
|
|
|
|
expect(reloadSpy).toHaveBeenCalled()
|
|
|
|
|
expect(documentListViewService.currentPage).toEqual(2)
|
|
|
|
|
const reqs = httpTestingController.match(
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=2&page_size=3&ordering=-created&truncate_content=true`
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=2&page_size=3&ordering=-created&truncate_content=true&include_selection_data=true`
|
|
|
|
|
)
|
|
|
|
|
expect(reqs.length).toBeGreaterThan(0)
|
|
|
|
|
})
|
|
|
|
|
@@ -489,11 +472,11 @@ describe('DocumentListViewService', () => {
|
|
|
|
|
.mockReturnValue(documents)
|
|
|
|
|
documentListViewService.currentPage = 2
|
|
|
|
|
httpTestingController.match(
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=2&page_size=50&ordering=-created&truncate_content=true`
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=2&page_size=50&ordering=-created&truncate_content=true&include_selection_data=true`
|
|
|
|
|
)
|
|
|
|
|
documentListViewService.pageSize = 3
|
|
|
|
|
httpTestingController.match(
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=2&page_size=3&ordering=-created&truncate_content=true`
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=2&page_size=3&ordering=-created&truncate_content=true&include_selection_data=true`
|
|
|
|
|
)
|
|
|
|
|
const reloadSpy = jest.spyOn(documentListViewService, 'reload')
|
|
|
|
|
documentListViewService.getPrevious(1).subscribe({
|
|
|
|
|
@@ -503,7 +486,7 @@ describe('DocumentListViewService', () => {
|
|
|
|
|
expect(reloadSpy).toHaveBeenCalled()
|
|
|
|
|
expect(documentListViewService.currentPage).toEqual(1)
|
|
|
|
|
const reqs = httpTestingController.match(
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=3&ordering=-created&truncate_content=true`
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=3&ordering=-created&truncate_content=true&include_selection_data=true`
|
|
|
|
|
)
|
|
|
|
|
expect(reqs.length).toBeGreaterThan(0)
|
|
|
|
|
})
|
|
|
|
|
@@ -516,13 +499,10 @@ describe('DocumentListViewService', () => {
|
|
|
|
|
it('should support select a document', () => {
|
|
|
|
|
documentListViewService.reload()
|
|
|
|
|
const req = httpTestingController.expectOne(
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true`
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true&include_selection_data=true`
|
|
|
|
|
)
|
|
|
|
|
expect(req.request.method).toEqual('GET')
|
|
|
|
|
req.flush(full_results)
|
|
|
|
|
httpTestingController.expectOne(
|
|
|
|
|
`${environment.apiBaseUrl}documents/selection_data/`
|
|
|
|
|
)
|
|
|
|
|
documentListViewService.toggleSelected(documents[0])
|
|
|
|
|
expect(documentListViewService.isSelected(documents[0])).toBeTruthy()
|
|
|
|
|
documentListViewService.toggleSelected(documents[0])
|
|
|
|
|
@@ -544,16 +524,13 @@ describe('DocumentListViewService', () => {
|
|
|
|
|
it('should support select page', () => {
|
|
|
|
|
documentListViewService.pageSize = 3
|
|
|
|
|
const req = httpTestingController.expectOne(
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=3&ordering=-created&truncate_content=true`
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=3&ordering=-created&truncate_content=true&include_selection_data=true`
|
|
|
|
|
)
|
|
|
|
|
expect(req.request.method).toEqual('GET')
|
|
|
|
|
req.flush({
|
|
|
|
|
count: 3,
|
|
|
|
|
results: documents.slice(0, 3),
|
|
|
|
|
})
|
|
|
|
|
httpTestingController.expectOne(
|
|
|
|
|
`${environment.apiBaseUrl}documents/selection_data/`
|
|
|
|
|
)
|
|
|
|
|
documentListViewService.selectPage()
|
|
|
|
|
expect(documentListViewService.selected.size).toEqual(3)
|
|
|
|
|
expect(documentListViewService.isSelected(documents[5])).toBeFalsy()
|
|
|
|
|
@@ -562,13 +539,10 @@ describe('DocumentListViewService', () => {
|
|
|
|
|
it('should support select range', () => {
|
|
|
|
|
documentListViewService.reload()
|
|
|
|
|
const req = httpTestingController.expectOne(
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true`
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true&include_selection_data=true`
|
|
|
|
|
)
|
|
|
|
|
expect(req.request.method).toEqual('GET')
|
|
|
|
|
req.flush(full_results)
|
|
|
|
|
httpTestingController.expectOne(
|
|
|
|
|
`${environment.apiBaseUrl}documents/selection_data/`
|
|
|
|
|
)
|
|
|
|
|
documentListViewService.toggleSelected(documents[0])
|
|
|
|
|
expect(documentListViewService.isSelected(documents[0])).toBeTruthy()
|
|
|
|
|
documentListViewService.selectRangeTo(documents[2])
|
|
|
|
|
@@ -588,7 +562,7 @@ describe('DocumentListViewService', () => {
|
|
|
|
|
|
|
|
|
|
documentListViewService.setFilterRules(filterRules)
|
|
|
|
|
httpTestingController.expectOne(
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true&tags__id__all=9`
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true&include_selection_data=true&tags__id__all=9`
|
|
|
|
|
)
|
|
|
|
|
const reqs = httpTestingController.match(
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=100000&fields=id&tags__id__all=9`
|
|
|
|
|
@@ -604,7 +578,7 @@ describe('DocumentListViewService', () => {
|
|
|
|
|
const cancelSpy = jest.spyOn(documentListViewService, 'cancelPending')
|
|
|
|
|
documentListViewService.reload()
|
|
|
|
|
httpTestingController.expectOne(
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true&tags__id__all=9`
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true&include_selection_data=true&tags__id__all=9`
|
|
|
|
|
)
|
|
|
|
|
expect(cancelSpy).toHaveBeenCalled()
|
|
|
|
|
})
|
|
|
|
|
@@ -623,7 +597,7 @@ describe('DocumentListViewService', () => {
|
|
|
|
|
documentListViewService.setFilterRules([])
|
|
|
|
|
expect(documentListViewService.sortField).toEqual('created')
|
|
|
|
|
httpTestingController.expectOne(
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true`
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true&include_selection_data=true`
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
@@ -650,11 +624,11 @@ describe('DocumentListViewService', () => {
|
|
|
|
|
expect(localStorageSpy).toHaveBeenCalled()
|
|
|
|
|
// reload triggered
|
|
|
|
|
httpTestingController.match(
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true`
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true&include_selection_data=true`
|
|
|
|
|
)
|
|
|
|
|
documentListViewService.displayFields = null
|
|
|
|
|
httpTestingController.match(
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true`
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true&include_selection_data=true`
|
|
|
|
|
)
|
|
|
|
|
expect(documentListViewService.displayFields).toEqual(
|
|
|
|
|
DEFAULT_DISPLAY_FIELDS.filter((f) => f.id !== DisplayField.ADDED).map(
|
|
|
|
|
@@ -694,7 +668,7 @@ describe('DocumentListViewService', () => {
|
|
|
|
|
it('should generate quick filter URL preserving default state', () => {
|
|
|
|
|
documentListViewService.reload()
|
|
|
|
|
httpTestingController.expectOne(
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true`
|
|
|
|
|
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true&include_selection_data=true`
|
|
|
|
|
)
|
|
|
|
|
const urlTree = documentListViewService.getQuickFilterUrl(filterRules)
|
|
|
|
|
expect(urlTree).toBeDefined()
|
|
|
|
|
|