mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-02-24 00:59:35 -06:00
Tweakhancement: reset to page 1 on reset filters (#12143)
This commit is contained in:
@@ -147,21 +147,21 @@ describe('DocumentListComponent', () => {
|
||||
})
|
||||
|
||||
it('should show score sort fields on fulltext queries', () => {
|
||||
documentListService.filterRules = [
|
||||
documentListService.setFilterRules([
|
||||
{
|
||||
rule_type: FILTER_HAS_TAGS_ANY,
|
||||
value: '10',
|
||||
},
|
||||
]
|
||||
])
|
||||
fixture.detectChanges()
|
||||
expect(component.getSortFields()).toEqual(documentListService.sortFields)
|
||||
|
||||
documentListService.filterRules = [
|
||||
documentListService.setFilterRules([
|
||||
{
|
||||
rule_type: FILTER_FULLTEXT_QUERY,
|
||||
value: 'foo',
|
||||
},
|
||||
]
|
||||
])
|
||||
fixture.detectChanges()
|
||||
expect(component.getSortFields()).toEqual(
|
||||
documentListService.sortFieldsFullText
|
||||
@@ -170,12 +170,12 @@ describe('DocumentListComponent', () => {
|
||||
|
||||
it('should determine if filtered, support reset', () => {
|
||||
fixture.detectChanges()
|
||||
documentListService.filterRules = [
|
||||
documentListService.setFilterRules([
|
||||
{
|
||||
rule_type: FILTER_HAS_TAGS_ANY,
|
||||
value: '10',
|
||||
},
|
||||
]
|
||||
])
|
||||
documentListService.isReloading = false
|
||||
fixture.detectChanges()
|
||||
expect(component.isFiltered).toBeTruthy()
|
||||
@@ -185,6 +185,20 @@ describe('DocumentListComponent', () => {
|
||||
expect(fixture.nativeElement.textContent.match(/Reset/g)).toHaveLength(1)
|
||||
})
|
||||
|
||||
it('should apply filter rule changes via list service', () => {
|
||||
const setFilterRulesSpy = jest.spyOn(documentListService, 'setFilterRules')
|
||||
const rules = [{ rule_type: FILTER_HAS_TAGS_ANY, value: '10' }]
|
||||
component.onFilterRulesChange(rules)
|
||||
expect(setFilterRulesSpy).toHaveBeenCalledWith(rules)
|
||||
})
|
||||
|
||||
it('should reset filter rules to page one via list service', () => {
|
||||
const setFilterRulesSpy = jest.spyOn(documentListService, 'setFilterRules')
|
||||
const rules = [{ rule_type: FILTER_HAS_TAGS_ANY, value: '10' }]
|
||||
component.onFilterRulesReset(rules)
|
||||
expect(setFilterRulesSpy).toHaveBeenCalledWith(rules, true)
|
||||
})
|
||||
|
||||
it('should load saved view from URL', () => {
|
||||
const view: SavedView = {
|
||||
id: 10,
|
||||
@@ -217,7 +231,7 @@ describe('DocumentListComponent', () => {
|
||||
.spyOn(activatedRoute, 'paramMap', 'get')
|
||||
.mockReturnValue(of(convertToParamMap(queryParams)))
|
||||
activatedRoute.snapshot.queryParams = queryParams
|
||||
fixture.detectChanges()
|
||||
component.ngOnInit()
|
||||
expect(getSavedViewSpy).toHaveBeenCalledWith(view.id)
|
||||
expect(activateSavedViewSpy).toHaveBeenCalledWith(
|
||||
view,
|
||||
|
||||
Reference in New Issue
Block a user