From 72c0c0cd260778fbdb2e97c92fad434d9ef70983 Mon Sep 17 00:00:00 2001 From: cindy-wg <64384079+cindy-wg@users.noreply.github.com> Date: Thu, 27 Feb 2025 17:29:02 -0600 Subject: [PATCH] updated UserGuide.md for search feature --- UserGuide.md | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/UserGuide.md b/UserGuide.md index f4db1a8..2de243a 100644 --- a/UserGuide.md +++ b/UserGuide.md @@ -18,4 +18,32 @@ This feature allows users to repost a topic to a different category, as demonstr ![alt text](userGuide-images/image4.png) ### Testing -- There are no additional tests for this feature, since it was built into another feature that already had test coverage. \ No newline at end of file +- There are no additional tests for this feature, since it was built into another feature that already had test coverage. + +## Search for post topics using specific keywords +This feature allows users to enter a search keyword and filter the post list to only include post topics containing the keyword. +1. Navigate to any page that contains a list of posts (e.g. a category such as 'General Discussion' or a page such as 'Recent'): + ![alt text](userGuide-images/search-feature-1.png) +2. Enter characters into the search bar near the top (highlighted in red): + ![alt text](userGuide-images/search-feature-2.png) +3. The post list will update to only contain posts topics that contain the search term. + ![alt text](userGuide-images/search-feature-3.png) + +### Testing +Automated tests for this feature are located in the test/topics/search.js file. These test the Topics.searchByKeyword function that filters topics according to the keyword and is used by the backend API. +To test this feature, run: +``` +npm run test +``` +To add a test, +1. Provide a query object with the 'keyword' and 'initTopics' (list of topics to search from ) properties. +2. Pass the query into Topics.searchByKeyword() and ensure the resulting array matches the expected behavior. + +These tests cover scenarios including: +- Listing all post with topics that contain the keyword +- Showing no posts if none of their topics match the keyword +- Showing no posts if there are none to search from despite there being a keyword +- Listing all post topics if the the keyword is empty +- Ensuring search is case-insensitive +- Verifying post topics with partial matches to the keyword are shown +These tests are sufficient to test the feature and ensure the acceptance criteria is met because it verifies that the function correctly filters topics that contain the keyword, handles edge cases, is case-insensitive, and overall behaves as expected no matter the query.