mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-11-06 14:59:22 +00:00
Fixhancement: rework saved view widget queue processing to expected (#14699)
* activateSavedViewWithDocuments, move most of loadSavedView to a helper * Consolidate the page size thing * Pass widget's documents to list service fpr next / previous * Tests for the page size + widget click * Fix close from a dashboard widget list
This commit is contained in:
1 parent
e88303cc16
commit
c5239f9f74
8 files changed
+150
-13
No files matched your search
+35
-1
@@ -16,7 +16,11 @@ import { routes } from 'src/app/app-routing.module'
|
||||
import { CustomFieldDisplayComponent } from 'src/app/components/common/custom-field-display/custom-field-display.component'
|
||||
import { PreviewPopupComponent } from 'src/app/components/common/preview-popup/preview-popup.component'
|
||||
import { CustomFieldDataType } from 'src/app/data/custom-field'
|
||||
import { DisplayField, DisplayMode } from 'src/app/data/document'
|
||||
import {
|
||||
DEFAULT_DASHBOARD_VIEW_PAGE_SIZE,
|
||||
DisplayField,
|
||||
DisplayMode,
|
||||
} from 'src/app/data/document'
|
||||
import {
|
||||
FILTER_CORRESPONDENT,
|
||||
FILTER_DOCUMENT_TYPE,
|
||||
@@ -277,10 +281,40 @@ describe('SavedViewWidgetComponent', () => {
|
||||
|
||||
it('should navigate to document', () => {
|
||||
const routerSpy = jest.spyOn(router, 'navigate')
|
||||
const activateSpy = jest.spyOn(
|
||||
documentListViewService,
|
||||
'activateSavedViewWithDocuments'
|
||||
)
|
||||
component.openDocumentDetail(documentResults[0])
|
||||
expect(activateSpy).toHaveBeenCalled()
|
||||
expect(routerSpy).toHaveBeenCalledWith(['documents', documentResults[0].id])
|
||||
})
|
||||
|
||||
it('should hand its documents to the list service when opening a document', () => {
|
||||
jest.spyOn(documentService, 'listFiltered').mockReturnValue(
|
||||
of({
|
||||
all: [2, 3],
|
||||
count: 25,
|
||||
results: documentResults,
|
||||
})
|
||||
)
|
||||
jest.spyOn(router, 'navigateByUrl').mockResolvedValue(true)
|
||||
const activateSpy = jest
|
||||
.spyOn(documentListViewService, 'activateSavedViewWithDocuments')
|
||||
.mockImplementation(() => {})
|
||||
component.ngOnInit()
|
||||
fixture.detectChanges()
|
||||
fixture.debugElement
|
||||
.query(By.css('a[title="Open document"]'))
|
||||
.nativeElement.click()
|
||||
expect(activateSpy).toHaveBeenCalledWith(savedView, documentResults, 25, 20)
|
||||
})
|
||||
|
||||
it('should fall back to the default dashboard page size', () => {
|
||||
component.savedView = { ...savedView, page_size: undefined }
|
||||
expect(component.pageSize).toEqual(DEFAULT_DASHBOARD_VIEW_PAGE_SIZE)
|
||||
})
|
||||
|
||||
it('should navigate via quickfilter on click tag', () => {
|
||||
const qfSpy = jest.spyOn(documentListViewService, 'quickFilter')
|
||||
component.clickTag(11, new MouseEvent('click'))
|
||||
|
||||
Reference in new issue
Block a user