Skip to content

Gayatri - fix(job-form-builder): warn on duplicate questions in Add/Append flows (Ticket #8) - #5523

Open
sawantgayatri19 wants to merge 1 commit into
developmentfrom
gayatri/job-form-duplicate-question-warning
Open

Gayatri - fix(job-form-builder): warn on duplicate questions in Add/Append flows (Ticket #8)#5523
sawantgayatri19 wants to merge 1 commit into
developmentfrom
gayatri/job-form-duplicate-question-warning

Conversation

@sawantgayatri19

Copy link
Copy Markdown

Description

Fixes # 8 (bug list priority medium — Application/Job Posting Page: Application Form Template — Handle Duplicate Questions Gracefully)

In the /jobformbuilder template builder, the form allowed multiple identical questions to be added without any warning, which could lead to cluttered forms and duplicate data — both via the "Add Question" flow and the "Append Template" flow.

This PR implements soft validation: when a duplicate (or near-duplicate) question is detected, the user sees a warning and can choose to proceed anyway or cancel. If there's no duplicate, the question is added normally with no extra prompt.

Related PRs (if any):
None. This is a standalone frontend change — no backend changes required.

Main changes explained:

  • Update jobFormQuestionUtils.js — added normalizeQuestionText (trims, collapses whitespace, lowercases, strips trailing punctuation for comparison), isDuplicateQuestion (checks a single candidate against existing fields), and findDuplicateQuestions (checks a batch of candidates against existing fields and against each other, for the template-append case).
  • Update JobFormbuilder.jsx — the "Add Question" handler now calls isDuplicateQuestion before adding a new field; if a match is found, shows window.confirm("You already have a similar question. Add Anyway?"); cancelling aborts the add, confirming proceeds as normal.
  • Update QuestionSetManager.jsx — the "Append Template" handler now calls findDuplicateQuestions against the current form fields before merging in a template's questions; if any overlaps are found, shows a count-based confirm dialog; declining filters out only the overlapping questions while still appending the non-overlapping ones, confirming appends everything.
  • Create jobFormQuestionUtils.duplicateDetection.test.js — 16 unit tests covering isDuplicateQuestion and findDuplicateQuestions as pure functions (exact matches, case/whitespace/punctuation variants, empty inputs, batch-internal duplicates).

How to test:

  1. Check out this branch: gayatri/job-form-duplicate-question-warning
  2. npm install (or yarn), then run the frontend dev server as usual
  3. Log in as a user with job-form management permissions
  4. Go to /jobformbuilder
  5. Test unique add: In "Field Label," type a brand-new question and click Add Field → it should be added instantly, no popup
  6. Test duplicate warning (Add Question): Add the same question text again → confirm dialog appears: "You already have a similar question. Add Anyway?"
    • Click Cancel → question is not added, form unchanged
    • Repeat and click OK → question is added as a duplicate entry
  7. Test duplicate warning (Append Template):Save the current question set as a template, then remove one of its fields from the live form, then click "Append Template" and select that template → confirm dialog appears showing a count of overlapping questions
    • Cancel → only the non-overlapping questions from the template get merged in, overlapping ones are skipped
    • OK → all questions (including duplicates) get merged in
  8. Run unit tests: npx vitest src/components/Collaboration/__tests__/jobFormQuestionUtils.duplicateDetection.test.js → 16/16 should pass

Screenshots or videos of changes:

Note:
No backend changes were needed — duplicate detection is purely a frontend/client-side soft-validation feature, matching the original ticket's expected outcome ("never fully block adding a question").

Implements soft duplicate detection for Ticket #8:
- normalizeQuestionText / isDuplicateQuestion / findDuplicateQuestions
  helpers in jobFormQuestionUtils.js
- Add Question flow (JobFormbuilder.jsx) warns via confirm dialog on
  exact/near-exact duplicate, user can proceed or cancel
- Append Template flow (QuestionSetManager.jsx) warns on overlapping
  questions (against existing fields and within the template batch),
  filters out declined duplicates while still merging non-overlapping
  questions
- 16 unit tests covering both helpers
@netlify

netlify Bot commented Sep 9, 2026

Copy link
Copy Markdown

Deploy Preview for highestgoodnetwork-dev ready!

Name Link
🔨 Latest commit 6aa65ea
🔍 Latest deploy log https://app.netlify.com/projects/highestgoodnetwork-dev/deploys/6aa196ebcacd550008668593
😎 Deploy Preview https://deploy-preview-5523--highestgoodnetwork-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@sonarqubecloud

sonarqubecloud Bot commented Sep 9, 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.

2 participants