Repository navigation
test(pages): cover loader and action updates to shared data - #699
Merged
Merged
Conversation
Middleware sets the starting `shared` value. Since #624 the page object reads it after the loader and action run, so `c.set('shared', ...)` and in-place changes in a loader or action reach the page. Nothing tested that. Add tests for the JSON and HTML page after an action, a validation error, a loader on GET, the loader that runs after an action, and an action that leaves shared data alone (it keeps the middleware value). Document that loaders and actions can update shared data and that middleware does not run again after an action. Fixes #695 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
websockets-playground.test.ts builds playground/websockets in place while jsx-websocket.test.ts copies the same folder. The build rewrites .cloudflare/output, so the copy could hit a removed file and fail with ENOENT. .cloudflare is build output, like dist and .void, so do not copy it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
🚀 Deploying Preview to Cloudflare 🚀Preview URL: https://fix-page-action-shared-void-cloud.voidzero-docs.workers.dev (commit b26e972)This URL reflects your latest Preview deploymentPreview Deployments by commit
|
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.
Fixes #695
What I found
mainalready readssharedafter the loader and action run (changed in #624). The issue's table was checked on 1.5.0, which read it before they ran.Why the last row stays:
The action (or the loader) can update
shared, or redirect so that middleware runs again on the next page load. All four adapters (React, Vue, Svelte, Solid) replacesharedwith the value from each new page response, including after an action. This was checked by reading the code and in a browser against the playground builds.This PR
Tests (
pages-protocol.test.ts,routing-runtime.test.ts):ValidationErrorsharedalone keeps the middleware valueWith the old early read, 5 of the new tests fail.
Docs:
layouts.mdshows a loader or action updatingshared,actions-and-forms.mdsays middleware does not run again after an action, and theuseShared()rows in the API reference now mention loaders and actions.Test flake (separate commit):
jsx-websocket.test.tscopiesplayground/websocketswhilewebsockets-playground.test.tsrebuilds it in place. The copy could hit a file the build just removed (ENOENT … .cloudflare/output/…/assets/.vite)..cloudflareis build output, so the copy helper now skips it, as it already skipsdistand.void.Not changed
shared.sharedafternext()runs too late.These are separate from this issue.
Verification
vp test runon the two test files (-t shared): 7 passedvp run test: 773 files passedvp run check: 33/33🤖 Generated with Claude Code