From 51f99134c3c0f6cbf23ae0f1162e5607abefbdbc Mon Sep 17 00:00:00 2001 From: Amey Bhagwat Date: Fri, 20 Nov 2026 18:05:01 +0530 Subject: [PATCH] # changed city and state field mandatory for Survey questions. --- backend/src/survey/definition.js | 4 ++-- backend/test/survey.test.js | 15 +++++++++++++++ help/study_questionnaire.md | 4 ++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/backend/src/survey/definition.js b/backend/src/survey/definition.js index 27e3a5b..3f35af4 100644 --- a/backend/src/survey/definition.js +++ b/backend/src/survey/definition.js @@ -136,13 +136,13 @@ export const surveyDefinition = { { id: 'other', label: 'Other (specify)' }, ], }, - { id: 'city', type: 'short_text', label: 'City', required: false }, + { id: 'city', type: 'short_text', label: 'City', required: true }, { id: 'state', type: 'single_choice', display: 'dropdown', label: 'State', - required: false, + required: true, options: stateOptions, }, ], diff --git a/backend/test/survey.test.js b/backend/test/survey.test.js index 279113a..6762b01 100644 --- a/backend/test/survey.test.js +++ b/backend/test/survey.test.js @@ -83,6 +83,21 @@ function sample(question) { } describe('survey answers', () => { + it('requires city and state on the live demographics section', () => { + const demographics = { + sections: [surveyDefinition.sections.find((section) => section.id === 'demographics')], + }; + const messages = validateAnswers(demographics, {}).map((item) => item.message); + expect(messages).toContain('City is required'); + expect(messages).toContain('State is required'); + expect( + validateAnswers(demographics, { + city: 'Pune', + state: { choice: 'maharashtra' }, + }).map((item) => item.message), + ).not.toEqual(expect.arrayContaining(['City is required', 'State is required'])); + }); + it('validates each question type', () => { expect( validateAnswers( diff --git a/help/study_questionnaire.md b/help/study_questionnaire.md index e7e4b58..74c5802 100644 --- a/help/study_questionnaire.md +++ b/help/study_questionnaire.md @@ -13,8 +13,8 @@ - **Years of Practice:** ______ - **Practice setting** (multi-select): Private Clinic / Private Hospital / Govt. Hospital / Other (please specify): ______ - **Specialization** (single choice): Chest Physician / Consulting Physician / Other (specify): ______ -- **City:** ______ -- **State** (dropdown): all Indian states and union territories +- **City:** ______ (required) +- **State** (dropdown, required): all Indian states and union territories ## Section 2: Physician Practice Profile