]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Fix error in system status test
authorshamoon <4887959+shamoon@users.noreply.github.com>
Sat, 6 Sep 2025 14:56:15 +0000 (07:56 -0700)
committershamoon <4887959+shamoon@users.noreply.github.com>
Sat, 6 Sep 2025 14:56:15 +0000 (07:56 -0700)
src-ui/src/app/components/admin/settings/settings.component.spec.ts

index 3b74362feda8464bfb638f692a047fb1dfc931fe..300067d1b95cd2bcc460fb6f4eafcdbffc0fa6a5 100644 (file)
@@ -61,6 +61,40 @@ const groups = [
   { id: 2, name: 'group2' },
 ]
 
+const status: SystemStatus = {
+  pngx_version: '2.4.3',
+  server_os: 'macOS-14.1.1-arm64-arm-64bit',
+  install_type: InstallType.BareMetal,
+  storage: { total: 494384795648, available: 13573525504 },
+  database: {
+    type: 'sqlite',
+    url: '/paperless-ngx/data/db.sqlite3',
+    status: SystemStatusItemStatus.ERROR,
+    error: null,
+    migration_status: {
+      latest_migration: 'socialaccount.0006_alter_socialaccount_extra_data',
+      unapplied_migrations: [],
+    },
+  },
+  tasks: {
+    redis_url: 'redis://localhost:6379',
+    redis_status: SystemStatusItemStatus.ERROR,
+    redis_error: 'Error 61 connecting to localhost:6379. Connection refused.',
+    celery_status: SystemStatusItemStatus.ERROR,
+    celery_url: 'celery@localhost',
+    celery_error: 'Error connecting to celery@localhost',
+    index_status: SystemStatusItemStatus.OK,
+    index_last_modified: new Date().toISOString(),
+    index_error: null,
+    classifier_status: SystemStatusItemStatus.OK,
+    classifier_last_trained: new Date().toISOString(),
+    classifier_error: null,
+    sanity_check_status: SystemStatusItemStatus.ERROR,
+    sanity_check_last_run: new Date().toISOString(),
+    sanity_check_error: 'Error running sanity check.',
+  },
+}
+
 describe('SettingsComponent', () => {
   let component: SettingsComponent
   let fixture: ComponentFixture<SettingsComponent>
@@ -290,40 +324,6 @@ describe('SettingsComponent', () => {
   })
 
   it('should load system status on initialize, show errors if needed', () => {
-    const status: SystemStatus = {
-      pngx_version: '2.4.3',
-      server_os: 'macOS-14.1.1-arm64-arm-64bit',
-      install_type: InstallType.BareMetal,
-      storage: { total: 494384795648, available: 13573525504 },
-      database: {
-        type: 'sqlite',
-        url: '/paperless-ngx/data/db.sqlite3',
-        status: SystemStatusItemStatus.ERROR,
-        error: null,
-        migration_status: {
-          latest_migration: 'socialaccount.0006_alter_socialaccount_extra_data',
-          unapplied_migrations: [],
-        },
-      },
-      tasks: {
-        redis_url: 'redis://localhost:6379',
-        redis_status: SystemStatusItemStatus.ERROR,
-        redis_error:
-          'Error 61 connecting to localhost:6379. Connection refused.',
-        celery_status: SystemStatusItemStatus.ERROR,
-        celery_url: 'celery@localhost',
-        celery_error: 'Error connecting to celery@localhost',
-        index_status: SystemStatusItemStatus.OK,
-        index_last_modified: new Date().toISOString(),
-        index_error: null,
-        classifier_status: SystemStatusItemStatus.OK,
-        classifier_last_trained: new Date().toISOString(),
-        classifier_error: null,
-        sanity_check_status: SystemStatusItemStatus.ERROR,
-        sanity_check_last_run: new Date().toISOString(),
-        sanity_check_error: 'Error running sanity check.',
-      },
-    }
     jest.spyOn(systemStatusService, 'get').mockReturnValue(of(status))
     jest.spyOn(permissionsService, 'isAdmin').mockReturnValue(true)
     completeSetup()
@@ -340,6 +340,8 @@ describe('SettingsComponent', () => {
 
   it('should open system status dialog', () => {
     const modalOpenSpy = jest.spyOn(modalService, 'open')
+    jest.spyOn(systemStatusService, 'get').mockReturnValue(of(status))
+    jest.spyOn(permissionsService, 'isAdmin').mockReturnValue(true)
     completeSetup()
     component.showSystemStatus()
     expect(modalOpenSpy).toHaveBeenCalledWith(SystemStatusDialogComponent, {