Repository navigation
test(e2e): fill onboarding Benefits step dynamically - #1361
Merged
Merged
Conversation
Replaces the bare "Benefits" title assertion with a real fill: intercepts the benefit-offers schema response and drives createHeadlessForm (the same engine the app runs) to discover visible radio/select fields round by round, so conditionally-revealed fields (e.g. a benefit's "value" after its "filter" is picked) get filled without hardcoding a country's benefit-group UUIDs, unlike the existing Spain-only helper. Extends the assertion through the Review step. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Contributor
|
Deploy preview for adp-cost-calculator ready!
Deployed with vercel-action |
Contributor
|
Deploy preview for remote-flows ready!
Deployed with vercel-action |
Contributor
📊 Coverage Report⚪ Coverage unchanged
Detailed BreakdownLines Coverage
Statements Coverage
Functions Coverage
Branches Coverage
✅ Coverage check passed |
watchForBenefitsSchema silently fell back to an empty schema on a non-2xx response, turning a real API failure into a confusing downstream submit/validation failure instead of a clear error at the point of interception. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- Register the benefit-offers schema listener before Introduction submits (creates the employment), not before Contract Details: useBenefitOffersSchema is enabled as soon as employmentId exists, so the request had already resolved by the time the old listener was registered, and waitForResponse hung until timeout. - Feed createHeadlessForm a real nested initialValues object instead of a flat one keyed by the dotted data-field string. The dotted string is only valid as a DOM lookup key; the schema's own if/then conditionals read a nested object, so a benefit's "value" field never appeared once its "filter" was picked. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Replaces fillOnboardingStep4SpainForm's hardcoded sandbox-company benefit-group UUIDs with the same schema-driven helper the Germany spec now uses, so both onboarding e2e tests fill Benefits generically instead of one of them being tied to one company's fixed field names. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…eHeadlessForm createHeadlessForm is called once and handleValidation is used to re-evaluate conditionals each round: both jsf v0 and v1 mutate the same `fields` array in place rather than returning a new one, so recomputing the whole form from scratch every round was redundant. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Documents the pattern discovered while building the dynamic Benefits e2e helper: call createHeadlessForm once and recompute conditionals via handleValidation (which mutates the same fields array in place for both jsf v0 and v1) instead of re-calling createHeadlessForm on every value change. Notes the existing src/flows/*/api.ts hooks that do the latter as accepted legacy debt, not the pattern for new code. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
gabrielseco
force-pushed
the
e2e-germany-dynamic-benefits
branch
from
September 23, 2026 07:15
5114a4b to
971f3b0
Compare
1 of 2 tasks
jordividaller
approved these changes
Sep 23, 2026
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 1472751. Configure here.
handled marked a field done as soon as it was seen, even when its options list was still empty (e.g. a benefit's "value" field before its sibling "filter" is set). Once handleValidation later populated those options, the field was never revisited and stayed blank. Now a field is only marked handled once it's actually filled, and the loop only gives up (and logs the skip annotation) once a full round makes no progress. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Merged
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.

Summary
Extends the Germany and Spain onboarding e2e tests to actually fill the Benefits step (Germany previously only asserted the step title; Spain used a helper hardcoded to one sandbox company's benefit-group UUIDs) using the real schema returned by the API, for both flows.
Why
The only prior Benefits-step filler (
fillOnboardingStep4SpainForm) hardcoded that sandbox company's specific benefit-group UUIDs as field names, which only works for that one country/company. Rather than write another one-off hardcoded filler for Germany, this fills the step dynamically from whatever schema the API actually returns, and replaces the Spain helper with the same approach so there's one way to do this instead of two.What changed
Toggle details
example/e2e/helpers/benefits.ts:watchForBenefitsSchema(page)— registers apage.waitForResponselistener for thebenefit-offers/schemarequest. Must be registered before the Introduction step submits:useBenefitOffersSchemais enabled as soon as the employment is created there, not when the user reaches the Benefits step, so registering it any later misses the request.fillOnboardingBenefitsStepDynamically(page, schemaPromise)— feeds the intercepted schema throughcreateHeadlessForm(the same engine, from@remoteoss/remote-json-schema-form-kit, that the app itself uses) to compute the currently visible fields, picks the first option for each radio/select, and re-derives the fields after each round so fields that only appear once a sibling field is set (e.g. a benefit'svalueafter itsfilteris picked) get filled too. Feeds back a real nestedinitialValuesobject (not a flat object keyed by the dotted DOM lookup string) since the schema's own conditional logic reads nested values. Keeps the existing "Locked Benefit" skip-guard.@remoteoss/remote-json-schema-form-kitadded as a devDependency ofexample/(previously only resolvable indirectly via the@remoteoss/remote-flowssymlink), since it's ESM-only and loaded via dynamicimport()from the CommonJS e2e helper.onboard-germany-employee.spec.tsandonboard-basic-employee.spec.ts(Spain) both now fill Benefits via the new helper.fillOnboardingStep4SpainFormremoved fromexample/e2e/helpers/onboarding.ts— no longer used.Screenshots
N/A
Related Resources
N/A
Testing
example/app in a browserNote
Low Risk
Changes are limited to e2e helpers, example dependencies, and contributor docs; no production app or API behavior is modified.
Overview
Onboarding e2e for Spain and Germany now completes the Benefits step with a shared helper instead of Spain-only hardcoded benefit-group UUIDs (Germany previously only checked the step title).
watchForBenefitsSchemamust be registered before Introduction submits because thebenefit-offers/schemarequest fires when employment is created.fillOnboardingBenefitsStepDynamicallyuses the intercepted schema withcreateHeadlessForm(dynamic ESM import in the e2e package), walks visible radio/select fields, fills the first option in the DOM, and keeps a nested values object for conditionals—then callshandleValidationin a loop so fields likevalueafterfilterappear. The oldfillOnboardingStep4SpainFormis removed.@remoteoss/remote-json-schema-form-kitis added as anexample/devDependency..cursor/rules/json-schema-form-usage.mdcandCLAUDE.mddocument callingcreateHeadlessFormonce and usinghandleValidationon value changes (not re-calling on every change).Reviewed by Cursor Bugbot for commit b4bb04a. Bugbot is set up for automated code reviews on this repo. Configure here.