Enhancement/#205 implement bookmark logic tests#772
Conversation
Arnau-66
left a comment
There was a problem hiding this comment.
Reviewed: bookmark toggle logic is correctly implemented in the challenge card.
stopPropagation prevents unwanted navigation, tooltip handling is properly managed, and auth checks are in place.
State updates (isBookmarked and bookmarks_count) look consistent, and the added unit tests cover add/remove/error scenarios well.
Styles applied correctly
src/app/shared/components/challenge-card/challenge-card.component.ts
Outdated
Show resolved
Hide resolved
src/app/shared/components/challenge-card/challenge-card.component.ts
Outdated
Show resolved
Hide resolved
|
I think the version should be considered as a minor instead of a minor plus patch, it introduces something new to the user ( even if it's not fully implemented) |
|
Overall i think it's well adressed and it should pass with those tweaks, good job |
|
Hi Vania! 👋 The Without The only synchronous test is "should not execute if user is not logged in" — that one doesn't call the service at all (early return), so it doesn't need Let me know if you'd like me to refactor these tests differently! 🙂 |
…tion from changelog
b93fb5b to
7b379a9
Compare
|




📍 Context
Following the UI implementation in PR#203, this PR implements the full bookmark toggle logic and comprehensive test coverage for the challenge card component.
The bookmark feature allows users to save challenges for later reference. Backend endpoints (
addBookmark,removeBookmark) exist inChallengeServiceand are integrated in this implementation.✅ Changes
toggleBookmark()method with full logic:ChallengeService.addBookmark()/removeBookmark()endpointsisBookmarked,bookmarks_count) based on API responseNgbTooltipreference to close tooltip programmatically after clickBackend Status
The bookmark functionality requires backend endpoints that are currently unstable:
POST /challenge/challenges/{id}/bookmarks→ Returns 500 Internal Server ErrorDELETE /challenge/challenges/{id}/bookmarks→ Returns 500 Internal Server ErrorExample error from console:

Development Workarounds
For local testing and demonstration:
getUserBookmarks()of({}).pipe(delay(200))to simulate successful responsesCode Status
✅ Component logic is production-ready and will work correctly once backend endpoints are stable
✅ All unit tests pass (using mocked service responses)
🧪 Testing
Unit Tests
All tests passing ✅
toggleBookmark: should call addBookmark when not bookmarkedtoggleBookmark: should call removeBookmark when already bookmarkedtoggleBookmark: should handle error on addBookmarktoggleBookmark: should handle error on removeBookmarktoggleBookmark: should close tooltip when providedtoggleBookmark: should not execute if user is not logged inManual Testing
Tested locally with mocked service responses:
📂 Files Changed
src/app/shared/components/challenge-card/challenge-card.component.html— Added#bookmarkTooltiptemplate referencesrc/app/shared/components/challenge-card/challenge-card.component.ts— Implemented fulltoggleBookmark()logic with tooltip fixsrc/app/shared/components/challenge-card/challenge-card.component.spec.ts— Added 6 comprehensive tests for bookmark functionalitypackage.json— Version bumpsrc/environments/environment.CI.dev.ts— Version bumpCHANGELOG.md— Added changelog entry✅ Acceptance Criteria
isBookmarkedstate updates correctly after API responsebookmarks_countincrements/decrements appropriatelystopPropagationworks)🚫 Out of Scope