Skip to content

Sayali - feat: Add Backend API for Help Feedback Modal and Request Tracking#2045

Merged
one-community merged 3 commits intodevelopmentfrom
Sayali_HGN_Feedback_Modal_Backend
Feb 17, 2026
Merged

Sayali - feat: Add Backend API for Help Feedback Modal and Request Tracking#2045
one-community merged 3 commits intodevelopmentfrom
Sayali_HGN_Feedback_Modal_Backend

Conversation

@sayali-2308
Copy link
Contributor

@sayali-2308 sayali-2308 commented Feb 13, 2026

Screenshot 2026-02-12 223531

Description

Fixes #15 (PRIORITY URGENT) from HGN Phase I Bugs and Needed Functionalities doc - Backend support for HGN Feedback Modal: Service Worker Registration Failure

Created complete help request tracking system from scratch to enable the feedback modal to auto-trigger 1 week after help requests are made. This system did not exist in the codebase prior to this PR.

Related PRS (if any):

This backend PR is related to the #4835 frontend PR.
To test this backend PR you need to checkout the #4835 frontend PR.

Main changes explained:

  • Created src/models/helpRequest.js for tracking when users make help requests (includes userId, requestedAt, topic, description, status, feedbackSubmitted fields)
  • Created src/models/helpFeedback.js for storing feedback submissions with member ratings (includes userId, helpRequestId, receivedHelp, activeMembers/inactiveMembers arrays, comments, closedPermanently)
  • Created src/controllers/helpRequestController.js with createHelpRequest, checkIfModalShouldShow (1-week trigger logic), updateRequestDate (FOR TESTING ONLY), getAllHelpRequests (FOR TESTING ONLY)
  • Created src/controllers/helpFeedbackController.js with submitFeedback (saves feedback and marks help request complete), closePermanently (saves user preference)
  • Created src/routes/helpRequestRouter.js for /api/helprequest endpoints
  • Created src/routes/helpFeedbackRouter.js for /api/feedback endpoints
  • Updated src/app.js to add routes after bodyParser and before other middleware (bypasses auth for these endpoints)

How to test:

  1. Checkout backend branch: Sayali_HGN_Feedback_Modal_Backend
  2. Checkout frontend branch: Sayali_HGN_Feedback_Modal_Fix
  3. Run npm install in backend repo
  4. Start backend: npm run start (runs on port 4500)
  5. Start frontend: npm run start:local (runs on port 5173)
  6. Have Postman installed for API testing

Test Case 1: Create Help Request API

  1. In Postman, send POST request:
    POST http://localhost:4500/api/helprequest/create
    Body (raw JSON):
   {
     "userId": "69779f8d889b15074b785a02",
     "topic": "Need help with React",
     "description": "Having state management issues"
   }
  1. Verify response: 201 Created with help request data including _id, status: "open", feedbackSubmitted: false, requestedAt (current timestamp)

Test Case 2: Check Modal Should NOT Show (New Request)

  1. In Postman, send GET request:
    GET http://localhost:4500/api/helprequest/check-modal/69779f8d889b15074b785a02
  2. Verify response: 200 OK with {"shouldShow": false}
  3. This is correct because request was just created, not 1 week old

Test Case 3: Get All Help Requests (Test Endpoint)

  1. In Postman, send GET request:
    GET http://localhost:4500/api/helprequest/all
  2. Verify response: 200 OK with array of all help requests
  3. Copy the _id from Test Case 1 response

Test Case 4: Update Date to 1 Week Ago (Test Endpoint)

  1. In Postman, send PUT request:
    PUT http://localhost:4500/api/helprequest/update-date
    Body (raw JSON):
   {
     "helpRequestId": "ID_FROM_TEST_CASE_3",
     "requestedAt": "2026-02-05T16:27:43.015Z"
   }
  1. Verify response: 200 OK with updated help request showing requestedAt: "2026-02-05T16:27:43.015Z"

Test Case 5: Check Modal SHOULD Show (Old Request)

  1. In Postman, send GET request:
    GET http://localhost:4500/api/helprequest/check-modal/69779f8d889b15074b785a02
  2. Verify response: 200 OK with:
   {
     "shouldShow": true,
     "helpRequestId": "the_request_id",
     "requestedAt": "2026-02-05T16:27:43.015Z"
   }

