Skip to content

fix(forms): make the JobStart age/disability gate answerable - #2207

Open
phrogwrld wants to merge 1 commit into
mainfrom
fix-jobstart-eligibility-gate
Open

phrogwrld wants to merge 1 commit into
mainfrom
fix-jobstart-eligibility-gate

Conversation

@phrogwrld

Copy link
Copy Markdown
Contributor

Refs #2199 ("If I click no. I cant type in the free text box but its mandatory").

Problem

JobStart Plus gates applicants aged 25+ who have no disability or long-term
health condition. That gate was implemented as a disabled, required text
field
in the disability-support step:

{
  "ref": "components/generic-text",
  "overrides": {
    "isDisabled": true,
    "label": "Are you 25 years or older, without a disability?",
    "validations": {
      "required": { "value": true, "error": "If you are over 24, you must have a disability..." },
      "equal": { "error": "If you are over 24, you must have a disability..." }
    },
    "behaviours": [
      { "type": "fieldConditionalOn", "targetFieldId": "applicant-dob",
        "operator": "gte", "value": "25", "transform": "yearsSince" },
      { "type": "optionalIf", "targetFieldId": "has-disability", "value": "yes" }
    ]
  }
}

Three defects in one element:

  1. Unsatisfiable. A 25+ applicant answering "no" saw a greyed-out box they
    could not type into, blocking Continue with no way forward.
  2. No fieldId. It fell back to the registry default (generic-text), so it
    submitted under a junk key and would collide with any other defaulted
    generic-text field in the step.
  3. Dead equal rule. An error with no value can never fire, so only
    required ever did anything.

Fix

Same gate, expressed the way this recipe already gates eligibility 40 lines away
(currently-employed): a radio carrying equal. Visibility, copy and policy are
unchanged — the applicant can now answer, and gets the authored message.

Verified against the real hydrated contract with the production validator
(@govtech-bb/form-validation):

Answer Result
"Yes" (25+, no disability) blocked — "If you are over 24, you must have a disability or long-term health condition to apply."
"No" passes
unanswered required error (only when visible, i.e. 25+ and has-disability != yes)

optionalIf relaxes only required (validation-builder.ts,
form-conditions/index.ts), so a conditionally-applied equal is not
expressible — which is why the gate stays a separate age-scoped control rather
than moving onto has-disability.

Guard

recipe-invariants.spec.ts now rejects any disabled-and-required field across all
76 recipes, with a negative test proving it bites. This was the only occurrence.

Verification

  • nx run api:test — 1277 pass (was 1276; the new negative test)
  • nx run api:build — green
  • tsc -b — clean
  • jobstart-plus-programme.smoke.spec.ts needs no change: it uses a 21-year-old,
    so the gate stays hidden

Note

Kept the hard block, since the recipe's own hint states the policy ("If you are
over 24, you must have a disability or long-term health condition to apply"). If
the intent is instead to let these applicants submit and be filtered later, say
so — that's a one-line change to drop the equal rule.

The gate was a disabled, required text field: applicants 25 or over who
answered "no" to the disability question got a greyed-out box they could
not fill and could not get past. It also carried no fieldId (falling back
to the registry default) and an `equal` rule with an error but no value,
so only `required` ever fired.

Now a radio with the recipe's existing `equal` gate pattern — same
visibility, same copy, same policy, but answerable. Adds a recipe
invariant rejecting disabled-and-required fields.

Refs #2199
@amazon-inspector-n-virginia

Copy link
Copy Markdown

⏳ I'm reviewing this pull request for security vulnerabilities and code quality issues. I'll provide an update when I'm done

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

Amplify PR previews

App Status URL
forms ⏭ Not affected
landing ⏭ Not affected
chat ⏭ Not affected
form-builder ⏭ Not affected
analytics ⏭ Not affected

Commit: e76979e · Branches auto-delete when this PR closes.

ℹ️ feature-flagging uses a single shared preview slot at a fixed URL (preview.feature-flagging.sandbox.alpha.gov.bb) — GitHub login works, but only one FF preview exists at a time (the most recent FF PR build wins). It reads/writes sandbox flag data.

@amazon-inspector-n-virginia

Copy link
Copy Markdown

✅ I finished the code review, and didn't find any security or code quality issues.

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