]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Fix a random test error
authorshamoon <4887959+shamoon@users.noreply.github.com>
Tue, 17 Sep 2024 02:36:44 +0000 (19:36 -0700)
committershamoon <4887959+shamoon@users.noreply.github.com>
Tue, 17 Sep 2024 02:36:44 +0000 (19:36 -0700)
src-ui/src/app/components/common/filterable-dropdown/filterable-dropdown.component.spec.ts
src-ui/src/app/components/common/filterable-dropdown/filterable-dropdown.component.ts

index a285144f48f8067ca305dad91dc0261818b20c7a..d1c37bc8ba062dcac049ad80314f0a67e96d38bb 100644 (file)
@@ -539,15 +539,10 @@ describe('FilterableDropdownComponent & FilterableDropdownSelectionModel', () =>
     fixture.nativeElement
       .querySelector('button')
       .dispatchEvent(new MouseEvent('click')) // open
-    fixture.detectChanges()
     tick(100)
     component.filterText = 'FooBar'
-    fixture.detectChanges()
-    component.listFilterTextInput.nativeElement.dispatchEvent(
-      new KeyboardEvent('keyup', { key: 'Enter' })
-    )
+    component.listFilterEnter()
     expect(component.selectionModel.getSelectedItems()).toEqual([])
-    tick(300)
     expect(createSpy).toHaveBeenCalled()
   }))
 
index 4a3c70953cf69e0b85870e28a8e3c8f648063fe5..7830e3909fd89d4e3e724b3f14770882cc9ff4a7 100644 (file)
@@ -483,7 +483,7 @@ export class FilterableDropdownComponent implements OnDestroy, OnInit {
   dropdownOpenChange(open: boolean): void {
     if (open) {
       setTimeout(() => {
-        this.listFilterTextInput.nativeElement.focus()
+        this.listFilterTextInput?.nativeElement.focus()
       }, 0)
       if (this.editing) {
         this.selectionModel.reset()
@@ -492,7 +492,7 @@ export class FilterableDropdownComponent implements OnDestroy, OnInit {
       this.opened.next(this)
     } else {
       if (this.creating) {
-        this.dropdown.open()
+        this.dropdown?.open()
         this.creating = false
       } else {
         this.filterText = ''