mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-07-09 13:35:10 +00:00
More test fixes
This commit is contained in:
@@ -57,7 +57,7 @@ describe('UsersAndGroupsComponent', () => {
|
||||
}).compileComponents()
|
||||
fixture = TestBed.createComponent(UsersAndGroupsComponent)
|
||||
settingsService = TestBed.inject(SettingsService)
|
||||
settingsService.currentUser = users[0]
|
||||
settingsService.currentUser.set(users[0])
|
||||
userService = TestBed.inject(UserService)
|
||||
modalService = TestBed.inject(NgbModal)
|
||||
toastService = TestBed.inject(ToastService)
|
||||
|
||||
@@ -248,7 +248,7 @@ describe('AppFrameComponent', () => {
|
||||
const saveSettingSpy = jest.spyOn(settingsService, 'set')
|
||||
settingsService.set(SETTINGS_KEYS.ATTRIBUTES_SECTIONS_COLLAPSED, [])
|
||||
expect(component.slimSidebarEnabled).toBeFalsy()
|
||||
expect(component.slimSidebarAnimating).toBeFalsy()
|
||||
expect(component.slimSidebarAnimating()).toBeFalsy()
|
||||
component.toggleSlimSidebar()
|
||||
const requests = httpTestingController.match(
|
||||
`${environment.apiBaseUrl}ui_settings/`
|
||||
@@ -259,9 +259,9 @@ describe('AppFrameComponent', () => {
|
||||
requests[0].request.body.settings.attributes_sections_collapsed
|
||||
).toEqual(['attributes'])
|
||||
requests[0].flush({ success: true })
|
||||
expect(component.slimSidebarAnimating).toBeTruthy()
|
||||
expect(component.slimSidebarAnimating()).toBeTruthy()
|
||||
tick(200)
|
||||
expect(component.slimSidebarAnimating).toBeFalsy()
|
||||
expect(component.slimSidebarAnimating()).toBeFalsy()
|
||||
expect(component.slimSidebarEnabled).toBeTruthy()
|
||||
expect(saveSettingSpy).toHaveBeenCalledWith(
|
||||
SETTINGS_KEYS.SLIM_SIDEBAR,
|
||||
@@ -291,9 +291,9 @@ describe('AppFrameComponent', () => {
|
||||
fixture.nativeElement as HTMLDivElement
|
||||
).querySelector('button[data-toggle=collapse]')
|
||||
button.dispatchEvent(new MouseEvent('click'))
|
||||
expect(component.isMenuCollapsed).toBeFalsy()
|
||||
expect(component.isMenuCollapsed()).toBeFalsy()
|
||||
component.closeMenu()
|
||||
expect(component.isMenuCollapsed).toBeTruthy()
|
||||
expect(component.isMenuCollapsed()).toBeTruthy()
|
||||
})
|
||||
|
||||
it('should hide mobile search when scrolling down and show it when scrolling up', () => {
|
||||
@@ -308,14 +308,14 @@ describe('AppFrameComponent', () => {
|
||||
value: 40,
|
||||
})
|
||||
component.onWindowScroll()
|
||||
expect(component.mobileSearchHidden).toBe(true)
|
||||
expect(component.mobileSearchHidden()).toBe(true)
|
||||
|
||||
Object.defineProperty(globalThis, 'scrollY', {
|
||||
configurable: true,
|
||||
value: 0,
|
||||
})
|
||||
component.onWindowScroll()
|
||||
expect(component.mobileSearchHidden).toBe(false)
|
||||
expect(component.mobileSearchHidden()).toBe(false)
|
||||
})
|
||||
|
||||
it('should keep mobile search visible on desktop scroll or resize', () => {
|
||||
@@ -323,13 +323,13 @@ describe('AppFrameComponent', () => {
|
||||
value: 1024,
|
||||
})
|
||||
component.ngOnInit()
|
||||
component.mobileSearchHidden = true
|
||||
component.mobileSearchHidden.set(true)
|
||||
|
||||
component.onWindowScroll()
|
||||
|
||||
expect(component.mobileSearchHidden).toBe(false)
|
||||
expect(component.mobileSearchHidden()).toBe(false)
|
||||
|
||||
component.mobileSearchHidden = true
|
||||
component.mobileSearchHidden.set(true)
|
||||
component.onWindowResize()
|
||||
})
|
||||
|
||||
@@ -338,7 +338,7 @@ describe('AppFrameComponent', () => {
|
||||
value: 767,
|
||||
})
|
||||
component.ngOnInit()
|
||||
component.isMenuCollapsed = false
|
||||
component.isMenuCollapsed.set(false)
|
||||
|
||||
Object.defineProperty(globalThis, 'scrollY', {
|
||||
configurable: true,
|
||||
@@ -346,7 +346,7 @@ describe('AppFrameComponent', () => {
|
||||
})
|
||||
component.onWindowScroll()
|
||||
|
||||
expect(component.mobileSearchHidden).toBe(false)
|
||||
expect(component.mobileSearchHidden()).toBe(false)
|
||||
})
|
||||
|
||||
it('should support close document & navigate on close current doc', () => {
|
||||
@@ -379,11 +379,11 @@ describe('AppFrameComponent', () => {
|
||||
})
|
||||
|
||||
it('should disable global dropzone on start drag + drop, re-enable after', () => {
|
||||
expect(settingsService.globalDropzoneEnabled).toBeTruthy()
|
||||
expect(settingsService.globalDropzoneEnabled()).toBeTruthy()
|
||||
component.onDragStart(null)
|
||||
expect(settingsService.globalDropzoneEnabled).toBeFalsy()
|
||||
expect(settingsService.globalDropzoneEnabled()).toBeFalsy()
|
||||
component.onDragEnd(null)
|
||||
expect(settingsService.globalDropzoneEnabled).toBeTruthy()
|
||||
expect(settingsService.globalDropzoneEnabled()).toBeTruthy()
|
||||
})
|
||||
|
||||
it('should update saved view sorting on drag + drop, show info', () => {
|
||||
|
||||
@@ -122,7 +122,7 @@ describe('EditDialogComponent', () => {
|
||||
tagService = TestBed.inject(TagService)
|
||||
permissionsService = TestBed.inject(PermissionsService)
|
||||
settingsService = TestBed.inject(SettingsService)
|
||||
settingsService.currentUser = currentUser
|
||||
settingsService.currentUser.set(currentUser as any)
|
||||
permissionsService.initialize([], currentUser as any)
|
||||
activeModal = TestBed.inject(NgbActiveModal)
|
||||
httpTestingController = TestBed.inject(HttpTestingController)
|
||||
|
||||
@@ -106,7 +106,7 @@ describe('TagsComponent', () => {
|
||||
|
||||
modalService = TestBed.inject(NgbModal)
|
||||
settingsService = TestBed.inject(SettingsService)
|
||||
settingsService.currentUser = { id: 1 }
|
||||
settingsService.currentUser.set({ id: 1 } as any)
|
||||
fixture = TestBed.createComponent(TagsComponent)
|
||||
fixture.debugElement.injector.get(NG_VALUE_ACCESSOR)
|
||||
component = fixture.componentInstance
|
||||
|
||||
+2
-2
@@ -64,9 +64,9 @@ describe('PermissionsFilterDropdownComponent', () => {
|
||||
{
|
||||
provide: SettingsService,
|
||||
useValue: {
|
||||
currentUser: {
|
||||
currentUser: () => ({
|
||||
id: currentUserID,
|
||||
},
|
||||
}),
|
||||
},
|
||||
},
|
||||
provideHttpClient(withInterceptorsFromDi()),
|
||||
|
||||
+1
-1
@@ -162,7 +162,7 @@
|
||||
<pngx-document-card-large
|
||||
[document]="null"
|
||||
[ngStyle]="{ opacity: 1 - (row * 1/placeholderRows.length) }"
|
||||
[displayFields]="displayFields">
|
||||
[displayFields]="displayFields()">
|
||||
</pngx-document-card-large>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,11 +25,11 @@ describe('LoadingComponentWithPermissions', () => {
|
||||
})
|
||||
|
||||
it('should have loading set to true by default', () => {
|
||||
expect(component.loading).toBeTruthy()
|
||||
expect(component.loading()).toBeTruthy()
|
||||
})
|
||||
|
||||
it('should have show set to false by default', () => {
|
||||
expect(component.show).toBeFalsy()
|
||||
expect(component.show()).toBeFalsy()
|
||||
})
|
||||
|
||||
it('should call next and complete on unsubscribeNotifier with itself on destroy', () => {
|
||||
|
||||
@@ -66,7 +66,7 @@ export class SavedViewsComponent
|
||||
public isDirty$: Observable<boolean>
|
||||
|
||||
get displayFields() {
|
||||
return this.settings.allDisplayFields
|
||||
return this.settings.allDisplayFields()
|
||||
}
|
||||
|
||||
public get savedViews(): SavedView[] {
|
||||
|
||||
@@ -96,7 +96,7 @@ describe(`Additional service tests for SavedViewService`, () => {
|
||||
})
|
||||
|
||||
it('should sort dashboard views', () => {
|
||||
service['savedViews'] = saved_views
|
||||
service['savedViews'].set(saved_views)
|
||||
jest.spyOn(settingsService, 'get').mockImplementation((key) => {
|
||||
if (key === SETTINGS_KEYS.DASHBOARD_VIEWS_VISIBLE_IDS) return [1, 2, 3]
|
||||
if (key === SETTINGS_KEYS.DASHBOARD_VIEWS_SORT_ORDER) return [3, 1, 2]
|
||||
@@ -110,7 +110,7 @@ describe(`Additional service tests for SavedViewService`, () => {
|
||||
})
|
||||
|
||||
it('should use user-specific dashboard visibility when configured', () => {
|
||||
service['savedViews'] = saved_views
|
||||
service['savedViews'].set(saved_views)
|
||||
jest.spyOn(settingsService, 'get').mockImplementation((key) => {
|
||||
if (key === SETTINGS_KEYS.DASHBOARD_VIEWS_VISIBLE_IDS) return [4, 2]
|
||||
if (key === SETTINGS_KEYS.DASHBOARD_VIEWS_SORT_ORDER) return []
|
||||
@@ -119,7 +119,7 @@ describe(`Additional service tests for SavedViewService`, () => {
|
||||
})
|
||||
|
||||
it('should sort sidebar views', () => {
|
||||
service['savedViews'] = saved_views
|
||||
service['savedViews'].set(saved_views)
|
||||
jest.spyOn(settingsService, 'get').mockImplementation((key) => {
|
||||
if (key === SETTINGS_KEYS.SIDEBAR_VIEWS_VISIBLE_IDS) return [1, 2, 3]
|
||||
if (key === SETTINGS_KEYS.SIDEBAR_VIEWS_SORT_ORDER) return [3, 1, 2]
|
||||
@@ -133,7 +133,7 @@ describe(`Additional service tests for SavedViewService`, () => {
|
||||
})
|
||||
|
||||
it('should use user-specific sidebar visibility when configured', () => {
|
||||
service['savedViews'] = saved_views
|
||||
service['savedViews'].set(saved_views)
|
||||
jest.spyOn(settingsService, 'get').mockImplementation((key) => {
|
||||
if (key === SETTINGS_KEYS.SIDEBAR_VIEWS_VISIBLE_IDS) return [4, 2]
|
||||
if (key === SETTINGS_KEYS.SIDEBAR_VIEWS_SORT_ORDER) return []
|
||||
|
||||
@@ -392,22 +392,22 @@ describe('SettingsService', () => {
|
||||
req.flush(ui_settings)
|
||||
settingsService.initializeDisplayFields()
|
||||
expect(
|
||||
settingsService.allDisplayFields.includes(DEFAULT_DISPLAY_FIELDS[0])
|
||||
settingsService.allDisplayFields().includes(DEFAULT_DISPLAY_FIELDS[0])
|
||||
).toBeTruthy() // title
|
||||
expect(
|
||||
settingsService.allDisplayFields.includes(DEFAULT_DISPLAY_FIELDS[4])
|
||||
settingsService.allDisplayFields().includes(DEFAULT_DISPLAY_FIELDS[4])
|
||||
).toBeFalsy() // correspondent
|
||||
|
||||
settingsService.set(SETTINGS_KEYS.NOTES_ENABLED, false)
|
||||
settingsService.initializeDisplayFields()
|
||||
expect(
|
||||
settingsService.allDisplayFields.includes(DEFAULT_DISPLAY_FIELDS[8])
|
||||
settingsService.allDisplayFields().includes(DEFAULT_DISPLAY_FIELDS[8])
|
||||
).toBeFalsy() // notes
|
||||
|
||||
jest.spyOn(permissionService, 'currentUserCan').mockReturnValue(true)
|
||||
settingsService.initializeDisplayFields()
|
||||
expect(
|
||||
settingsService.allDisplayFields.includes(DEFAULT_DISPLAY_FIELDS[4])
|
||||
settingsService.allDisplayFields().includes(DEFAULT_DISPLAY_FIELDS[4])
|
||||
).toBeTruthy() // correspondent
|
||||
})
|
||||
|
||||
@@ -422,12 +422,14 @@ describe('SettingsService', () => {
|
||||
)
|
||||
settingsService.initializeDisplayFields()
|
||||
expect(
|
||||
settingsService.allDisplayFields.includes(DEFAULT_DISPLAY_FIELDS[0])
|
||||
settingsService.allDisplayFields().includes(DEFAULT_DISPLAY_FIELDS[0])
|
||||
).toBeTruthy()
|
||||
expect(
|
||||
settingsService.allDisplayFields.find(
|
||||
(f) => f.id === `${DisplayField.CUSTOM_FIELD}${customFields[0].id}`
|
||||
).name
|
||||
settingsService
|
||||
.allDisplayFields()
|
||||
.find(
|
||||
(f) => f.id === `${DisplayField.CUSTOM_FIELD}${customFields[0].id}`
|
||||
).name
|
||||
).toEqual(customFields[0].name)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user