Skip to content

Purav-taking-over-job-form-issues-backend - #2333

Open
pixelpix13 wants to merge 3 commits into
developmentfrom
Purav-job-form-issues-backend
Open

Purav-taking-over-job-form-issues-backend#2333
pixelpix13 wants to merge 3 commits into
developmentfrom
Purav-job-form-issues-backend

Conversation

@pixelpix13

@pixelpix13 pixelpix13 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Description

This PR takes over and finishes the backend work for the Job Application Page (/job-application) form fixes (Priority High). It supersedes the original backend PR #2318 by rebasing the feature onto current development and adding fixes found during live testing.

Paired frontend PR (required for end-to-end testing): OneCommunityGlobal/HighestGoodNetworkApp#5502 — branch Purav-fix-job-application-form-issues

Applicants can submit applications without a JWT, duplicate emails are blocked per form, confirmation emails are sent (non-fatal), resumes and per-question file uploads are stored in Azure (non-fatal), and the job title dropdown loads distinct titles from the jobs collection.

Related PRs

Repo Branch PR Role
HGNRest (this PR) Purav-job-form-issues-backend #2333 Takeover backend — rebased on current development
HGNRest (superseded) job-form-issues-backend #2318 Original backend PR (Sohail → Purav takeover)
HighestGoodNetworkApp (paired) Purav-fix-job-application-form-issues #5502 Takeover frontend — required for end-to-end testing
HighestGoodNetworkApp (superseded) fix-job-form-issues-frontend #5469 Original frontend PR

To test end-to-end: check out Purav-job-form-issues-backend on HGNRest and Purav-fix-job-application-form-issues on HighestGoodNetworkApp (#5502).

What changed vs the old PR (#2318)

  • Fresh branch created from latest development (not a direct merge of job-form-issues-backend, which was behind and would have overwritten newer job-form admin code)
  • Only job-application feature changes were ported; unrelated pr-grading commits and package-lock.json churn were excluded
  • Fix after live test: the live form sends a payload JSON body plus questionFile_* multipart fields (resume + second upload). Switched from upload.single('resume') to upload.any() and added payload parsing so cover-letter uploads no longer cause MulterError: Unexpected field / 500

Main changes explained

  • jobApplicationsModel.js — added email and resumeUrl fields for duplicate detection and resume storage
  • jobsController.js — added getActiveJobPositions (Job.distinct('title'), sorted alphabetically)
  • jobsRouter.js/positions → active job titles; old getPositions (JobPositionCategory) moved to /position-categories; route ordering preserved
  • collaborationController.js — added submitFormResponse: 400 on missing fields, 404 if form not found, 409 on duplicate email, optional Azure resume + question-file uploads (non-fatal), confirmation email via emailSender (non-fatal), 201 on success; accepts both flat fields and payload JSON from the live frontend
  • collaborationRouter.jsPOST /jobforms/:formId/responses with upload.any() middleware
  • middleware.js — public exemptions for GET /api/jobforms/all, GET /api/jobforms/:id, and POST /api/jobforms/:id/responses
  • Tests — collaborationController.test.js (new) and jobsController.test.js (getActiveJobPositions)

How to test

  1. Check out branch Purav-job-form-issues-backend on HGNRest and Purav-fix-job-application-form-issues on HighestGoodNetworkApp (#5502)
  2. Run npm install if needed on both repos
  3. Backend: npm run build then npm start (HGNRest, default port 4500)
  4. Frontend: npm run start:localhttp://localhost:5173
  5. Open the job application page (e.g. /job-application) — no login required for applicants
  6. Select or enter a job title; confirm the form loads
  7. Fill required fields, upload a resume, and upload a file on a question that supports second upload (e.g. question 14)
  8. Submit — expect 201 and success toast; form fields should reset
  9. Repeat submit with the same email — expect 409 Conflict
  10. Backend direct (Postman/Insomnia):
    • GET /api/jobs/positions{ positions: ["Title A", ...] }
    • POST /api/jobforms/:formId/responses without JWT → 201
    • Invalid formId → 404; missing email → 400
  11. Tests: npm test -- src/controllers/collaborationController.test.js src/controllers/jobsController.test.js
  12. Verify dark mode on the frontend PR (#5502) when testing UI

Screenshots or videos of changes

pr_5502_2333_1 pr_5502_2333_2 pr_5502_2333_3
pr_5502_2333_video.mp4

Note

…ositions list

Give the job application page backend support on current development so applicants can submit without a JWT, resume uploads and confirmation emails are stored or sent, and the dropdown loads distinct job titles.
…oads

The live form posts a payload JSON body plus questionFile_* fields, which multer.single(resume) rejected before save. Accept any multipart files so resume and second uploads are stored.
Extract answer-building and email helpers to satisfy Sonar cognitive complexity, and add coverage for invalid payload, save failures, and failed question-file uploads.
@pixelpix13
pixelpix13 force-pushed the Purav-job-form-issues-backend branch from fb9a22f to 64c0a1d Compare September 3, 2026 20:09
@sonarqubecloud

sonarqubecloud Bot commented Sep 3, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant