Skip to content

Commit ede47af

Browse files
authored
test(vue-start): server-functions (#6129)
1 parent 43a36e9 commit ede47af

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+3780
-113
lines changed
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: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"name": "tanstack-vue-start-e2e-server-functions",
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+
"preview": "vite preview",
11+
"start": "pnpx srvx --prod -s ../client dist/server/server.js",
12+
"test:e2e": "rm -rf port*.txt; playwright test --project=chromium"
13+
},
14+
"dependencies": {
15+
"@tanstack/vue-query": "^5.90.9",
16+
"@tanstack/vue-router": "workspace:^",
17+
"@tanstack/vue-router-devtools": "workspace:^",
18+
"@tanstack/vue-router-ssr-query": "workspace:^",
19+
"@tanstack/vue-start": "workspace:^",
20+
"js-cookie": "^3.0.5",
21+
"redaxios": "^0.5.1",
22+
"tailwind-merge": "^2.6.0",
23+
"vite": "^7.1.7",
24+
"vue": "^3.5.25",
25+
"zod": "^3.24.2"
26+
},
27+
"devDependencies": {
28+
"@playwright/test": "^1.50.1",
29+
"@tailwindcss/postcss": "^4.1.15",
30+
"@tanstack/router-e2e-utils": "workspace:^",
31+
"@types/js-cookie": "^3.0.6",
32+
"@types/node": "^22.10.2",
33+
"combinate": "^1.1.11",
34+
"postcss": "^8.5.1",
35+
"srvx": "^0.9.8",
36+
"tailwindcss": "^4.1.17",
37+
"typescript": "^5.7.2",
38+
"@vitejs/plugin-vue": "^6.0.3",
39+
"@vitejs/plugin-vue-jsx": "^5.1.2",
40+
"vite-tsconfig-paths": "^5.1.4"
41+
}
42+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { defineConfig, devices } from '@playwright/test'
2+
import { getTestServerPort } from '@tanstack/router-e2e-utils'
3+
import packageJson from './package.json' with { type: 'json' }
4+
5+
export const PORT = await getTestServerPort(packageJson.name)
6+
const baseURL = `http://localhost:${PORT}`
7+
8+
/**
9+
* See https://playwright.dev/docs/test-configuration.
10+
*/
11+
export default defineConfig({
12+
testDir: './tests',
13+
workers: 1,
14+
15+
reporter: [['line']],
16+
17+
use: {
18+
/* Base URL to use in actions like `await page.goto('/')`. */
19+
baseURL,
20+
},
21+
22+
webServer: {
23+
command: `pnpm build && VITE_SERVER_PORT=${PORT} PORT=${PORT} pnpm start`,
24+
url: baseURL,
25+
reuseExistingServer: !process.env.CI,
26+
stdout: 'pipe',
27+
},
28+
29+
projects: [
30+
{
31+
name: 'chromium',
32+
use: { ...devices['Desktop Chrome'] },
33+
},
34+
],
35+
})
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export default {
2+
plugins: {
3+
'@tailwindcss/postcss': {},
4+
},
5+
}
15 KB
Binary file not shown.
1.47 KB
Loading
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/vue-router'
8+
import type { ErrorComponentProps } from '@tanstack/vue-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 class="min-w-0 flex-1 p-4 flex flex-col items-center justify-center gap-6">
21+
<ErrorComponent error={error} />
22+
<div class="flex gap-2 items-center flex-wrap">
23+
<button
24+
onClick={() => {
25+
router.invalidate()
26+
}}
27+
class={`px-2 py-1 bg-gray-600 dark:bg-gray-700 rounded-sm text-white uppercase font-extrabold`}
28+
>
29+
Try Again
30+
</button>
31+
{isRoot.value ? (
32+
<Link
33+
to="/"
34+
class={`px-2 py-1 bg-gray-600 dark:bg-gray-700 rounded-sm text-white uppercase font-extrabold`}
35+
>
36+
Home
37+
</Link>
38+
) : (
39+
<Link
40+
to="/"
41+
class={`px-2 py-1 bg-gray-600 dark:bg-gray-700 rounded-sm text-white uppercase font-extrabold`}
42+
onClick={(e: MouseEvent) => {
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/vue-router'
2+
3+
export function NotFound({ children }: { children?: any }) {
4+
return (
5+
<div class="space-y-2 p-2" data-testid="default-not-found-component">
6+
<div class="text-gray-600 dark:text-gray-400">
7+
{children || <p>The page you are looking for does not exist.</p>}
8+
</div>
9+
<p class="flex items-center gap-2 flex-wrap">
10+
<button
11+
onClick={() => window.history.back()}
12+
class="bg-emerald-500 text-white px-2 py-1 rounded-sm uppercase font-black text-sm"
13+
>
14+
Go back
15+
</button>
16+
<Link
17+
to="/"
18+
class="bg-cyan-600 text-white px-2 py-1 rounded-sm uppercase font-black text-sm"
19+
>
20+
Start Over
21+
</Link>
22+
</p>
23+
</div>
24+
)
25+
}

0 commit comments

Comments
 (0)