Test Case 6: Submit Feedback API

  1. In Postman, send POST request:
    POST http://localhost:4500/api/feedback/submit
    Body (raw JSON):
   {
     "userId": "69779f8d889b15074b785a02",
     "helpRequestId": "ID_FROM_TEST_CASE_3",
     "receivedHelp": "yes",
     "activeMembers": [
       {"name": "Test User", "rating": 3},
       {"name": "Another User", "rating": 5}
     ],
     "inactiveMembers": [],
     "comments": "Great help from the team!"
   }
  1. Verify response: 201 Created with feedback data
  2. Check MongoDB: Help request's feedbackSubmitted field should be updated to true

Test Case 7: Modal Should NOT Show After Feedback Submitted

  1. In Postman, send GET request:
    GET http://localhost:4500/api/helprequest/check-modal/69779f8d889b15074b785a02
  2. Verify response: 200 OK with {"shouldShow": false}
  3. This is correct because feedback was already submitted

Test Case 8: Close Permanently API

  1. In Postman, send POST request:
    POST http://localhost:4500/api/feedback/close-permanently
    Body (raw JSON):
   {
     "userId": "69779f8d889b15074b785a02"
   }
  1. Verify response: 200 OK
  2. Check MongoDB: New feedback document created with closedPermanently: true

Test Case 9: Integration Test with Frontend

  1. Ensure backend is running on port 4500
  2. Open frontend at http://localhost:5173/hgnhelp/feedback with frontend PR checked out
  3. Verify modal appears if 1-week-old help request exists for logged-in user
  4. Fill out form and submit
  5. Verify data saves to MongoDB via backend API

Screenshots or videos of changes:

image image image image image image

Note:

  • Routes are added in app.js BEFORE auth middleware to bypass authentication requirements
  • Routes positioned after bodyParser to ensure req.body is parsed correctly
  • Test endpoints updateRequestDate and getAllHelpRequests are marked "FOR TESTING ONLY" - they allow reviewers to test the 1-week trigger logic without waiting an actual week
  • The help request tracking system was built entirely from scratch as it did not exist in the codebase
  • This PR works together with frontend PR #4835

Created help request tracking system and feedback submission API.
Includes models, controllers, and routes for feedback modal feature.
@one-community one-community added the High Priority - Please Review First This is an important PR we'd like to get merged as soon as possible label Feb 14, 2026
@one-community one-community changed the title feat: Add Backend API for Help Feedback Modal and Request Tracking Sayali - feat: Add Backend API for Help Feedback Modal and Request Tracking Feb 14, 2026
Copy link

@Anusha-Gali Anusha-Gali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Sayali,

I have reviewed your PR locally and have successfully validated all API responses.

Test case 1
Image

Test case 2
Image

Test case 3
Image

Test case 4
Image

Test case 5
Image

Test case 6
Image
Image
Image
Image

Test case 7
Image

Test case 8
Image

Test case 9
OneCommunityGlobal/HighestGoodNetworkApp#4835 (review)

@maithili20
Copy link

Hi @sayali-2308
Reviewed your PR and everything is working as expected.

Testcase1
Testcase1
Testcase2
Testcase2
Testcase3
Testcase3
Testcase4
Screenshot 2026-02-16 at 4 30 56 PM
Testcase5
Screenshot 2026-02-16 at 4 34 36 PM
Testcase6
Screenshot 2026-02-16 at 4 36 20 PM
Testcase 7
Screenshot 2026-02-16 at 4 36 41 PM
Testacse8
Screenshot 2026-02-16 at 4 37 39 PM
Screenshot 2026-02-16 at 4 41 49 PM
Testcase 9
Left my comments on FE PR - OneCommunityGlobal/HighestGoodNetworkApp#4835 (comment)

@one-community
Copy link
Member

Thank you all, merging!

@one-community one-community merged commit e9b0c09 into development Feb 17, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

High Priority - Please Review First This is an important PR we'd like to get merged as soon as possible

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Comments