fix(acceptance): seed child-slice parent BEFORE navigate + wait for the FK <option> (kills the relational-child e2e park) - #211
Merged
Conversation
…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.
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 wall
A relational child slice (a Contact with a
companyIdparent-FK rendered as a native<select>) parked: fast gate green, but the E2E acceptance timed out (Playwright 30s) onselectOption. 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:
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 andselectOptionwaited the full 30s → false park.The fix (scoped to the per-entity spec — what the build's slice acceptance uses)
generateEntitySpecseeds each form-driven mutating test (create/persist/update/delete) beforenavigateTo<Child>(), then waits for the seededoption[value]to attach beforeselectOption(belt-and-suspenders against the async fetch race). Seeding still runs afterdashboard.goto()(needs the auth cookie).generateParentSeedingCodetakeswithSelectNote(default true); the API-only negative blocks (POST directly, no<select>) seed withwithSelectNote=falseso the<select>rationale note isn't misleading there.Tests
navigateToordering, asserted for every form-driven test (create/persist/update/delete), not just the first spec-wide occurrence.<select>note is present in form tests but absent from the API-only negative block (which still seeds the parent).name).Validation
<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
planToAcceptanceSpecnever produces (FK-first ordering, dangling parents, all-FK entities). Kept out of this fix to stay scoped; WIP preserved in git atcc5fcb73.Full suite: typecheck / lint / format clean, 3192/3205 green.