File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
e2e/react-start/server-functions Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,20 @@ import type { Page } from '@playwright/test'
66
77const PORT = await getTestServerPort ( packageJson . name )
88
9+ test ( 'Server function URLs correctly include constant ids' , async ( {
10+ page,
11+ } ) => {
12+ for ( const currentPage of [ '/submit-post-formdata' , '/formdata-redirect' ] ) {
13+ await page . goto ( currentPage )
14+ await page . waitForLoadState ( 'networkidle' )
15+
16+ const form = page . locator ( 'form' )
17+ const actionUrl = await form . getAttribute ( 'action' )
18+
19+ expect ( actionUrl ) . toMatch ( / ^ \/ _ s e r v e r F n \/ c o n s t a n t _ i d / )
20+ }
21+ } )
22+
923test ( 'invoking a server function with custom response status code' , async ( {
1024 page,
1125} ) => {
Original file line number Diff line number Diff line change @@ -3,12 +3,25 @@ import tsConfigPaths from 'vite-tsconfig-paths'
33import { tanstackStart } from '@tanstack/react-start/plugin/vite'
44import viteReact from '@vitejs/plugin-react'
55
6+ const FUNCTIONS_WITH_CONSTANT_ID = [
7+ 'src/routes/submit-post-formdata.tsx--greetUser_createServerFn_handler' ,
8+ 'src/routes/formdata-redirect/index.tsx--greetUser_createServerFn_handler' ,
9+ ]
10+
611export default defineConfig ( {
712 plugins : [
813 tsConfigPaths ( {
914 projects : [ './tsconfig.json' ] ,
1015 } ) ,
11- tanstackStart ( ) ,
16+ tanstackStart ( {
17+ serverFns : {
18+ functionId : ( opts ) => {
19+ if ( FUNCTIONS_WITH_CONSTANT_ID . includes ( opts . currentId ) )
20+ return 'constant_id'
21+ else return undefined
22+ } ,
23+ } ,
24+ } ) ,
1225 viteReact ( ) ,
1326 ] ,
1427} )
You can’t perform that action at this time.
0 commit comments