test data
Prompt
You are a senior Angular engineer. Build a small feature with tests. STACK — use exactly these, no substitutes - Angular 21, standalone components only (no NgModules), zone-based - @ngrx/signals: signalStore, withState, withComputed, withMethods, rxMethod. Not classic NgRx — no actions, reducers or effects. - RxJS 7.8, TypeScript 5.9 strict - Tests: Vitest + Spectator (createComponentFactory / createServiceFactory) and ng-mocks. No raw TestBed boilerplate. FEATURE: Book search — a search box and a results list. EXISTING API — do not reimplement HTTP interface Book { id: string; title: string; author: string; year: number } interface BookPage { items: Book[]; total: number } abstract class BooksApi { abstract search(query: string, page: number, pageSize: number): Observable<BookPage>; } REQUIREMENTS 1. Search runs 300ms after typing stops. Queries under 2 characters don't search; show the empty state instead. 2. A new query cancels any in-flight request. Results from a stale query must never appear. 3. Trim the query. Identical consecutive queries don't re-fire. 4. States: idle, loading, success, empty (0 results), and error with a Retry button that re-runs the last query. 5. "Load more" appends the next page and hides when everything is loaded. Changing the query resets to page 1. 6. Accessible: labelled input, results announced via aria-live, loading state indicated. DELIVERABLES - book-search.store.ts - book-search.component.ts with its template - book-search.store.spec.ts and book-search.component.spec.ts covering debounce, stale-request cancellation, min length, empty, error and retry, load more, and query reset - Short notes: key design decisions, and anything in the requirements you find ambiguous RULES - Fake timers for debounce tests. - No `any`. No manual subscribe() in the component. - If you're unsure an API exists in these versions, say so — don't invent it.