-
-
Couldn't load subscription status.
- Fork 1.3k
test(solid-start): server-functions e2e #5616
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test(solid-start): server-functions e2e #5616
Conversation
WalkthroughThe PR adds comprehensive e2e test infrastructure for Solid Start server functions, introducing new routes for primitives, middleware patterns, form data redirects, and factory patterns. It also integrates SSR query support into the Solid Start router, adds corresponding dependencies, updates the route tree, and reorders imports in the React example. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
View your CI Pipeline Execution ↗ for commit de07270
☁️ Nx Cloud last updated this comment at |
More templates
@tanstack/arktype-adapter
@tanstack/directive-functions-plugin
@tanstack/eslint-plugin-router
@tanstack/history
@tanstack/nitro-v2-vite-plugin
@tanstack/react-router
@tanstack/react-router-devtools
@tanstack/react-router-ssr-query
@tanstack/react-start
@tanstack/react-start-client
@tanstack/react-start-server
@tanstack/router-cli
@tanstack/router-core
@tanstack/router-devtools
@tanstack/router-devtools-core
@tanstack/router-generator
@tanstack/router-plugin
@tanstack/router-ssr-query-core
@tanstack/router-utils
@tanstack/router-vite-plugin
@tanstack/server-functions-plugin
@tanstack/solid-router
@tanstack/solid-router-devtools
@tanstack/solid-router-ssr-query
@tanstack/solid-start
@tanstack/solid-start-client
@tanstack/solid-start-server
@tanstack/start-client-core
@tanstack/start-plugin-core
@tanstack/start-server-core
@tanstack/start-static-server-functions
@tanstack/start-storage-context
@tanstack/valibot-adapter
@tanstack/virtual-file-routes
@tanstack/zod-adapter
commit: |
b61f68f to
13a2191
Compare
4908768 to
d42389c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Nitpick comments (11)
e2e/solid-start/server-functions/vite.config.ts (1)
6-9: Make function-id matching cross‑platform and faster.Normalize file paths (Windows vs POSIX) and use a Set for O(1) lookup. Prevents false negatives on Windows devs/CI.
Apply:
+import path from 'node:path' + -const FUNCTIONS_WITH_CONSTANT_ID = [ - 'src/routes/submit-post-formdata.tsx/greetUser_createServerFn_handler', - 'src/routes/formdata-redirect/index.tsx/greetUser_createServerFn_handler', -] +const FUNCTIONS_WITH_CONSTANT_ID = new Set([ + 'src/routes/submit-post-formdata.tsx/greetUser_createServerFn_handler', + 'src/routes/formdata-redirect/index.tsx/greetUser_createServerFn_handler', +]) + +const toPosix = (p: string) => p.split(path.sep).join('/') @@ tanstackStart({ serverFns: { generateFunctionId: (opts) => { - const id = `${opts.filename}/${opts.functionName}` - if (FUNCTIONS_WITH_CONSTANT_ID.includes(id)) return 'constant_id' + const id = `${toPosix(opts.filename)}/${opts.functionName}` + if (FUNCTIONS_WITH_CONSTANT_ID.has(id)) return 'constant_id' else return undefined }, }, }),Also applies to: 19-27
e2e/solid-start/server-functions/src/routes/factory/-functions/createFakeFn.ts (1)
1-5: Type flexibility: make handler generic instead of Promise only.Current typing is restrictive. Optional improvement:
-export function createFakeFn() { - return { - handler: (cb: () => Promise<any>) => cb, - } -} +export function createFakeFn<TArgs extends any[], TResult>() { + return { + handler: (cb: (...args: TArgs) => TResult) => cb, + } +}e2e/solid-start/server-functions/tests/server-functions.spec.ts (2)
335-345: Reduce flakiness: rely on locator auto‑waiting instead of networkidle after click.Playwright assertions auto‑wait; the extra
networkidleafter clicks can be flaky in SPAs.- await page.getByTestId('test-submit-post-formdata-fn-calls-btn').click() - - await page.waitForLoadState('networkidle') + await page.getByTestId('test-submit-post-formdata-fn-calls-btn').click() + // rely on the assertion below to auto-wait
394-403: Trim textContent() before equality checks to avoid whitespace mismatches.Safer when elements might include incidental spaces/newlines.
- async function checkEqual(prefix: string) { - const requestParam = await page - .getByTestId(`${prefix}-data-request-param`) - .textContent() - expect(requestParam).not.toBe('') - const requestFunc = await page - .getByTestId(`${prefix}-data-request-func`) - .textContent() - expect(requestParam).toBe(requestFunc) - } + async function checkEqual(prefix: string) { + const requestParam = + (await page.getByTestId(`${prefix}-data-request-param`).textContent())?.trim() || '' + expect(requestParam).not.toBe('') + const requestFunc = + (await page.getByTestId(`${prefix}-data-request-func`).textContent())?.trim() || '' + expect(requestParam).toBe(requestFunc) + }e2e/solid-start/server-functions/src/routes/middleware/send-serverFn.tsx (1)
5-22: Consider reordering for clarity.The middleware references
barFn(line 9) before it's defined (line 20). While this works due to JavaScript hoisting and the async nature of middleware execution, definingbarFnbefore the middleware would improve code readability.Apply this diff to reorder the definitions:
+const barFn = createServerFn().handler(() => { + return 'bar' +}) + const middleware = createMiddleware({ type: 'function' }).client( async ({ next }) => { return next({ sendContext: { serverFn: barFn, }, }) }, ) const fooFn = createServerFn() .middleware([middleware]) .handler(({ context }) => { return context.serverFn() }) -const barFn = createServerFn().handler(() => { - return 'bar' -})e2e/solid-start/server-functions/src/routes/primitives/index.tsx (1)
1-9: Add missing newline after imports.Apply this diff to fix the ESLint error:
import { For, Show } from 'solid-js' import { z } from 'zod' + export const Route = createFileRoute('/primitives/')({ component: RouteComponent, ssr: 'data-only', })e2e/solid-start/server-functions/src/routes/factory/index.tsx (1)
1-20: Sort import members alphabetically.Apply this diff to fix the ESLint error:
-import { createSignal, For } from 'solid-js' +import { For, createSignal } from 'solid-js'e2e/solid-start/server-functions/src/routes/factory/-functions/functions.ts (1)
40-41: Gate console logs to reduce test noise.Wrap with a debug flag or use a logger at debug level to keep CI logs clean.
- console.log('local middleware triggered') + if (process.env.DEBUG?.includes('server-fns')) { + console.debug('local middleware triggered') + }Also applies to: 51-52
e2e/solid-start/server-functions/src/routes/middleware/request-middleware.tsx (3)
4-4: Sort import members as flagged by ESLint.Alphabetize named imports.
-import { createSignal, Show } from 'solid-js' +import { Show, createSignal } from 'solid-js'As per static analysis hints.
31-34: Prefer explicit data type from the server function for clarity.Typedef once and reuse.
- const [clientData, setClientData] = createSignal<ReturnType< - typeof loaderData - > | null>(null) + type ServerData = Awaited<ReturnType<typeof serverFn>> + const [clientData, setClientData] = createSignal<ServerData | null>(null)
52-57: Optional: handle client call errors.Avoid unhandled rejections in e2e runs.
- onClick={async () => { - const data = await serverFn() - setClientData(data) - }} + onClick={async () => { + try { + const data = await serverFn() + setClientData(data) + } catch (err) { + console.error('serverFn failed', err) + } + }}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (19)
e2e/react-start/server-functions/src/router.tsx(1 hunks)e2e/solid-start/query-integration/src/routes/loader-fetchQuery/$type.tsx(0 hunks)e2e/solid-start/server-functions/package.json(1 hunks)e2e/solid-start/server-functions/src/routeTree.gen.ts(11 hunks)e2e/solid-start/server-functions/src/router.tsx(1 hunks)e2e/solid-start/server-functions/src/routes/factory/-functions/createBarServerFn.ts(1 hunks)e2e/solid-start/server-functions/src/routes/factory/-functions/createFakeFn.ts(1 hunks)e2e/solid-start/server-functions/src/routes/factory/-functions/createFooServerFn.ts(1 hunks)e2e/solid-start/server-functions/src/routes/factory/-functions/functions.ts(1 hunks)e2e/solid-start/server-functions/src/routes/factory/index.tsx(1 hunks)e2e/solid-start/server-functions/src/routes/formdata-redirect/index.tsx(1 hunks)e2e/solid-start/server-functions/src/routes/formdata-redirect/target.$name.tsx(1 hunks)e2e/solid-start/server-functions/src/routes/middleware/client-middleware-router.tsx(1 hunks)e2e/solid-start/server-functions/src/routes/middleware/index.tsx(1 hunks)e2e/solid-start/server-functions/src/routes/middleware/request-middleware.tsx(1 hunks)e2e/solid-start/server-functions/src/routes/middleware/send-serverFn.tsx(1 hunks)e2e/solid-start/server-functions/src/routes/primitives/index.tsx(1 hunks)e2e/solid-start/server-functions/tests/server-functions.spec.ts(2 hunks)e2e/solid-start/server-functions/vite.config.ts(2 hunks)
💤 Files with no reviewable changes (1)
- e2e/solid-start/query-integration/src/routes/loader-fetchQuery/$type.tsx
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use TypeScript in strict mode with extensive type safety across the codebase
Files:
e2e/solid-start/server-functions/src/routes/factory/-functions/createFakeFn.tse2e/solid-start/server-functions/src/routes/formdata-redirect/target.$name.tsxe2e/solid-start/server-functions/src/routes/middleware/index.tsxe2e/solid-start/server-functions/src/routes/middleware/send-serverFn.tsxe2e/solid-start/server-functions/src/router.tsxe2e/solid-start/server-functions/src/routes/middleware/client-middleware-router.tsxe2e/solid-start/server-functions/src/routes/factory/-functions/createFooServerFn.tse2e/solid-start/server-functions/src/routes/factory/-functions/functions.tse2e/solid-start/server-functions/src/routes/primitives/index.tsxe2e/solid-start/server-functions/src/routes/middleware/request-middleware.tsxe2e/solid-start/server-functions/tests/server-functions.spec.tse2e/react-start/server-functions/src/router.tsxe2e/solid-start/server-functions/src/routes/formdata-redirect/index.tsxe2e/solid-start/server-functions/src/routeTree.gen.tse2e/solid-start/server-functions/vite.config.tse2e/solid-start/server-functions/src/routes/factory/-functions/createBarServerFn.tse2e/solid-start/server-functions/src/routes/factory/index.tsx
**/src/routes/**
📄 CodeRabbit inference engine (AGENTS.md)
Place file-based routes under src/routes/ directories
Files:
e2e/solid-start/server-functions/src/routes/factory/-functions/createFakeFn.tse2e/solid-start/server-functions/src/routes/formdata-redirect/target.$name.tsxe2e/solid-start/server-functions/src/routes/middleware/index.tsxe2e/solid-start/server-functions/src/routes/middleware/send-serverFn.tsxe2e/solid-start/server-functions/src/routes/middleware/client-middleware-router.tsxe2e/solid-start/server-functions/src/routes/factory/-functions/createFooServerFn.tse2e/solid-start/server-functions/src/routes/factory/-functions/functions.tse2e/solid-start/server-functions/src/routes/primitives/index.tsxe2e/solid-start/server-functions/src/routes/middleware/request-middleware.tsxe2e/solid-start/server-functions/src/routes/formdata-redirect/index.tsxe2e/solid-start/server-functions/src/routes/factory/-functions/createBarServerFn.tse2e/solid-start/server-functions/src/routes/factory/index.tsx
e2e/**
📄 CodeRabbit inference engine (AGENTS.md)
Store end-to-end tests under the e2e/ directory
Files:
e2e/solid-start/server-functions/src/routes/factory/-functions/createFakeFn.tse2e/solid-start/server-functions/src/routes/formdata-redirect/target.$name.tsxe2e/solid-start/server-functions/package.jsone2e/solid-start/server-functions/src/routes/middleware/index.tsxe2e/solid-start/server-functions/src/routes/middleware/send-serverFn.tsxe2e/solid-start/server-functions/src/router.tsxe2e/solid-start/server-functions/src/routes/middleware/client-middleware-router.tsxe2e/solid-start/server-functions/src/routes/factory/-functions/createFooServerFn.tse2e/solid-start/server-functions/src/routes/factory/-functions/functions.tse2e/solid-start/server-functions/src/routes/primitives/index.tsxe2e/solid-start/server-functions/src/routes/middleware/request-middleware.tsxe2e/solid-start/server-functions/tests/server-functions.spec.tse2e/react-start/server-functions/src/router.tsxe2e/solid-start/server-functions/src/routes/formdata-redirect/index.tsxe2e/solid-start/server-functions/src/routeTree.gen.tse2e/solid-start/server-functions/vite.config.tse2e/solid-start/server-functions/src/routes/factory/-functions/createBarServerFn.tse2e/solid-start/server-functions/src/routes/factory/index.tsx
**/package.json
📄 CodeRabbit inference engine (AGENTS.md)
Use workspace:* protocol for internal dependencies in package.json files
Files:
e2e/solid-start/server-functions/package.json
🧬 Code graph analysis (12)
e2e/solid-start/server-functions/src/routes/formdata-redirect/target.$name.tsx (1)
e2e/solid-start/server-functions/src/routes/formdata-redirect/index.tsx (1)
Route(5-10)
e2e/solid-start/server-functions/src/routes/middleware/index.tsx (3)
e2e/solid-start/server-functions/src/routes/middleware/client-middleware-router.tsx (1)
Route(25-28)e2e/solid-start/server-functions/src/routes/middleware/request-middleware.tsx (1)
Route(23-26)e2e/solid-start/server-functions/src/routes/middleware/send-serverFn.tsx (1)
Route(24-27)
e2e/solid-start/server-functions/src/routes/middleware/send-serverFn.tsx (3)
e2e/solid-start/server-functions/src/routes/middleware/client-middleware-router.tsx (1)
Route(25-28)e2e/solid-start/server-functions/src/routes/middleware/index.tsx (1)
Route(3-5)e2e/solid-start/server-functions/src/routes/middleware/request-middleware.tsx (1)
Route(23-26)
e2e/solid-start/server-functions/src/router.tsx (1)
e2e/react-start/server-functions/src/router.tsx (1)
getRouter(8-25)
e2e/solid-start/server-functions/src/routes/middleware/client-middleware-router.tsx (4)
packages/start-client-core/src/index.tsx (1)
getRouterInstance(102-102)e2e/solid-start/server-functions/src/routes/middleware/index.tsx (1)
Route(3-5)e2e/solid-start/server-functions/src/routes/middleware/request-middleware.tsx (1)
Route(23-26)e2e/solid-start/server-functions/src/routes/middleware/send-serverFn.tsx (1)
Route(24-27)
e2e/solid-start/server-functions/src/routes/factory/-functions/functions.ts (3)
e2e/solid-start/server-functions/src/routes/factory/-functions/createFooServerFn.ts (1)
createFooServerFn(12-12)e2e/solid-start/server-functions/src/routes/factory/-functions/createBarServerFn.ts (1)
createBarServerFn(13-13)e2e/solid-start/server-functions/src/routes/factory/-functions/createFakeFn.ts (1)
createFakeFn(1-5)
e2e/solid-start/server-functions/src/routes/primitives/index.tsx (7)
e2e/solid-start/server-functions/src/routes/factory/index.tsx (1)
Route(17-20)e2e/solid-start/server-functions/src/routes/formdata-redirect/index.tsx (1)
Route(5-10)e2e/solid-start/server-functions/src/routes/formdata-redirect/target.$name.tsx (1)
Route(3-5)e2e/solid-start/server-functions/src/routes/middleware/client-middleware-router.tsx (1)
Route(25-28)e2e/solid-start/server-functions/src/routes/middleware/index.tsx (1)
Route(3-5)e2e/solid-start/server-functions/src/routes/middleware/request-middleware.tsx (1)
Route(23-26)e2e/solid-start/server-functions/src/routes/middleware/send-serverFn.tsx (1)
Route(24-27)
e2e/solid-start/server-functions/src/routes/middleware/request-middleware.tsx (1)
packages/start-server-core/src/request-response.ts (1)
getRequest(72-75)
e2e/solid-start/server-functions/src/routes/formdata-redirect/index.tsx (1)
e2e/solid-start/server-functions/src/routes/formdata-redirect/target.$name.tsx (1)
Route(3-5)
e2e/solid-start/server-functions/vite.config.ts (1)
packages/router-core/src/route.ts (1)
id(1547-1549)
e2e/solid-start/server-functions/src/routes/factory/-functions/createBarServerFn.ts (1)
e2e/solid-start/server-functions/src/routes/factory/-functions/createFooServerFn.ts (1)
createFooServerFn(12-12)
e2e/solid-start/server-functions/src/routes/factory/index.tsx (2)
e2e/solid-start/server-functions/src/routes/factory/-functions/createFooServerFn.ts (1)
fooFnInsideFactoryFile(14-22)e2e/solid-start/server-functions/src/routes/factory/-functions/functions.ts (8)
fooFn(6-11)fooFnPOST(13-20)barFn(22-27)barFnPOST(29-36)localFn(58-65)localFnPOST(67-74)composedFn(86-93)fakeFn(76-81)
🪛 ESLint
e2e/solid-start/server-functions/src/routes/primitives/index.tsx
[error] 5-5: Expected 1 empty line after import statement not followed by another import.
(import/newline-after-import)
e2e/solid-start/server-functions/src/routes/middleware/request-middleware.tsx
[error] 4-4: Member 'Show' of the import declaration should be sorted alphabetically.
(sort-imports)
e2e/solid-start/server-functions/src/routes/factory/index.tsx
[error] 3-3: Member 'For' of the import declaration should be sorted alphabetically.
(sort-imports)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Test
- GitHub Check: Preview
🔇 Additional comments (24)
e2e/react-start/server-functions/src/router.tsx (1)
2-3: LGTM! Import organization improved.Moving these imports to the top of the file eliminates duplication and follows standard JavaScript/TypeScript conventions for import organization.
e2e/solid-start/server-functions/src/router.tsx (1)
2-4: SSR Query integration wiring looks correct.QueryClient per request, setup call after router creation, and typed registration are all good.
Also applies to: 9-21, 23-24
e2e/solid-start/server-functions/src/routes/formdata-redirect/target.$name.tsx (1)
3-15: Route component is concise and correct.Dynamic param handling and test IDs align with tests.
e2e/solid-start/server-functions/tests/server-functions.spec.ts (1)
7-19: LGTM for constant id URL assertion.Good coverage to ensure server function action URLs include the constant id.
e2e/solid-start/server-functions/package.json (1)
14-18: @tanstack/solid-query is not an internal monorepo package.The verification confirms that @tanstack/solid-query is an external npm dependency and not part of this monorepo. The current dependency specification
"@tanstack/solid-query": "^5.90.6"at line 14 is correct and should remain unchanged. The workspace:* protocol applies only to internal packages maintained within the monorepo.Likely an incorrect or invalid review comment.
e2e/solid-start/server-functions/src/routes/factory/-functions/createFooServerFn.ts (2)
1-10: LGTM!The middleware definition is clean and correctly implements the factory pattern for server-side context augmentation.
12-22: LGTM!The factory and handler exports are well-structured. The handler correctly returns the context augmented by the middleware.
e2e/solid-start/server-functions/src/routes/factory/-functions/createBarServerFn.ts (2)
1-11: LGTM!The middleware composition is correctly implemented, following the same pattern as the foo middleware.
13-22: LGTM!The composed factory and handler are correctly implemented. The middleware composition will result in both
fooandbarbeing present in the context.e2e/solid-start/server-functions/src/routes/formdata-redirect/index.tsx (3)
1-10: LGTM!The route definition with search validation is correctly implemented.
12-33: LGTM!The server function correctly validates FormData input and uses the redirect pattern appropriately. The validation ensures both the data type and required field are present.
35-74: LGTM!The component correctly implements progressive enhancement, handling both JavaScript-enabled and no-JavaScript modes for form submission.
e2e/solid-start/server-functions/src/routes/middleware/send-serverFn.tsx (1)
24-27: LGTM!The route definition correctly sets up the loader to invoke the server function.
e2e/solid-start/server-functions/src/routes/middleware/index.tsx (1)
1-39: LGTM!The middleware index route correctly provides navigation to the various middleware test cases. The
reloadDocument={true}on the request-middleware link is appropriate for testing request-level middleware.e2e/solid-start/server-functions/src/routes/middleware/client-middleware-router.tsx (1)
1-28: LGTM!The middleware correctly accesses the router instance using
getRouterInstance()and passes the router context to the server function.e2e/solid-start/server-functions/src/routes/primitives/index.tsx (3)
11-37: LGTM!The server functions correctly handle primitive types with appropriate validators. The
stringifyhelper properly handles theundefinedcase.
39-96: LGTM!The test infrastructure correctly uses
@tanstack/solid-queryto test server functions with primitive types. The handling of undefined values is consistent throughout.
97-136: LGTM!The test cases comprehensively cover the primitive types (null, undefined, string) for both GET and POST methods.
e2e/solid-start/server-functions/src/routes/factory/index.tsx (2)
28-115: LGTM!The test cases correctly define expected outputs based on middleware composition. The context objects properly reflect the cumulative effect of nested middleware.
117-184: LGTM!The test infrastructure correctly uses
deepEqualfor comparison and provides clear UI feedback for each test case.e2e/solid-start/server-functions/src/routes/factory/-functions/functions.ts (3)
83-88: Confirm middleware accepts a server-fn factory.Passing
createBarServerFninto.middleware([...])is unconventional; ensure the API supports factories here (not only middleware created viacreateMiddleware).
6-27: Handlers and method variants look consistent.Factory usage, POST overrides, and context passing read correctly.
Also applies to: 29-36, 58-66, 67-75, 86-93
76-81: ****
fakeFnis not a server function—it's a plain async function created bycreateFakeFn, which returns the handler callback as-is without wrapping it as a server function. The function runs exclusively client-side (invoked via theonClickhandler in the test component) wherewindowis available and valid. The test marksfakeFnwithtype: 'localFn'and expects the window object in the output. The code is correct as written.Likely an incorrect or invalid review comment.
e2e/solid-start/server-functions/src/routeTree.gen.ts (1)
25-35: Generated route additions look consistent.New routes are wired across imports, instances, maps, unions, and children. No manual edits recommended; keep this file generated.
Re-run the route generator after resolving upstream blocks to ensure this stays in sync.
Also applies to: 101-120, 126-153, 155-179, 198-204, 221-229, 248-257, 273-281, 298-306, 428-455, 463-483, 491-497, 516-525
| <p> | ||
| serverFn when invoked in the loader returns: | ||
| <br /> | ||
| <span data-testid="serverFn-loader-result"> | ||
| {JSON.stringify(serverFnClientResult())} | ||
| </span> | ||
| </p> | ||
| <p> | ||
| serverFn when invoked on the client returns: | ||
| <br /> | ||
| <span data-testid="serverFn-client-result"> | ||
| {JSON.stringify(loaderData().serverFnLoaderResult)} | ||
| </span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix swapped display of loader and client results.
The same bug exists here as in send-serverFn.tsx:
- Line 57 (testid: "serverFn-loader-result") displays
serverFnClientResult()instead of loader data - Line 64 (testid: "serverFn-client-result") displays
loaderData().serverFnLoaderResultinstead of client result
Apply this diff to fix the swapped data:
<p>
serverFn when invoked in the loader returns:
<br />
<span data-testid="serverFn-loader-result">
- {JSON.stringify(serverFnClientResult())}
+ {JSON.stringify(loaderData().serverFnLoaderResult)}
</span>
</p>
<p>
serverFn when invoked on the client returns:
<br />
<span data-testid="serverFn-client-result">
- {JSON.stringify(loaderData().serverFnLoaderResult)}
+ {JSON.stringify(serverFnClientResult())}
</span>
</p>🤖 Prompt for AI Agents
In
e2e/solid-start/server-functions/src/routes/middleware/client-middleware-router.tsx
around lines 53 to 65, the loader and client result spans are swapped: the span
with data-testid "serverFn-loader-result" is rendering serverFnClientResult()
and the span with data-testid "serverFn-client-result" is rendering
loaderData().serverFnLoaderResult; swap the rendered expressions so
"serverFn-loader-result" displays loaderData().serverFnLoaderResult and
"serverFn-client-result" displays serverFnClientResult().
| serverFn when invoked in the loader returns: | ||
| <br /> | ||
| <span data-testid="serverFn-loader-result"> | ||
| {JSON.stringify(serverFnClientResult())} | ||
| </span> | ||
| </p> | ||
| <p> | ||
| serverFn when invoked on the client returns: | ||
| <br /> | ||
| <span data-testid="serverFn-client-result"> | ||
| {JSON.stringify(loaderData().serverFnLoaderResult)} | ||
| </span> | ||
| </p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix swapped display of loader and client results.
Lines 56 and 63 have their data sources swapped:
- Line 56 (testid: "serverFn-loader-result") displays
serverFnClientResult()instead of loader data - Line 63 (testid: "serverFn-client-result") displays
loaderData().serverFnLoaderResultinstead of client result
Apply this diff to fix the swapped data:
<p>
serverFn when invoked in the loader returns:
<br />
<span data-testid="serverFn-loader-result">
- {JSON.stringify(serverFnClientResult())}
+ {JSON.stringify(loaderData().serverFnLoaderResult)}
</span>
</p>
<p>
serverFn when invoked on the client returns:
<br />
<span data-testid="serverFn-client-result">
- {JSON.stringify(loaderData().serverFnLoaderResult)}
+ {JSON.stringify(serverFnClientResult())}
</span>
</p>📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| serverFn when invoked in the loader returns: | |
| <br /> | |
| <span data-testid="serverFn-loader-result"> | |
| {JSON.stringify(serverFnClientResult())} | |
| </span> | |
| </p> | |
| <p> | |
| serverFn when invoked on the client returns: | |
| <br /> | |
| <span data-testid="serverFn-client-result"> | |
| {JSON.stringify(loaderData().serverFnLoaderResult)} | |
| </span> | |
| </p> | |
| serverFn when invoked in the loader returns: | |
| <br /> | |
| <span data-testid="serverFn-loader-result"> | |
| {JSON.stringify(loaderData().serverFnLoaderResult)} | |
| </span> | |
| </p> | |
| <p> | |
| serverFn when invoked on the client returns: | |
| <br /> | |
| <span data-testid="serverFn-client-result"> | |
| {JSON.stringify(serverFnClientResult())} | |
| </span> | |
| </p> |
🤖 Prompt for AI Agents
In e2e/solid-start/server-functions/src/routes/middleware/send-serverFn.tsx
around lines 53 to 65, the displayed values for the two spans are swapped: the
span with data-testid="serverFn-loader-result" currently renders
serverFnClientResult() and the span with data-testid="serverFn-client-result"
renders loaderData().serverFnLoaderResult; swap the expressions so the
loader-result span renders JSON.stringify(loaderData().serverFnLoaderResult) and
the client-result span renders JSON.stringify(serverFnClientResult()) (preserve
the JSON.stringify wrapping and surrounding markup).
| test.describe('formdata redirect modes', () => { | ||
| for (const mode of ['js', 'no-js']) { | ||
| test(`Server function can redirect when sending formdata: mode = ${mode}`, async ({ | ||
| page, | ||
| }) => { | ||
| await page.goto('/formdata-redirect?mode=' + mode) | ||
|
|
||
| await page.waitForLoadState('networkidle') | ||
| const expected = | ||
| (await page | ||
| .getByTestId('expected-submit-post-formdata-server-fn-result') | ||
| .textContent()) || '' | ||
| expect(expected).not.toBe('') | ||
|
|
||
| await page.getByTestId('test-submit-post-formdata-fn-calls-btn').click() | ||
|
|
||
| await page.waitForLoadState('networkidle') | ||
|
|
||
| await expect( | ||
| page.getByTestId('formdata-redirect-target-name'), | ||
| ).toContainText(expected) | ||
|
|
||
| expect(page.url().endsWith(`/formdata-redirect/target/${expected}`)) | ||
| }) | ||
| } | ||
| }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix missing assertion: currently a no‑op, test won’t fail on wrong URL.
The expect(page.url().endsWith(...)) call lacks a matcher. Use toHaveURL or assert truthiness.
Apply one of:
- expect(page.url().endsWith(`/formdata-redirect/target/${expected}`))
+ await expect(page).toHaveURL(new RegExp(`/formdata-redirect/target/${expected}$`))or (no RegExp):
- expect(page.url().endsWith(`/formdata-redirect/target/${expected}`))
+ expect(page.url().endsWith(`/formdata-redirect/target/${expected}`)).toBe(true)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| test.describe('formdata redirect modes', () => { | |
| for (const mode of ['js', 'no-js']) { | |
| test(`Server function can redirect when sending formdata: mode = ${mode}`, async ({ | |
| page, | |
| }) => { | |
| await page.goto('/formdata-redirect?mode=' + mode) | |
| await page.waitForLoadState('networkidle') | |
| const expected = | |
| (await page | |
| .getByTestId('expected-submit-post-formdata-server-fn-result') | |
| .textContent()) || '' | |
| expect(expected).not.toBe('') | |
| await page.getByTestId('test-submit-post-formdata-fn-calls-btn').click() | |
| await page.waitForLoadState('networkidle') | |
| await expect( | |
| page.getByTestId('formdata-redirect-target-name'), | |
| ).toContainText(expected) | |
| expect(page.url().endsWith(`/formdata-redirect/target/${expected}`)) | |
| }) | |
| } | |
| }) | |
| test.describe('formdata redirect modes', () => { | |
| for (const mode of ['js', 'no-js']) { | |
| test(`Server function can redirect when sending formdata: mode = ${mode}`, async ({ | |
| page, | |
| }) => { | |
| await page.goto('/formdata-redirect?mode=' + mode) | |
| await page.waitForLoadState('networkidle') | |
| const expected = | |
| (await page | |
| .getByTestId('expected-submit-post-formdata-server-fn-result') | |
| .textContent()) || '' | |
| expect(expected).not.toBe('') | |
| await page.getByTestId('test-submit-post-formdata-fn-calls-btn').click() | |
| await page.waitForLoadState('networkidle') | |
| await expect( | |
| page.getByTestId('formdata-redirect-target-name'), | |
| ).toContainText(expected) | |
| await expect(page).toHaveURL(new RegExp(`/formdata-redirect/target/${expected}$`)) | |
| }) | |
| } | |
| }) |
🤖 Prompt for AI Agents
In e2e/solid-start/server-functions/tests/server-functions.spec.ts around lines
328 to 353, the final assertion uses
expect(page.url().endsWith(`/formdata-redirect/target/${expected}`)) without a
matcher so it does nothing; replace it with a proper assertion such as await
expect(page).toHaveURL(new RegExp(`/formdata-redirect/target/${expected}$`)) or
assert truthiness with
expect(page.url().endsWith(`/formdata-redirect/target/${expected}`)).toBe(true)
(or .toBeTruthy()) to ensure the test fails when the URL is incorrect.
aligning server-functions e2e to match react
Summary by CodeRabbit
New Features
Tests
Chores