Skip to content

Add spec coverage for search-bar.component.ts #5228

@Ma77Ball

Description

@Ma77Ball

Task Summary

Create search-bar.component.spec.ts for frontend/src/app/dashboard/component/user/search-bar/search-bar.component.ts.

Behavior to cover:

  • isLogin tracking — initial value comes from UserService.isLogin(); updates when userChanged() emits.
  • onSearchInputChange — clears listOfResult immediately for empty query; for non-empty pushes through searchSubject.
  • Debouncing — searchSubject emits go through debounceTime(200) (use fakeAsync + tick) and then getSearchResults.
  • getSearchResults caching — first call invokes SearchService.search([query], params, 0, 5, null, SortMethod.NameAsc, isLogin, includePublic=true); subsequent calls with same query return cached
    result without re-invoking service.
  • Cache eviction (addToCache) — once 20 queries are cached, adding a 21st evicts the oldest (queryOrder.shift() + searchCache.delete).
  • convertToName — returns correct DashboardEntry.name for workflow, project, file, dataset items; throws "Unexpected type in SearchResult." otherwise.
  • performSearch — navigates to DASHBOARD_SEARCH with queryParams: { q: keyword }.

Task Type

  • Refactor / Cleanup
  • DevOps / Deployment / CI
  • Testing / QA
  • Documentation
  • Performance
  • Other

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions