Skip to content

fix(acceptance): seed child-slice parent BEFORE navigate + wait for the FK <option> (kills the relational-child e2e park) - #211

Merged
agjs merged 2 commits into
mainfrom
fix/child-slice-parent-fk-acceptance
Jul 28, 2026
Merged

fix(acceptance): seed child-slice parent BEFORE navigate + wait for the FK <option> (kills the relational-child e2e park)#211
agjs merged 2 commits into
mainfrom
fix/child-slice-parent-fk-acceptance

Conversation

@agjs

@agjs agjs commented Jul 28, 2026

Copy link
Copy Markdown
Owner

The wall

A relational child slice (a Contact with a companyId parent-FK rendered as a native <select>) parked: fast gate green, but the E2E acceptance timed out (Playwright 30s) on selectOption. Single-entity and parent slices crossed green fine — only children with a parent-<select> parked.

Root cause

The generated child-slice acceptance seeded the parent in the wrong order relative to the child page's async parent-list fetch:

  1. dashboard.goto() (auth) → 2. navigateTo<Child>() — child page mounts, fetches the parent list before any parent exists → 3. seed parent via API → 4. selectOption(seededId).

The fetched list never included the seed, so <option value="{seededId}"> never entered the DOM and selectOption waited the full 30s → false park.

The fix (scoped to the per-entity spec — what the build's slice acceptance uses)

  • generateEntitySpec seeds each form-driven mutating test (create/persist/update/delete) before navigateTo<Child>(), then waits for the seeded option[value] to attach before selectOption (belt-and-suspenders against the async fetch race). Seeding still runs after dashboard.goto() (needs the auth cookie).
  • generateParentSeedingCode takes withSelectNote (default true); the API-only negative blocks (POST directly, no <select>) seed with withSelectNote=false so the <select> rationale note isn't misleading there.

Tests

  • Per-block seed-before-navigateTo ordering, asserted for every form-driven test (create/persist/update/delete), not just the first spec-wide occurrence.
  • The <select> note is present in form tests but absent from the API-only negative block (which still seeds the parent).
  • Single-entity slice emits no FK wait/select (fix is scoped to relational children).
  • Contact fixture mirrors a real derived spec (FK appended last → identity resolves to name).

Validation

  • 4-model panel: PASS (all reviewers approved; one pre-existing minor dead-code advisory left as-is).
  • Live CRM build (Company + Contact belongsTo Company): FULL GREEN — both features verified, final acceptance (full validate + build + E2E + size) green, 2/2 resources verified. Contact no longer times out on the parent <select>; it reached (and passed) the downstream negative assertions, confirming the select step works.

Deferred (task #84)

FK-aware identity/first-field selection + chain-spec dangling-parent hardening — a class of generator fragility for inputs planToAcceptanceSpec never produces (FK-first ordering, dangling parents, all-FK entities). Kept out of this fix to stay scoped; WIP preserved in git at cc5fcb73.

Full suite: typecheck / lint / format clean, 3192/3205 green.

agjs added 2 commits July 28, 2026 14:40
…ion> (child-slice e2e)

The generated child-slice acceptance (e.g. Contact belongsTo Company) seeded the parent
Company via API AFTER navigating to the child page and opening the form, then immediately
selectOption(companyId) on the company <select>. But that <select> is populated by an async
list query on the child page's mount (navigate) — which ran BEFORE the seed and was never
refetched — so the <option value={seededId}> never entered the DOM and selectOption waited
the full 30s → e2e timeout → the whole slice false-PARKED. (Company/single-entity slices
were fine; only relational CHILD slices with a parent-FK <select> hit this.)

Fix (generateEntitySpec, all 4 mutating tests — create/persist/update/delete):
- Emit parentSeedingCode BETWEEN dashboard.goto() and navigateTo<Child>() so the child page's
  initial (fresh, per-test reload) parent-list fetch already includes the seeded parent —
  independent of the model's React-Query refetch behavior.
- generateFieldFillSteps: before selectOption on an FK field, waitFor option[value="${id}"]
  { state: attached } (belt-and-suspenders against the async fetch race).
- generateParentSeedingCode prepends the rationale note only when parents exist (parentless
  slices stay clean).
Negatives are API-only (no <select>) — unchanged.

Regression tests: seed precedes form-open, waitFor precedes selectOption, and a parentless
slice emits no FK wait/select. Full suite 3191/0; typecheck+lint+format clean.
…only negatives + strengthen ordering test

Follow-up to the seed-before-navigate fix (kept scoped to the per-entity spec, which is
what the build's slice acceptance uses):

- generateParentSeedingCode takes withSelectNote (default true). The negative blocks POST
  directly to the API (no navigation, no parent <select>), so generateEntitySpec seeds them
  with withSelectNote=false — the '<select>' rationale note would be misleading there.

- Strengthened the ordering regression test: assert the parent seed precedes navigateToContact
  in EVERY form-driven block (create/persist/update/delete), not just the first spec-wide
  occurrence. Added a test that the note is present in form tests but absent from the API-only
  negative block (which still seeds the parent). Reordered the Contact fixture so the FK is
  appended last (mirrors planToAcceptanceSpec.addParentFkFields) → identity resolves to name.

Deferred to task #84: FK-aware identity/first-field selection and chain-spec dangling-parent
hardening — a class of generator fragility for inputs planToAcceptanceSpec never produces
(FK-first ordering, dangling parents, all-FK entities). WIP preserved in git at cc5fcb7.

typecheck clean, lint clean, format clean, 3192/3205 suite green.
@agjs
agjs merged commit c6ce17e into main Jul 28, 2026
8 checks passed
@agjs
agjs deleted the fix/child-slice-parent-fk-acceptance branch July 28, 2026 14:30
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