Skip to content

Commit 97587e6

Browse files
committed
add e2e app for prisma
1 parent b05028f commit 97587e6

21 files changed

+6446
-38
lines changed

examples/common/apps.ts

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const apps = [
77
"playground15",
88
"vercel-blog-starter",
99
"ssg-app",
10+
"prisma",
1011
// e2e
1112
"app-pages-router",
1213
"app-router",

examples/prisma/.gitignore

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.*
7+
.yarn/*
8+
!.yarn/patches
9+
!.yarn/plugins
10+
!.yarn/releases
11+
!.yarn/versions
12+
13+
# testing
14+
/coverage
15+
16+
# next.js
17+
/.next/
18+
/out/
19+
20+
# production
21+
/build
22+
23+
# misc
24+
.DS_Store
25+
*.pem
26+
27+
# debug
28+
npm-debug.log*
29+
yarn-debug.log*
30+
yarn-error.log*
31+
.pnpm-debug.log*
32+
33+
# env files (can opt-in for committing if needed)
34+
.env*
35+
36+
# vercel
37+
.vercel
38+
39+
# typescript
40+
*.tsbuildinfo
41+
next-env.d.ts
42+
43+
# playwright
44+
/test-results/
45+
/playwright-report/
46+
/blob-report/
47+
/playwright/.cache/

examples/prisma/README.md

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
2+
3+
## Getting Started
4+
5+
First, run the development server:
6+
7+
```bash
8+
npm run dev
9+
# or
10+
yarn dev
11+
# or
12+
pnpm dev
13+
# or
14+
bun dev
15+
```
16+
17+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
18+
19+
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
20+
21+
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
22+
23+
## Learn More
24+
25+
To learn more about Next.js, take a look at the following resources:
26+
27+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
28+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
29+
30+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
31+
32+
## Deploy on Vercel
33+
34+
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
35+
36+
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { configurePlaywright } from "../../common/config-e2e";
2+
3+
export default configurePlaywright("prisma");

examples/prisma/e2e/prisma.spec.ts

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { test, expect } from "@playwright/test";
2+
3+
test.describe("playground/cloudflare", () => {
4+
test("Prisma doesn't crash", async ({page}) => {
5+
await page.goto("/");
6+
const aliceName = await page.getByTestId("name-1").innerText();
7+
expect(aliceName).toBe("Alice");
8+
const aliceEmail = await page.getByTestId("email-1").innerText();
9+
expect(aliceEmail).toBe("[email protected]")
10+
11+
const bobName = await page.getByTestId("name-2").innerText();
12+
expect(bobName).toBe("Bob");
13+
const bobEmail = await page.getByTestId("email-2").innerText();
14+
expect(bobEmail).toBe("[email protected]")
15+
16+
const carolName = await page.getByTestId("name-3").innerText();
17+
expect(carolName).toBe("Carol");
18+
const carolEmail = await page.getByTestId("email-3").innerText();
19+
expect(carolEmail).toBe("[email protected]")
20+
21+
})
22+
});

examples/prisma/next.config.ts

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import type { NextConfig } from "next";
2+
3+
const nextConfig: NextConfig = {
4+
/* config options here */
5+
serverExternalPackages: [
6+
"@prisma/client",
7+
".prisma/client",
8+
]
9+
};
10+
11+
export default nextConfig;

examples/prisma/open-next.config.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { defineCloudflareConfig } from "@opennextjs/cloudflare";
2+
3+
export default defineCloudflareConfig({
4+
});

