Skip to content

Commit

Permalink
add route_param test
Browse files Browse the repository at this point in the history
  • Loading branch information
AlecAivazis committed Oct 19, 2023
1 parent fc50f97 commit cbf51b7
Show file tree
Hide file tree
Showing 12 changed files with 337 additions and 19 deletions.
1 change: 1 addition & 0 deletions e2e/react/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ dist-ssr
*.njsproj
*.sln
*.sw?
vite.config.ts.*
3 changes: 3 additions & 0 deletions e2e/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,14 @@
"@types/react": "^18.0.27",
"@types/react-dom": "^18.0.10",
"@vitejs/plugin-react": "^3.1.0",
"autoprefixer": "^10.4.16",
"concurrently": "7.1.0",
"cross-env": "^7.0.3",
"e2e-api": "workspace:^",
"hono": "^3.6.0",
"houdini-adapter-node": "workspace:^",
"postcss": "^8.4.31",
"tailwindcss": "^3.3.3",
"typescript": "^4.9.3",
"vite": "^4.1.0",
"wrangler": "^3.7.0"
Expand Down
6 changes: 6 additions & 0 deletions e2e/react/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
11 changes: 6 additions & 5 deletions e2e/react/src/routes/+layout.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import manifest from '$houdini/plugins/houdini-react/manifest.json'
import { useCache } from '$houdini/plugins/houdini-react/runtime/routing'
import React from 'react'
import { routes } from '~/utils/routes'

import type { LayoutProps } from './$types'
import './index.css'

export default function ({ children }: LayoutProps) {
// save the cache reference on the window
Expand All @@ -17,11 +18,11 @@ export default function ({ children }: LayoutProps) {
return (
<>
<ul style={{ listStyle: 'none' }}>
{Object.values(manifest.pages).map((route) => {
{Object.entries(routes).map(([route, url]) => {
return (
<li key={route.url}>
<a href={route.url} data-houdini-preload>
{route.url}
<li key={url}>
<a href={url} data-houdini-preload>
{route}
</a>
</li>
)
Expand Down
2 changes: 1 addition & 1 deletion e2e/react/src/routes/hello/+page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { PageProps } from './$types'

export default function ({ HelloWorld }: PageProps) {
return <div>{JSON.stringify(HelloWorld)}</div>
return <div>{HelloWorld.hello}</div>
}
3 changes: 3 additions & 0 deletions e2e/react/src/routes/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
14 changes: 14 additions & 0 deletions e2e/react/src/routes/route_params/+layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { LayoutProps } from './$types'

export default ({ children }: LayoutProps) => {
return (
<div>
<div className="flex flex-row gap-12">
<a href="/route_params/1">user 1</a>
<a href="/route_params/2">user 2</a>
<a href="/route_params/3">user 3</a>
</div>
{children}
</div>
)
}
5 changes: 5 additions & 0 deletions e2e/react/src/routes/route_params/[id]/+page.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
query RouteParamsUserInfo($id: ID!) {
user(id: $id, snapshot: "route_params") {
name
}
}
10 changes: 10 additions & 0 deletions e2e/react/src/routes/route_params/[id]/+page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { PageProps } from './$types'

export default function ({ RouteParamsUserInfo }: PageProps) {
const { user } = RouteParamsUserInfo
return (
<div>
<div>{user.name}</div>
</div>
)
}
6 changes: 6 additions & 0 deletions e2e/react/src/utils/routes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const routes = {
hello: '/hello',
componentFields_simple: '/component_fields/simple',
componentFields_arguments: '/component_fields/arguments',
route_params: '/route_params/1',
}
7 changes: 7 additions & 0 deletions e2e/react/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}'],
theme: {
extend: {},
},
plugins: [],
}
Loading

0 comments on commit cbf51b7

Please sign in to comment.