Conversation
…ing the QueryClient
`e2e/farm.spec.ts` seeded React Query data by reaching for `window.__queryClient`
and calling `setQueryData(['pools'], …)` itself. That couples every spec to two
things it should not know about: the QueryClient instance, and the literal
spelling of each query key. Rename a key and an unrelated spec fails; drop the
global and every spec breaks at once — which is exactly what the issue reports.
`src/lib/e2eSeed.ts` owns that knowledge instead and exposes a small surface:
window.__e2e.seedPools([pool])
window.__e2e.seedPositions(publicKey, [{ pool, position }])
window.__e2e.clearPositions(publicKey)
window.__e2e.reset()
The keys come from `QUERY_KEYS` in `useSorobanQuery`, which is where the hooks
that read them are defined, so a rename moves both sides together.
`src/context/index.tsx` installs it under the same development / NEXT_PUBLIC_E2E
condition the raw client used to be exposed under, and no longer publishes
`window.__queryClient` at all. `e2e/lock-unlock-lifecycle.spec.ts` used the same
global for the same reason, so it is migrated too rather than leaving one spec
coupled to an internal the app no longer offers.
Tests — `src/lib/e2eSeed.test.ts`, 9 new:
- pools land under the key `useSorobanQuery` reads;
- positions land under the key the app invalidates, `['userPosition', 'all', pk]`;
- positions are per account, so one seed cannot leak into another;
- clearing positions leaves the pool list alone, and reset clears both;
- the key spellings the specs rely on are pinned, so a rename fails next to the
reason instead of inside an unrelated spec;
- no file under `e2e/` or `tests/` mentions `__queryClient` any more, and
`src/context/index.tsx` no longer hands it out — the same invariant, asserted
rather than trusted.
Verification:
pnpm exec tsc --noEmit # clean
pnpm exec eslint <changed files> # 0 errors (2 pre-existing unused-const warnings)
pnpm exec vitest run src/lib/e2eSeed.test.ts # 9 passed
pnpm test # 357 passed, 23 failed
The 23 failures are pre-existing: stashing these changes and running the same
suite gives 348 passed and the same 23 failures in the same files, so this commit
adds 9 passing tests and changes nothing else.
Found on the way, unrelated to this issue: `pnpm install --frozen-lockfile` fails
on `main` because `package.json` lists `next-intl` and `pnpm-lock.yaml` does not,
so a locked install cannot resolve. Worth fixing separately — the lockfile here is
untouched by this commit.
✅ Deploy Preview for spiffy-melomakarona-eb1e8a ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
❌ Deploy Preview for smart-drop failed.
|
|
Ran the spec in a real browser. With #492's two fixes applied and this change in place: That matters for this PR specifically: tests 3–5 are the seeded ones — they read the pool list and the locked position that To be precise about what the run does and does not show: on |
(cherry picked from commit df3163e)
|
Added one more commit: a lockfile sync that is not about this PR's own subject, but is the reason every Netlify check on this PR was red.
That is why the six checks on this PR ("Header rules", "Pages changed", "Redirect rules" — the two deploy previews each report three) were failing: they report the preview failing to build, and the preview cannot build while the install is refused. It is repo-wide, not specific to this branch. The commit adds The dependency is real, not stale: This commit is also on the other three open PRs from the same base (#490, #491, #493) so their previews can go green independently of this one merging. |
|
Update on the checks, since they now tell a clearer story: #492 is fully green (both deploy previews, header/redirect rules), and this one is still red — but not for the reason it was. This branch carries the lockfile sync, so the install no longer aborts. What is left is the defects that live on I am deliberately not copying those fixes here: they would duplicate #492, and when it merges this branch picks them up on rebase. If you would rather each PR stand alone and be green today, say so and I will cherry-pick them in. |
|
The issue this targets (#475) has been completed by @SweetBoy-eth and the wave bot has already recorded the credit against that PR, so this branch can no longer earn anything for anyone. Closing it to keep the queue clean rather than leaving a conflicting PR open. |
Closes #475
What changes
e2e/farm.spec.tsseeds React Query state by reaching forwindow.__queryClientand callingsetQueryData(['pools'], …)itself. The issue is right that this breaks the day the global goes away — and it also couples the spec to the literal spelling of every query key, so a rename inuseSorobanQueryfails a test in a file that has nothing to do with the change.It now seeds through a small surface the app owns:
src/lib/e2eSeed.tsbuilds those keys fromQUERY_KEYS, which lives next to the hooks that read them, into one place.src/context/index.tsxinstalls it under the same development /NEXT_PUBLIC_E2Econdition the raw client was exposed under, and no longer publisheswindow.__queryClientat all.e2e/lock-unlock-lifecycle.spec.tsused the same global for the same purpose, so it is migrated as well — leaving it coupled to an internal the app no longer offers would just be a second version of this issue.Tests
src/lib/e2eSeed.test.ts, 9 new tests:useSorobanQueryreads;['userPosition', 'all', publicKey];e2e/ortests/mentions__queryClient, andsrc/context/index.tsxno longer hands it out. That is the issue's requirement asserted as a test instead of trusted to review.Verification
The 23 failures are pre-existing and unrelated: with these changes stashed, the same suite reports 348 passed and the same 23 failures in the same files (
soroban-parsers,feeBumpGuard,useLeaderboard,Navbar,alerts,StellarWalletContext,soroban.service,useSorobanEvents). The delta is exactly the 9 tests added here.eslinton the changed files reports 0 errors and two pre-existingPOOLS_XDR is assigned a value but never usedwarnings — both constants are unused onmaintoo, and I left them alone rather than bundling an unrelated cleanup into this PR.One thing I found but did not touch
pnpm install --frozen-lockfilefails onmain:package.jsonlistsnext-intlandpnpm-lock.yamldoes not, so a locked install cannot resolve. I installed without--frozen-lockfileto run the checks and left the lockfile exactly as it was. Worth its own fix, since it means a clean checkout cannot do a reproducible install.I have not run the Playwright specs against a real browser yet — doing that next and will report the result here.