Skip to content

Commit c75089d

Browse files
committed
encoding test package
1 parent c8f7a3e commit c75089d

24 files changed

+637
-28
lines changed

e2e/react-start/basic/tests/charset-encoding.spec.ts

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
node_modules
2+
package-lock.json
3+
yarn.lock
4+
5+
.DS_Store
6+
.cache
7+
.env
8+
.vercel
9+
.output
10+
11+
/build/
12+
/api/
13+
/server/build
14+
/public/build
15+
# Sentry Config File
16+
.env.sentry-build-plugin
17+
/test-results/
18+
/playwright-report/
19+
/blob-report/
20+
/playwright/.cache/
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
**/build
2+
**/public
3+
pnpm-lock.yaml
4+
routeTree.gen.ts
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name": "tanstack-react-start-e2e-encoding",
3+
"private": true,
4+
"sideEffects": false,
5+
"type": "module",
6+
"scripts": {
7+
"dev": "vite dev --port 3000",
8+
"dev:e2e": "vite dev",
9+
"build": "vite build && tsc --noEmit",
10+
"start": "node .output/server/index.mjs",
11+
"test:e2e": "rm -rf port*.txt; playwright test --project=chromium"
12+
},
13+
"dependencies": {
14+
"@tanstack/react-router": "workspace:^",
15+
"@tanstack/react-router-devtools": "workspace:^",
16+
"@tanstack/react-start": "workspace:^",
17+
"react": "^19.0.0",
18+
"react-dom": "^19.0.0",
19+
"redaxios": "^0.5.1",
20+
"tailwind-merge": "^2.6.0",
21+
"vite": "6.3.5",
22+
"zod": "^3.24.2"
23+
},
24+
"devDependencies": {
25+
"@playwright/test": "^1.50.1",
26+
"@tanstack/router-e2e-utils": "workspace:^",
27+
"@types/node": "^22.10.2",
28+
"@types/react": "^19.0.8",
29+
"@types/react-dom": "^19.0.3",
30+
"@vitejs/plugin-react": "^4.3.4",
31+
"autoprefixer": "^10.4.20",
32+
"combinate": "^1.1.11",
33+
"postcss": "^8.5.1",
34+
"tailwindcss": "^3.4.17",
35+
"typescript": "^5.7.2",
36+
"vite-tsconfig-paths": "^5.1.4"
37+
}
38+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { defineConfig, devices } from '@playwright/test'
2+
import {
3+
getDummyServerPort,
4+
getTestServerPort,
5+
} from '@tanstack/router-e2e-utils'
6+
import packageJson from './package.json' with { type: 'json' }
7+
8+
const PORT = await getTestServerPort(packageJson.name)
9+
const EXTERNAL_PORT = await getDummyServerPort(packageJson.name)
10+
const baseURL = `http://localhost:${PORT}`
11+
12+
/**
13+
* See https://playwright.dev/docs/test-configuration.
14+
*/
15+
export default defineConfig({
16+
testDir: './tests',
17+
workers: 1,
18+
19+
reporter: [['line']],
20+
21+
globalSetup: './tests/setup/global.setup.ts',
22+
globalTeardown: './tests/setup/global.teardown.ts',
23+
24+
use: {
25+
/* Base URL to use in actions like `await page.goto('/')`. */
26+
baseURL,
27+
},
28+
29+
webServer: {
30+
command: `VITE_NODE_ENV="test" VITE_EXTERNAL_PORT=${EXTERNAL_PORT} pnpm build && VITE_NODE_ENV="test" VITE_EXTERNAL_PORT=${EXTERNAL_PORT} VITE_SERVER_PORT=${PORT} PORT=${PORT} pnpm start`,
31+
url: baseURL,
32+
reuseExistingServer: !process.env.CI,
33+
stdout: 'pipe',
34+
},
35+
36+
projects: [
37+
{
38+
name: 'chromium',
39+
use: { ...devices['Desktop Chrome'] },
40+
},
41+
],
42+
})
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export default {
2+
plugins: {
3+
tailwindcss: {},
4+
autoprefixer: {},
5+
},
6+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// DO NOT DELETE THIS FILE!!!
2+
// This file is a good smoke test to make sure the custom client entry is working
3+
import { StrictMode, startTransition } from 'react'
4+
import { hydrateRoot } from 'react-dom/client'
5+
import { StartClient } from '@tanstack/react-start'
6+
import { createRouter } from './router'
7+
8+
console.log("[client-entry]: using custom client entry in 'src/client.tsx'")
9+
10+
const router = createRouter()
11+
12+
startTransition(() => {
13+
hydrateRoot(
14+
document,
15+
<StrictMode>
16+
<StartClient router={router} />
17+
</StrictMode>,
18+
)
19+
})
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import * as React from 'react'
2+
3+
export function CustomMessage({ message }: { message: string }) {
4+
return (
5+
<div className="py-2">
6+
<div className="italic">This is a custom message:</div>
7+
<p>{message}</p>
8+
</div>
9+
)
10+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import {
2+
ErrorComponent,
3+
Link,
4+
rootRouteId,
5+
useMatch,
6+
useRouter,
7+
} from '@tanstack/react-router'
8+
import type { ErrorComponentProps } from '@tanstack/react-router'
9+
10+
export function DefaultCatchBoundary({ error }: ErrorComponentProps) {
11+
const router = useRouter()
12+
const isRoot = useMatch({
13+
strict: false,
14+
select: (state) => state.id === rootRouteId,
15+
})
16+
17+
console.error(error)
18+
19+
return (
20+
<div className="min-w-0 flex-1 p-4 flex flex-col items-center justify-center gap-6">
21+
<ErrorComponent error={error} />
22+
<div className="flex gap-2 items-center flex-wrap">
23+
<button
24+
onClick={() => {
25+
router.invalidate()
26+
}}
27+
className={`px-2 py-1 bg-gray-600 dark:bg-gray-700 rounded text-white uppercase font-extrabold`}
28+
>
29+
Try Again
30+
</button>
31+
{isRoot ? (
32+
<Link
33+
to="/"
34+
className={`px-2 py-1 bg-gray-600 dark:bg-gray-700 rounded text-white uppercase font-extrabold`}
35+
>
36+
Home
37+
</Link>
38+
) : (
39+
<Link
40+
to="/"
41+
className={`px-2 py-1 bg-gray-600 dark:bg-gray-700 rounded text-white uppercase font-extrabold`}
42+
onClick={(e) => {
43+
e.preventDefault()
44+
window.history.back()
45+
}}
46+
>
47+
Go Back
48+
</Link>
49+
)}
50+
</div>
51+
</div>
52+
)
53+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { Link } from '@tanstack/react-router'
2+
3+
export function NotFound({ children }: { children?: any }) {
4+
return (
5+
<div className="space-y-2 p-2" data-testid="default-not-found-component">
6+
<div className="text-gray-600 dark:text-gray-400">
7+
{children || <p>The page you are looking for does not exist.</p>}
8+
</div>
9+
<p className="flex items-center gap-2 flex-wrap">
10+
<button
11+
onClick={() => window.history.back()}
12+
className="bg-emerald-500 text-white px-2 py-1 rounded uppercase font-black text-sm"
13+
>
14+
Go back
15+
</button>
16+
<Link
17+
to="/"
18+
className="bg-cyan-600 text-white px-2 py-1 rounded uppercase font-black text-sm"
19+
>
20+
Start Over
21+
</Link>
22+
</p>
23+
</div>
24+
)
25+
}

0 commit comments

Comments
 (0)