]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Chore: add coverage for missing lines in patch change
authorshamoon <4887959+shamoon@users.noreply.github.com>
Wed, 23 Apr 2025 06:33:11 +0000 (23:33 -0700)
committershamoon <4887959+shamoon@users.noreply.github.com>
Wed, 23 Apr 2025 06:33:11 +0000 (23:33 -0700)
src-ui/src/app/components/document-detail/document-detail.component.spec.ts

index 5b94c4922b10255e6c76dfcb2b3c6147ce238b8f..9be722c3a38bc8a31dfcd98898da2c4580633052 100644 (file)
@@ -992,6 +992,44 @@ describe('DocumentDetailComponent', () => {
     )
   })
 
+  it('should correctly determine changed fields', () => {
+    initNormally()
+    expect(component['getChangedFields']()).toEqual({
+      id: doc.id,
+    })
+    component.documentForm.get('title').setValue('Foo Bar')
+    component.documentForm.get('permissions_form').setValue({
+      owner: 1,
+      set_permissions: {
+        view: {
+          users: [2],
+          groups: [],
+        },
+        change: {
+          users: [3],
+          groups: [],
+        },
+      },
+    })
+    component.documentForm.get('title').markAsDirty()
+    component.documentForm.get('permissions_form').markAsDirty()
+    expect(component['getChangedFields']()).toEqual({
+      id: doc.id,
+      title: 'Foo Bar',
+      owner: 1,
+      set_permissions: {
+        view: {
+          users: [2],
+          groups: [],
+        },
+        change: {
+          users: [3],
+          groups: [],
+        },
+      },
+    })
+  })
+
   it('should show custom field errors', () => {
     initNormally()
     component.error = {