wizard: detect the demographics block by qwac id, not by name (#47) - #48
Merged
Merged
Conversation
The survey preview used `name in selectedDemographics && !rationale` to
spot the appended demographics, and a model question about age that
happened to be called 'age' (and dropped its rationale) would be
mistaken for the first demographic. Everything after it — including the
real appended demographics — ended up under the 'automatically added'
divider.
Demographics carry their qwac question_id (constants.ts); model output
goes through question_parser with a synthetic 'q_${index}' id by
default. Switching the check to id-based makes the boundary
unambiguous, and the rationale check stays as a belt-and-braces guard
against a model that ever copies a qwac id verbatim.
* Extract `detectDemographicsStart` into a pure helper in
`src/lib/components/surveyView.ts` so it can be unit-tested.
* SurveyView prop: `demographicNames` -> `demographicIds`.
* Page maps the wizard's selected names to ids via the constants.
* New `surveyView.test.ts` with five cases, including the exact
failure from the issue (regression). Verified that the regression
test fails on the old name-based logic and passes on the fix.
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.
The survey preview used
name in selectedDemographics && !rationaleto spot the appended demographics. A model question about age that happened to be calledage(and dropped its rationale) was mistaken for the first demographic, and everything after it — including the real appended demographics — ended up under the "automatically added" divider.Why id is the right key. Demographics carry their qwac
question_id(constants.ts); model output goes throughquestion_parser.tswith a syntheticq_${index}id by default. So id-based detection is unambiguous; the rationale check stays as a belt-and-braces guard against a model that ever copies a qwac id verbatim.detectDemographicsStartinto a pure helper insrc/lib/components/surveyView.tsso it's unit-testable.SurveyViewprop:demographicNames→demographicIds.surveyView.test.tswith five cases, including the exact failure from the issue.Regression check. Temporarily reverted the helper to the old name-based logic and confirmed the new test fails (
expected -1 to be 3— the divider landed on the model'sagequestion instead of the realagedemographic). With the fix restored, all five pass.Verified:
npm run test:unit(87 pass, +5),npm run test:e2e(45 pass),npm run check,npm run lint.Closes #47.