examples/prisma/package.json

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "prisma",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"dev": "next dev --turbopack",
7+
"build": "next build",
8+
"start": "next start",
9+
"lint": "next lint",
10+
"prepare:db": "npx prisma generate && wrangler d1 ",
11+
"build:worker": "npx prisma generate && pnpm opennextjs-cloudflare build",
12+
"preview:worker": "pnpm opennextjs-cloudflare preview",
13+
"preview": "pnpm build:worker && pnpm preview:worker",
14+
"e2e": "playwright test -c e2e/playwright.config.ts",
15+
"e2e:dev": "playwright test -c e2e/playwright.dev.config.ts",
16+
"cf-typegen": "wrangler types --env-interface CloudflareEnv"
17+
},
18+
"dependencies": {
19+
"@opennextjs/cloudflare": "workspace:*",
20+
"@prisma/adapter-d1": "^6.7.0",
21+
"@prisma/client": "^6.7.0",
22+
"next": "catalog:e2e",
23+
"react": "catalog:e2e",
24+
"react-dom": "catalog:e2e"
25+
},
26+
"devDependencies": {
27+
"@types/node": "catalog:",
28+
"@types/react": "catalog:e2e",
29+
"@types/react-dom": "catalog:e2e",
30+
"prisma": "^6.7.0",
31+
"typescript": "catalog:",
32+
"wrangler": "catalog:"
33+
}
34+
}

examples/prisma/populate.sql

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CREATE TABLE IF NOT EXISTS users (
2+
id INTEGER PRIMARY KEY AUTOINCREMENT,
3+
name TEXT NOT NULL,
4+
email TEXT NOT NULL,
5+
UNIQUE (email) ON CONFLICT REPLACE
6+
);
7+
8+
INSERT INTO users (name, email) VALUES
9+
('Alice', '[email protected]'),
10+
('Bob', '[email protected]'),
11+
('Carol', '[email protected]');

examples/prisma/prisma.config.ts

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import type {PrismaConfig} from "prisma";
2+
3+
export default {
4+
earlyAccess: true,
5+
schema: "./schema.prisma",
6+
} satisfies PrismaConfig;

examples/prisma/schema.prisma

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
generator client {
2+
provider = "prisma-client-js"
3+
previewFeatures = ["driverAdapters"]
4+
}
5+
6+
datasource db {
7+
provider = "sqlite"
8+
url = env("NOT_USED")
9+
}
10+
11+
model users {
12+
id Int @id @default(autoincrement())
13+
email String @unique
14+
name String?
15+
}

examples/prisma/src/app/favicon.ico

25.3 KB
Binary file not shown.

examples/prisma/src/app/globals.css

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
:root {
2+
--background: #ffffff;
3+
--foreground: #171717;
4+
}
5+
6+
@media (prefers-color-scheme: dark) {
7+
:root {
8+
--background: #0a0a0a;
9+
--foreground: #ededed;
10+
}
11+
}
12+
13+
html,
14+
body {
15+
max-width: 100vw;
16+
overflow-x: hidden;
17+
}
18+
19+
body {
20+
color: var(--foreground);
21+
background: var(--background);
22+
font-family: Arial, Helvetica, sans-serif;
23+
-webkit-font-smoothing: antialiased;
24+
-moz-osx-font-smoothing: grayscale;
25+
}
26+
27+
* {
28+
box-sizing: border-box;
29+
padding: 0;
30+
margin: 0;
31+
}
32+
33+
a {
34+
color: inherit;
35+
text-decoration: none;
36+
}
37+
38+
@media (prefers-color-scheme: dark) {
39+
html {
40+
color-scheme: dark;
41+
}
42+
}

examples/prisma/src/app/layout.tsx

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import type { Metadata } from "next";
2+
import { Geist, Geist_Mono } from "next/font/google";
3+
import "./globals.css";
4+
5+
const geistSans = Geist({
6+
variable: "--font-geist-sans",
7+
subsets: ["latin"],
8+
});
9+
10+
const geistMono = Geist_Mono({
11+
variable: "--font-geist-mono",
12+
subsets: ["latin"],
13+
});
14+
15+
export const metadata: Metadata = {
16+
title: "Create Next App",
17+
description: "Generated by create next app",
18+
};
19+
20+
export default function RootLayout({
21+
children,
22+
}: Readonly<{
23+
children: React.ReactNode;
24+
}>) {
25+
return (
26+
<html lang="en">
27+
<body className={`${geistSans.variable} ${geistMono.variable}`}>
28+
{children}
29+
</body>
30+
</html>
31+
);
32+
}

0 commit comments

Comments
 (0)