Gayatri - fix(job-form-builder): warn on duplicate questions in Add/Append flows (Ticket #8) - #5523
Open
sawantgayatri19 wants to merge 1 commit into
Open
Conversation
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
✅ Deploy Preview for highestgoodnetwork-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



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:
jobFormQuestionUtils.js— addednormalizeQuestionText(trims, collapses whitespace, lowercases, strips trailing punctuation for comparison),isDuplicateQuestion(checks a single candidate against existing fields), andfindDuplicateQuestions(checks a batch of candidates against existing fields and against each other, for the template-append case).JobFormbuilder.jsx— the "Add Question" handler now callsisDuplicateQuestionbefore adding a new field; if a match is found, showswindow.confirm("You already have a similar question. Add Anyway?"); cancelling aborts the add, confirming proceeds as normal.QuestionSetManager.jsx— the "Append Template" handler now callsfindDuplicateQuestionsagainst 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.jobFormQuestionUtils.duplicateDetection.test.js— 16 unit tests coveringisDuplicateQuestionandfindDuplicateQuestionsas pure functions (exact matches, case/whitespace/punctuation variants, empty inputs, batch-internal duplicates).How to test:
gayatri/job-form-duplicate-question-warningnpm install(oryarn), then run the frontend dev server as usual/jobformbuildernpx vitest src/components/Collaboration/__tests__/jobFormQuestionUtils.duplicateDetection.test.js→ 16/16 should passScreenshots 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").