Skip to content

test(e2e): fill onboarding Benefits step dynamically - #1361

Merged
gabrielseco merged 8 commits into
mainfrom
e2e-germany-dynamic-benefits
Sep 23, 2026
Merged

gabrielseco merged 8 commits into
mainfrom
e2e-germany-dynamic-benefits

Conversation

@gabrielseco

@gabrielseco gabrielseco commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

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
  • New helper example/e2e/helpers/benefits.ts:
    • watchForBenefitsSchema(page) — registers a page.waitForResponse listener for the benefit-offers/schema request. Must be registered before the Introduction step submits: useBenefitOffersSchema is 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 through createHeadlessForm (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's value after its filter is picked) get filled too. Feeds back a real nested initialValues object (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-kit added as a devDependency of example/ (previously only resolvable indirectly via the @remoteoss/remote-flows symlink), since it's ESM-only and loaded via dynamic import() from the CommonJS e2e helper.
  • onboard-germany-employee.spec.ts and onboard-basic-employee.spec.ts (Spain) both now fill Benefits via the new helper.
  • fillOnboardingStep4SpainForm removed from example/e2e/helpers/onboarding.ts — no longer used.

Screenshots

N/A

Related Resources

N/A

Testing

  • Tested against the example/ app in a browser
  • Feature flag: N/A

Note

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).

watchForBenefitsSchema must be registered before Introduction submits because the benefit-offers/schema request fires when employment is created. fillOnboardingBenefitsStepDynamically uses the intercepted schema with createHeadlessForm (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 calls handleValidation in a loop so fields like value after filter appear. The old fillOnboardingStep4SpainForm is removed.

@remoteoss/remote-json-schema-form-kit is added as an example/ devDependency. .cursor/rules/json-schema-form-usage.mdc and CLAUDE.md document calling createHeadlessForm once and using handleValidation on 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.

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>
@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Deploy preview for adp-cost-calculator ready!

Project:adp-cost-calculator
Status: ✅  Deploy successful!
Preview URL:https://adp-cost-calculator-di9gbrqo3-remotecom.vercel.app
Latest Commit:b4bb04a

Deployed with vercel-action

@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Deploy preview for remote-flows ready!

Project:remote-flows
Status: ✅  Deploy successful!
Preview URL:https://remote-flows-kauwnlsc9-remotecom.vercel.app
Latest Commit:b4bb04a

Deployed with vercel-action

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread example/e2e/helpers/benefits.ts Resolved
@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

📊 Coverage Report

⚪ Coverage unchanged

Metric Current Previous Change Status
Lines 86.34% 86.34% 0% ⚪
Statements 85.91% 85.91% 0% ⚪
Functions 84.92% 84.92% 0% ⚪
Branches 77.77% 77.77% 0% ⚪

Detailed Breakdown

Lines Coverage
  • Covered: 4849 / 5616
  • Coverage: 86.34%
  • Change: 0% (0 lines)
Statements Coverage
  • Covered: 4933 / 5742
  • Coverage: 85.91%
  • Change: 0% (0 statements)
Functions Coverage
  • Covered: 1290 / 1519
  • Coverage: 84.92%
  • Change: 0% (0 functions)
Branches Coverage
  • Covered: 3001 / 3859
  • Coverage: 77.77%
  • Change: 0% (0 branches)

✅ Coverage check passed

gabrielseco and others added 3 commits September 22, 2026 12:15
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>
@gabrielseco gabrielseco changed the title test(e2e): fill Germany onboarding Benefits step dynamically test(e2e): fill onboarding Benefits step dynamically Sep 22, 2026
gabrielseco and others added 2 commits September 22, 2026 12:39
…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>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread example/e2e/helpers/benefits.ts Resolved
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>
@gabrielseco
gabrielseco merged commit 7eed6f4 into main Sep 23, 2026
12 checks passed
@gabrielseco
gabrielseco deleted the e2e-germany-dynamic-benefits branch September 23, 2026 08:23
@gabrielseco gabrielseco mentioned this pull request Sep 25, 2026
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.

2 participants