-
-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: create monorepo e2e spec (#1079)
This needs more work to figure out how to install dependencies in the test monorepo and link in the waku package in a way that closely matches the way it works with published npm packages. --------- Co-authored-by: Daishi Kato <[email protected]>
- Loading branch information
Showing
17 changed files
with
275 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"name": "monorepo", | ||
"private": true, | ||
"workspaces": [ | ||
"packages/*" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "waku-project", | ||
"version": "0.0.0", | ||
"type": "module", | ||
"private": true, | ||
"scripts": { | ||
"dev": "waku dev", | ||
"build": "waku build", | ||
"start": "waku start" | ||
}, | ||
"dependencies": { | ||
"react": "19.0.0", | ||
"react-dom": "19.0.0", | ||
"react-server-dom-webpack": "19.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "19.0.1", | ||
"@types/react-dom": "19.0.2", | ||
"autoprefixer": "10.4.20", | ||
"tailwindcss": "3.4.16", | ||
"typescript": "5.7.2" | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
e2e/fixtures/monorepo/packages/waku-project/postcss.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** @type {import('postcss-load-config').Config} */ | ||
export default { | ||
plugins: { | ||
tailwindcss: {}, | ||
autoprefixer: {}, | ||
}, | ||
}; |
Binary file added
BIN
+5.58 KB
e2e/fixtures/monorepo/packages/waku-project/public/images/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions
21
e2e/fixtures/monorepo/packages/waku-project/src/components/counter.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use client'; | ||
|
||
import { useState } from 'react'; // eslint-disable-line import/no-unresolved | ||
|
||
export const Counter = () => { | ||
const [count, setCount] = useState(0); | ||
|
||
const handleIncrement = () => setCount((c) => c + 1); | ||
|
||
return ( | ||
<section className="border-blue-400 -mx-4 mt-4 rounded border border-dashed p-4"> | ||
<div>Count: {count}</div> | ||
<button | ||
onClick={handleIncrement} | ||
className="rounded-sm bg-black px-2 py-0.5 text-sm text-white" | ||
> | ||
Increment | ||
</button> | ||
</section> | ||
); | ||
}; |
18 changes: 18 additions & 0 deletions
18
e2e/fixtures/monorepo/packages/waku-project/src/components/footer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export const Footer = () => { | ||
return ( | ||
<footer className="p-6 lg:fixed lg:bottom-0 lg:left-0"> | ||
<div> | ||
visit{' '} | ||
<a | ||
href="https://waku.gg/" | ||
target="_blank" | ||
rel="noreferrer" | ||
className="mt-4 inline-block underline" | ||
> | ||
waku.gg | ||
</a>{' '} | ||
to learn more | ||
</div> | ||
</footer> | ||
); | ||
}; |
11 changes: 11 additions & 0 deletions
11
e2e/fixtures/monorepo/packages/waku-project/src/components/header.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Link } from 'waku'; | ||
|
||
export const Header = () => { | ||
return ( | ||
<header className="flex items-center gap-4 p-6 lg:fixed lg:left-0 lg:top-0"> | ||
<h2 className="text-lg font-bold tracking-tight"> | ||
<Link to="/">Waku starter</Link> | ||
</h2> | ||
</header> | ||
); | ||
}; |
39 changes: 39 additions & 0 deletions
39
e2e/fixtures/monorepo/packages/waku-project/src/pages/_layout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import '../styles.css'; | ||
|
||
import type { ReactNode } from 'react'; | ||
|
||
import { Header } from '../components/header'; | ||
import { Footer } from '../components/footer'; | ||
|
||
type RootLayoutProps = { children: ReactNode }; | ||
|
||
export default async function RootLayout({ children }: RootLayoutProps) { | ||
const data = await getData(); | ||
|
||
return ( | ||
<div className="font-['Nunito']"> | ||
<meta name="description" content={data.description} /> | ||
<link rel="icon" type="image/png" href={data.icon} /> | ||
<Header /> | ||
<main className="m-6 flex items-center *:min-h-64 *:min-w-64 lg:m-0 lg:min-h-svh lg:justify-center"> | ||
{children} | ||
</main> | ||
<Footer /> | ||
</div> | ||
); | ||
} | ||
|
||
const getData = async () => { | ||
const data = { | ||
description: 'An internet website!', | ||
icon: '/images/favicon.png', | ||
}; | ||
|
||
return data; | ||
}; | ||
|
||
export const getConfig = async () => { | ||
return { | ||
render: 'static', | ||
} as const; | ||
}; |
32 changes: 32 additions & 0 deletions
32
e2e/fixtures/monorepo/packages/waku-project/src/pages/about.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Link } from 'waku'; | ||
|
||
export default async function AboutPage() { | ||
const data = await getData(); | ||
|
||
return ( | ||
<div> | ||
<title>{data.title}</title> | ||
<h1 className="text-4xl font-bold tracking-tight">{data.headline}</h1> | ||
<p>{data.body}</p> | ||
<Link to="/" className="mt-4 inline-block underline"> | ||
Return home | ||
</Link> | ||
</div> | ||
); | ||
} | ||
|
||
const getData = async () => { | ||
const data = { | ||
title: 'About', | ||
headline: 'About Waku', | ||
body: 'The minimal React framework', | ||
}; | ||
|
||
return data; | ||
}; | ||
|
||
export const getConfig = async () => { | ||
return { | ||
render: 'static', | ||
} as const; | ||
}; |
37 changes: 37 additions & 0 deletions
37
e2e/fixtures/monorepo/packages/waku-project/src/pages/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Link } from 'waku'; | ||
|
||
import { Counter } from '../components/counter'; | ||
|
||
export default async function HomePage() { | ||
const data = await getData(); | ||
|
||
return ( | ||
<div> | ||
<title>{data.title}</title> | ||
<h1 className="text-4xl font-bold tracking-tight" data-testid="header"> | ||
{data.headline} | ||
</h1> | ||
<p>{data.body}</p> | ||
<Counter /> | ||
<Link to="/about" className="mt-4 inline-block underline"> | ||
About page | ||
</Link> | ||
</div> | ||
); | ||
} | ||
|
||
const getData = async () => { | ||
const data = { | ||
title: 'Waku', | ||
headline: 'Waku', | ||
body: 'Hello world!', | ||
}; | ||
|
||
return data; | ||
}; | ||
|
||
export const getConfig = async () => { | ||
return { | ||
render: 'static', | ||
} as const; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
@import url('https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,400;0,700;1,400;1,700&display=swap'); | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; |
4 changes: 4 additions & 0 deletions
4
e2e/fixtures/monorepo/packages/waku-project/tailwind.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/** @type {import('tailwindcss').Config} */ | ||
export default { | ||
content: ['./src/**/*.{js,jsx,ts,tsx}'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"compilerOptions": { | ||
"composite": true, | ||
"strict": true, | ||
"target": "esnext", | ||
"downlevelIteration": true, | ||
"esModuleInterop": true, | ||
"module": "esnext", | ||
"moduleResolution": "bundler", | ||
"skipLibCheck": true, | ||
"noUncheckedIndexedAccess": true, | ||
"exactOptionalPropertyTypes": true, | ||
"types": ["react/experimental"], | ||
"jsx": "react-jsx", | ||
"rootDir": "./src", | ||
"outDir": "./dist" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { expect } from '@playwright/test'; | ||
|
||
import { test, prepareStandaloneSetup } from './utils.js'; | ||
|
||
const startApp = prepareStandaloneSetup('monorepo'); | ||
|
||
for (const mode of ['DEV', 'PRD'] as const) { | ||
for (const packageManager of ['npm', 'pnpm', 'yarn'] as const) { | ||
test.describe(`${packageManager} monorepo: ${mode}`, () => { | ||
let port: number; | ||
let stopApp: () => Promise<void>; | ||
test.beforeAll(async () => { | ||
({ port, stopApp } = await startApp( | ||
mode, | ||
packageManager, | ||
'packages/waku-project', | ||
)); | ||
}); | ||
test.afterAll(async () => { | ||
await stopApp(); | ||
}); | ||
|
||
test('renders the home page', async ({ page }) => { | ||
await page.goto(`http://localhost:${port}`); | ||
await expect(page.getByTestId('header')).toHaveText('Waku'); | ||
}); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters