From ca515f7e1d4e144ccb28c139e7e6269cd2610bc4 Mon Sep 17 00:00:00 2001
From: shamoon <4887959+shamoon@users.noreply.github.com>
Date: Wed, 8 Jul 2026 19:04:52 -0700
Subject: [PATCH] More test fixes
---
.../users-groups.component.spec.ts | 2 +-
.../app-frame/app-frame.component.spec.ts | 30 +++++++++----------
.../edit-dialog/edit-dialog.component.spec.ts | 2 +-
.../common/input/tags/tags.component.spec.ts | 2 +-
...missions-filter-dropdown.component.spec.ts | 4 +--
.../saved-view-widget.component.html | 2 +-
.../loading.component.spec.ts | 4 +--
.../saved-views/saved-views.component.ts | 2 +-
.../services/rest/saved-view.service.spec.ts | 8 ++---
.../src/app/services/settings.service.spec.ts | 18 ++++++-----
10 files changed, 38 insertions(+), 36 deletions(-)
diff --git a/src-ui/src/app/components/admin/users-groups/users-groups.component.spec.ts b/src-ui/src/app/components/admin/users-groups/users-groups.component.spec.ts
index 31bd6e9d4..78b08efba 100644
--- a/src-ui/src/app/components/admin/users-groups/users-groups.component.spec.ts
+++ b/src-ui/src/app/components/admin/users-groups/users-groups.component.spec.ts
@@ -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)
diff --git a/src-ui/src/app/components/app-frame/app-frame.component.spec.ts b/src-ui/src/app/components/app-frame/app-frame.component.spec.ts
index d6f84276f..b533b9f12 100644
--- a/src-ui/src/app/components/app-frame/app-frame.component.spec.ts
+++ b/src-ui/src/app/components/app-frame/app-frame.component.spec.ts
@@ -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', () => {
diff --git a/src-ui/src/app/components/common/edit-dialog/edit-dialog.component.spec.ts b/src-ui/src/app/components/common/edit-dialog/edit-dialog.component.spec.ts
index 1dbd54edf..08cef5a46 100644
--- a/src-ui/src/app/components/common/edit-dialog/edit-dialog.component.spec.ts
+++ b/src-ui/src/app/components/common/edit-dialog/edit-dialog.component.spec.ts
@@ -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)
diff --git a/src-ui/src/app/components/common/input/tags/tags.component.spec.ts b/src-ui/src/app/components/common/input/tags/tags.component.spec.ts
index 90f0517bc..31676e25b 100644
--- a/src-ui/src/app/components/common/input/tags/tags.component.spec.ts
+++ b/src-ui/src/app/components/common/input/tags/tags.component.spec.ts
@@ -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
diff --git a/src-ui/src/app/components/common/permissions-filter-dropdown/permissions-filter-dropdown.component.spec.ts b/src-ui/src/app/components/common/permissions-filter-dropdown/permissions-filter-dropdown.component.spec.ts
index fd8e261a0..569aa39c0 100644
--- a/src-ui/src/app/components/common/permissions-filter-dropdown/permissions-filter-dropdown.component.spec.ts
+++ b/src-ui/src/app/components/common/permissions-filter-dropdown/permissions-filter-dropdown.component.spec.ts
@@ -64,9 +64,9 @@ describe('PermissionsFilterDropdownComponent', () => {
{
provide: SettingsService,
useValue: {
- currentUser: {
+ currentUser: () => ({
id: currentUserID,
- },
+ }),
},
},
provideHttpClient(withInterceptorsFromDi()),
diff --git a/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.html b/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.html
index 0893faa58..67047b887 100644
--- a/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.html
+++ b/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.html
@@ -162,7 +162,7 @@
+ [displayFields]="displayFields()">
}
}
diff --git a/src-ui/src/app/components/loading-component/loading.component.spec.ts b/src-ui/src/app/components/loading-component/loading.component.spec.ts
index d4667093d..5e898d752 100644
--- a/src-ui/src/app/components/loading-component/loading.component.spec.ts
+++ b/src-ui/src/app/components/loading-component/loading.component.spec.ts
@@ -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', () => {
diff --git a/src-ui/src/app/components/manage/saved-views/saved-views.component.ts b/src-ui/src/app/components/manage/saved-views/saved-views.component.ts
index 4e4629c0b..ca3710fc5 100644
--- a/src-ui/src/app/components/manage/saved-views/saved-views.component.ts
+++ b/src-ui/src/app/components/manage/saved-views/saved-views.component.ts
@@ -66,7 +66,7 @@ export class SavedViewsComponent
public isDirty$: Observable
get displayFields() {
- return this.settings.allDisplayFields
+ return this.settings.allDisplayFields()
}
public get savedViews(): SavedView[] {
diff --git a/src-ui/src/app/services/rest/saved-view.service.spec.ts b/src-ui/src/app/services/rest/saved-view.service.spec.ts
index c72fb5409..faf4e9328 100644
--- a/src-ui/src/app/services/rest/saved-view.service.spec.ts
+++ b/src-ui/src/app/services/rest/saved-view.service.spec.ts
@@ -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 []
diff --git a/src-ui/src/app/services/settings.service.spec.ts b/src-ui/src/app/services/settings.service.spec.ts
index 5190bc549..b4966f8c0 100644
--- a/src-ui/src/app/services/settings.service.spec.ts
+++ b/src-ui/src/app/services/settings.service.spec.ts
@@ -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)
})
})