mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-10-02 01:42:50 -05:00
Fix these frontend tests
This commit is contained in:
@@ -409,7 +409,7 @@ describe('DocumentDetailComponent', () => {
|
|||||||
color: '#ff0000',
|
color: '#ff0000',
|
||||||
text_color: '#000000',
|
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')
|
expect(component.suggestions.suggested_tags).not.toContain('NewTag12')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@@ -31,6 +31,7 @@ import {
|
|||||||
map,
|
map,
|
||||||
switchMap,
|
switchMap,
|
||||||
takeUntil,
|
takeUntil,
|
||||||
|
tap,
|
||||||
} from 'rxjs/operators'
|
} from 'rxjs/operators'
|
||||||
import { Correspondent } from 'src/app/data/correspondent'
|
import { Correspondent } from 'src/app/data/correspondent'
|
||||||
import { CustomField, CustomFieldDataType } from 'src/app/data/custom-field'
|
import { CustomField, CustomFieldDataType } from 'src/app/data/custom-field'
|
||||||
@@ -738,20 +739,27 @@ export class DocumentDetailComponent
|
|||||||
if (newName) modal.componentInstance.object = { name: newName }
|
if (newName) modal.componentInstance.object = { name: newName }
|
||||||
modal.componentInstance.succeeded
|
modal.componentInstance.succeeded
|
||||||
.pipe(
|
.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
|
return this.tagService
|
||||||
.listAll()
|
.listAll()
|
||||||
.pipe(map((tags) => ({ newTag, tags })))
|
.pipe(map((tags) => ({ newTag, tags })))
|
||||||
})
|
}),
|
||||||
|
takeUntil(this.unsubscribeNotifier)
|
||||||
)
|
)
|
||||||
.pipe(takeUntil(this.unsubscribeNotifier))
|
|
||||||
.subscribe(({ newTag, tags }) => {
|
.subscribe(({ newTag, tags }) => {
|
||||||
this.tagsInput.tags = tags.results
|
this.tagsInput.tags = tags.results
|
||||||
this.tagsInput.addTag(newTag.id)
|
this.tagsInput.addTag(newTag.id)
|
||||||
if (this.suggestions) {
|
|
||||||
this.suggestions.suggested_tags =
|
|
||||||
this.suggestions.suggested_tags.filter((tag) => tag !== newName)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user