From 13e5bc95331647d61fcf78042c6f36221691dad0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 5 Mar 2026 23:07:38 +0000 Subject: [PATCH 1/2] Initial plan From bb16d9709a5143cd5948ada2a36ae3df6918454c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 5 Mar 2026 23:16:28 +0000 Subject: [PATCH 2/2] fix: use safe router.push object form and add /users/search tests Co-authored-by: elifouts <116454864+elifouts@users.noreply.github.com> --- backend/api/internal/tests/main_test.go | 1 + backend/api/internal/tests/user_test.go | 22 ++++++++++++++++++++++ frontend/app/(tabs)/message.tsx | 4 ++-- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/backend/api/internal/tests/main_test.go b/backend/api/internal/tests/main_test.go index 38baf53..fdf06e0 100644 --- a/backend/api/internal/tests/main_test.go +++ b/backend/api/internal/tests/main_test.go @@ -80,6 +80,7 @@ func setupTestRouter() *gin.Engine { router.GET("/auth/me", handlers.RequireAuth(), handlers.GetMe) router.GET("/users", handlers.GetUsers) + router.GET("/users/search", handlers.SearchUsers) router.GET("/users/:username", handlers.GetUserByUsername) router.GET("/users/id/:user_id", handlers.GetUserById) router.POST("/users", handlers.RequireAuth(), handlers.CreateUser) diff --git a/backend/api/internal/tests/user_test.go b/backend/api/internal/tests/user_test.go index 27a187e..79f5214 100644 --- a/backend/api/internal/tests/user_test.go +++ b/backend/api/internal/tests/user_test.go @@ -199,4 +199,26 @@ var user_tests = []TestCase{ ExpectedStatus: http.StatusOK, ExpectedBody: `null`, }, + + // search users – empty q returns empty array + { + Method: http.MethodGet, + Endpoint: "/users/search?q=", + ExpectedStatus: http.StatusOK, + ExpectedBody: `[]`, + }, + // search users – prefix match returns matching users + { + Method: http.MethodGet, + Endpoint: "/users/search?q=dev", + ExpectedStatus: http.StatusOK, + ExpectedBody: `[{"bio":"Full-stack developer passionate about open-source projects.","creation_date":"2023-12-13T00:00:00Z","id":1,"links":["https://github.com/dev_user1","https://devuser1.com"],"picture":"https://example.com/dev_user1.jpg","settings":{"accentColor":"","backgroundRefreshEnabled":false,"compactMode":false,"refreshIntervalMs":120000,"zenMode":false},"username":"dev_user1"}]`, + }, + // search users – count is capped at 20 + { + Method: http.MethodGet, + Endpoint: "/users/search?q=d&count=100", + ExpectedStatus: http.StatusOK, + ExpectedBody: `[{"bio":"Data scientist with a passion for machine learning.","creation_date":"2023-06-13T00:00:00Z","id":3,"links":["https://github.com/data_scientist3","https://datascientist3.com"],"picture":"https://example.com/data_scientist3.jpg","settings":{"accentColor":"","backgroundRefreshEnabled":false,"compactMode":false,"refreshIntervalMs":120000,"zenMode":false},"username":"data_scientist3"},{"bio":"Full-stack developer passionate about open-source projects.","creation_date":"2023-12-13T00:00:00Z","id":1,"links":["https://github.com/dev_user1","https://devuser1.com"],"picture":"https://example.com/dev_user1.jpg","settings":{"accentColor":"","backgroundRefreshEnabled":false,"compactMode":false,"refreshIntervalMs":120000,"zenMode":false},"username":"dev_user1"}]`, + }, } diff --git a/frontend/app/(tabs)/message.tsx b/frontend/app/(tabs)/message.tsx index e9a2ae9..dcb4294 100644 --- a/frontend/app/(tabs)/message.tsx +++ b/frontend/app/(tabs)/message.tsx @@ -313,7 +313,7 @@ export default function MessageScreen() { setShowNewChatModal(false); setSearchQuery(""); setSuggestions([]); - router.push(`/conversation/${username}`); + router.push({ pathname: "/conversation/[username]", params: { username } }); }; const handleNewChat = () => { @@ -342,7 +342,7 @@ export default function MessageScreen() { setShowNewChatModal(false); setSearchQuery(""); setSuggestions([]); - router.push(`/conversation/${username}`); + router.push({ pathname: "/conversation/[username]", params: { username } }); }; const renderSuggestion = ({