]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Fix these frontend tests
authorshamoon <4887959+shamoon@users.noreply.github.com>
Tue, 30 Sep 2025 18:38:21 +0000 (11:38 -0700)
committershamoon <4887959+shamoon@users.noreply.github.com>
Tue, 30 Sep 2025 18:38:21 +0000 (11:38 -0700)
src-ui/src/app/components/document-detail/document-detail.component.spec.ts
src-ui/src/app/components/document-detail/document-detail.component.ts

index 20e9aec7900c19b70af209a169ce6470d0b65e8f..817450e06531ec376a3e7e2f9a929cb20b7700eb 100644 (file)
@@ -409,7 +409,7 @@ describe('DocumentDetailComponent', () => {
       color: '#ff0000',
       text_color: '#000000',
     })
-    expect(component.documentForm.get('tags').value).toContain(12)
+    expect(component.tagsInput.value).toContain(12)
     expect(component.suggestions.suggested_tags).not.toContain('NewTag12')
   })
 
index 5dd4c3e685216691bd532ed02a3764f4d60e37c1..b04d118aefbbae1bbf46b77c819fec0bf0d67d51 100644 (file)
@@ -31,6 +31,7 @@ import {
   map,
   switchMap,
   takeUntil,
+  tap,
 } from 'rxjs/operators'
 import { Correspondent } from 'src/app/data/correspondent'
 import { CustomField, CustomFieldDataType } from 'src/app/data/custom-field'
@@ -738,20 +739,27 @@ export class DocumentDetailComponent
     if (newName) modal.componentInstance.object = { name: newName }
     modal.componentInstance.succeeded
       .pipe(
-        switchMap((newTag) => {
+        tap((newTag: Tag) => {
+          // remove from suggestions if present
+          if (this.suggestions) {
+            this.suggestions = {
+              ...this.suggestions,
+              suggested_tags: this.suggestions.suggested_tags.filter(
+                (tag) => tag !== newTag.name
+              ),
+            }
+          }
+        }),
+        switchMap((newTag: Tag) => {
           return this.tagService
             .listAll()
             .pipe(map((tags) => ({ newTag, tags })))
-        })
+        }),
+        takeUntil(this.unsubscribeNotifier)
       )
-      .pipe(takeUntil(this.unsubscribeNotifier))
       .subscribe(({ newTag, tags }) => {
         this.tagsInput.tags = tags.results
         this.tagsInput.addTag(newTag.id)
-        if (this.suggestions) {
-          this.suggestions.suggested_tags =
-            this.suggestions.suggested_tags.filter((tag) => tag !== newName)
-        }
       })
   }