-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
test(vue-start): server-routes #6127
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
Changes from all commits
3954f7c
ba11b8a
9104e00
2d8429e
0b31ea6
488e336
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| node_modules | ||
| package-lock.json | ||
| yarn.lock | ||
|
|
||
| .DS_Store | ||
| .cache | ||
| .env | ||
| .vercel | ||
| .output | ||
|
|
||
| /build/ | ||
| /api/ | ||
| /server/build | ||
| /public/build | ||
| # Sentry Config File | ||
| .env.sentry-build-plugin | ||
| /test-results/ | ||
| /playwright-report/ | ||
| /blob-report/ | ||
| /playwright/.cache/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| **/build | ||
| **/public | ||
| pnpm-lock.yaml | ||
| routeTree.gen.ts |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| { | ||
| "name": "tanstack-vue-start-e2e-server-routes", | ||
| "private": true, | ||
| "sideEffects": false, | ||
| "type": "module", | ||
| "scripts": { | ||
| "dev": "vite dev --port 3000", | ||
| "dev:e2e": "vite dev", | ||
| "build": "vite build && tsc --noEmit", | ||
| "preview": "vite preview", | ||
| "start": "pnpx srvx --prod -s ../client dist/server/server.js", | ||
| "test:e2e": "playwright test --project=chromium" | ||
| }, | ||
| "dependencies": { | ||
| "@tanstack/vue-query": "^5.90.9", | ||
| "@tanstack/vue-router": "workspace:^", | ||
| "@tanstack/vue-router-devtools": "workspace:^", | ||
| "@tanstack/vue-router-ssr-query": "workspace:^", | ||
| "@tanstack/vue-start": "workspace:^", | ||
| "js-cookie": "^3.0.5", | ||
| "redaxios": "^0.5.1", | ||
| "tailwind-merge": "^2.6.0", | ||
| "vite": "^7.1.7", | ||
| "vue": "^3.5.25", | ||
| "zod": "^3.24.2" | ||
| }, | ||
| "devDependencies": { | ||
| "@playwright/test": "^1.50.1", | ||
| "@tailwindcss/postcss": "^4.1.15", | ||
| "@tanstack/router-e2e-utils": "workspace:^", | ||
| "@types/js-cookie": "^3.0.6", | ||
| "@types/node": "^22.10.2", | ||
| "combinate": "^1.1.11", | ||
| "postcss": "^8.5.1", | ||
| "srvx": "^0.8.6", | ||
| "tailwindcss": "^4.1.17", | ||
| "typescript": "^5.7.2", | ||
| "@vitejs/plugin-vue": "^6.0.3", | ||
| "@vitejs/plugin-vue-jsx": "^5.1.2", | ||
| "vite-tsconfig-paths": "^5.1.4" | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import { defineConfig, devices } from '@playwright/test' | ||
| import { getTestServerPort } from '@tanstack/router-e2e-utils' | ||
| import packageJson from './package.json' with { type: 'json' } | ||
|
|
||
| export const PORT = await getTestServerPort(packageJson.name) | ||
| const baseURL = `http://localhost:${PORT}` | ||
|
|
||
| /** | ||
| * See https://playwright.dev/docs/test-configuration. | ||
| */ | ||
| export default defineConfig({ | ||
| testDir: './tests', | ||
| workers: 1, | ||
|
|
||
| reporter: [['line']], | ||
|
|
||
| use: { | ||
| /* Base URL to use in actions like `await page.goto('/')`. */ | ||
| baseURL, | ||
| }, | ||
|
|
||
| webServer: { | ||
| command: `pnpm build && VITE_SERVER_PORT=${PORT} PORT=${PORT} pnpm start`, | ||
| url: baseURL, | ||
| reuseExistingServer: !process.env.CI, | ||
| stdout: 'pipe', | ||
| }, | ||
|
|
||
| projects: [ | ||
| { | ||
| name: 'chromium', | ||
| use: { ...devices['Desktop Chrome'] }, | ||
| }, | ||
| ], | ||
| }) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| export default { | ||
| plugins: { | ||
| '@tailwindcss/postcss': {}, | ||
| }, | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,53 @@ | ||||||||||||||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||||||||||||||
| ErrorComponent, | ||||||||||||||||||||||||||||||||||||||
| Link, | ||||||||||||||||||||||||||||||||||||||
| rootRouteId, | ||||||||||||||||||||||||||||||||||||||
| useMatch, | ||||||||||||||||||||||||||||||||||||||
| useRouter, | ||||||||||||||||||||||||||||||||||||||
| } from '@tanstack/vue-router' | ||||||||||||||||||||||||||||||||||||||
| import type { ErrorComponentProps } from '@tanstack/vue-router' | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| export function DefaultCatchBoundary({ error }: ErrorComponentProps) { | ||||||||||||||||||||||||||||||||||||||
| const router = useRouter() | ||||||||||||||||||||||||||||||||||||||
| const isRoot = useMatch({ | ||||||||||||||||||||||||||||||||||||||
| strict: false, | ||||||||||||||||||||||||||||||||||||||
| select: (state) => state.id === rootRouteId, | ||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| console.error(error) | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||
| <div class="min-w-0 flex-1 p-4 flex flex-col items-center justify-center gap-6"> | ||||||||||||||||||||||||||||||||||||||
| <ErrorComponent error={error} /> | ||||||||||||||||||||||||||||||||||||||
| <div class="flex gap-2 items-center flex-wrap"> | ||||||||||||||||||||||||||||||||||||||
| <button | ||||||||||||||||||||||||||||||||||||||
| onClick={() => { | ||||||||||||||||||||||||||||||||||||||
| router.invalidate() | ||||||||||||||||||||||||||||||||||||||
| }} | ||||||||||||||||||||||||||||||||||||||
| class={`px-2 py-1 bg-gray-600 dark:bg-gray-700 rounded-sm text-white uppercase font-extrabold`} | ||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||
| Try Again | ||||||||||||||||||||||||||||||||||||||
| </button> | ||||||||||||||||||||||||||||||||||||||
| {isRoot.value ? ( | ||||||||||||||||||||||||||||||||||||||
| <Link | ||||||||||||||||||||||||||||||||||||||
| to="/" | ||||||||||||||||||||||||||||||||||||||
| class={`px-2 py-1 bg-gray-600 dark:bg-gray-700 rounded-sm text-white uppercase font-extrabold`} | ||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||
| Home | ||||||||||||||||||||||||||||||||||||||
| </Link> | ||||||||||||||||||||||||||||||||||||||
| ) : ( | ||||||||||||||||||||||||||||||||||||||
| <Link | ||||||||||||||||||||||||||||||||||||||
| to="/" | ||||||||||||||||||||||||||||||||||||||
| class={`px-2 py-1 bg-gray-600 dark:bg-gray-700 rounded-sm text-white uppercase font-extrabold`} | ||||||||||||||||||||||||||||||||||||||
| onClick={(e: MouseEvent) => { | ||||||||||||||||||||||||||||||||||||||
| e.preventDefault() | ||||||||||||||||||||||||||||||||||||||
| window.history.back() | ||||||||||||||||||||||||||||||||||||||
| }} | ||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||
| Go Back | ||||||||||||||||||||||||||||||||||||||
| </Link> | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+39
to
+48
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Misleading The Go Back link specifies Consider refactoring to use a button element instead: - <Link
- to="/"
- class={`px-2 py-1 bg-gray-600 dark:bg-gray-700 rounded-sm text-white uppercase font-extrabold`}
- onClick={(e: MouseEvent) => {
- e.preventDefault()
- window.history.back()
- }}
- >
- Go Back
- </Link>
+ <button
+ onClick={() => {
+ window.history.back()
+ }}
+ class={`px-2 py-1 bg-gray-600 dark:bg-gray-700 rounded-sm text-white uppercase font-extrabold`}
+ >
+ Go Back
+ </button>This makes the intent clearer and avoids the misleading 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { Link } from '@tanstack/vue-router' | ||
|
|
||
| export function NotFound({ children }: { children?: any }) { | ||
| return ( | ||
| <div class="space-y-2 p-2" data-testid="default-not-found-component"> | ||
| <div class="text-gray-600 dark:text-gray-400"> | ||
| {children || <p>The page you are looking for does not exist.</p>} | ||
| </div> | ||
| <p class="flex items-center gap-2 flex-wrap"> | ||
| <button | ||
| onClick={() => window.history.back()} | ||
| class="bg-emerald-500 text-white px-2 py-1 rounded-sm uppercase font-black text-sm" | ||
| > | ||
| Go back | ||
| </button> | ||
| <Link | ||
| to="/" | ||
| class="bg-cyan-600 text-white px-2 py-1 rounded-sm uppercase font-black text-sm" | ||
| > | ||
| Start Over | ||
| </Link> | ||
| </p> | ||
| </div> | ||
| ) | ||
| } |
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.
Use
workspace:*protocol for internal dependencies.Internal TanStack packages currently use
workspace:^but the coding guidelines specify usingworkspace:*for workspace dependencies. This ensures exact version matching across the monorepo.Apply this diff to align with project conventions:
"dependencies": { "@tanstack/vue-query": "^5.90.9", - "@tanstack/vue-router": "workspace:^", - "@tanstack/vue-router-devtools": "workspace:^", - "@tanstack/vue-router-ssr-query": "workspace:^", - "@tanstack/vue-start": "workspace:^", + "@tanstack/vue-router": "workspace:*", + "@tanstack/vue-router-devtools": "workspace:*", + "@tanstack/vue-router-ssr-query": "workspace:*", + "@tanstack/vue-start": "workspace:*", "js-cookie": "^3.0.5", "redaxios": "^0.5.1","devDependencies": { "@playwright/test": "^1.50.1", "@tailwindcss/postcss": "^4.1.15", - "@tanstack/router-e2e-utils": "workspace:^", + "@tanstack/router-e2e-utils": "workspace:*", "@types/js-cookie": "^3.0.6",As per coding guidelines for workspace dependencies.
Also applies to: 30-30
🤖 Prompt for AI Agents