From 8c1f1e05b913b1ba09917dcad16967e7dd9d8ede Mon Sep 17 00:00:00 2001 From: CodeWithMaBot <310216433+CodeWithMaBot@users.noreply.github.com> Date: Sun, 23 Aug 2026 13:29:55 +0200 Subject: [PATCH] feat: autofill poster search with item title --- .../item-form/item-form.component.ts | 1 + .../poster-picker.component.spec.ts | 21 +++++++++++++++++++ .../poster-picker/poster-picker.component.ts | 11 +++++++++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/app/components/item-form/item-form.component.ts b/src/app/components/item-form/item-form.component.ts index 96338dc..f84eb7b 100644 --- a/src/app/components/item-form/item-form.component.ts +++ b/src/app/components/item-form/item-form.component.ts @@ -111,6 +111,7 @@ export interface ItemFormAutofillPatch { Poster { }); }); + it('seeds poster search with the item title when opened', async () => { + vi.useFakeTimers(); + const tmdbSuggestionService = TestBed.inject(TmdbSuggestionService); + const search = vi.mocked(tmdbSuggestionService.search); + try { + const fixture = TestBed.createComponent(PosterPickerComponent); + fixture.componentRef.setInput('searchSeed', ' Test Movie '); + fixture.detectChanges(); + + fixture.componentInstance.openPosterSearch(); + + expect(fixture.componentInstance.showPosterSearch()).toBe(true); + expect(fixture.componentInstance.posterSearchQuery()).toBe('Test Movie'); + + await vi.advanceTimersByTimeAsync(300); + expect(search).toHaveBeenCalledWith('Test Movie'); + } finally { + vi.useRealTimers(); + } + }); + it('searches TMDB for posters after debounce', async () => { vi.useFakeTimers(); const tmdbSuggestionService = TestBed.inject(TmdbSuggestionService); diff --git a/src/app/components/poster-picker/poster-picker.component.ts b/src/app/components/poster-picker/poster-picker.component.ts index 50b0688..6d89854 100644 --- a/src/app/components/poster-picker/poster-picker.component.ts +++ b/src/app/components/poster-picker/poster-picker.component.ts @@ -104,7 +104,7 @@ import { createTmdbSearchStream } from '../../utils/tmdb-search.utils'; @if (!showPosterSearch()) {