Skip to content

Commit f279fdd

Browse files
authored
Merge pull request #21 from Developer-DAO/e2e
added a basic test coverage
2 parents cf89997 + eea86c0 commit f279fdd

File tree

12 files changed

+598
-10
lines changed

12 files changed

+598
-10
lines changed

.github/workflows/playwright.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Playwright Tests
2+
on:
3+
push:
4+
branches: [ main, master ]
5+
pull_request:
6+
branches: [ main, master ]
7+
jobs:
8+
test:
9+
timeout-minutes: 60
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
- uses: actions/setup-node@v3
14+
with:
15+
node-version: 18
16+
- name: Install dependencies
17+
run: npm install -g yarn && yarn
18+
- name: Install Playwright Browsers
19+
run: yarn playwright install --with-deps
20+
- name: Run Playwright tests
21+
run: yarn playwright test
22+
- uses: actions/upload-artifact@v3
23+
if: always()
24+
with:
25+
name: playwright-report
26+
path: playwright-report/
27+
retention-days: 30

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,7 @@ yarn-error.log*
3434
# typescript
3535
*.tsbuildinfo
3636
next-env.d.ts
37+
/test-results/
38+
/playwright-report/
39+
/blob-report/
40+
/playwright/.cache/

app/about/page.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import React from "react";
55

66
export default function HomePage() {
77
return (
8-
<div className="relative flex min-h-screen flex-col bg-background">
8+
<div className="relative flex min-h-screen flex-col bg-background" data-testid="aboutpage">
99
<Navigation />
1010
<main className="flex-1">
1111

app/authentication/login/page.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ export const metadata: Metadata = {
1414
export default function AuthenticationPage() {
1515
return (
1616
<>
17-
<div className="container relative hidden h-[800px] flex-col items-center justify-center md:grid lg:max-w-none lg:grid-cols-2 lg:px-0">
17+
<div className="container relative hidden h-[800px] flex-col items-center justify-center md:grid lg:max-w-none lg:grid-cols-2 lg:px-0" data-testid="loginpage">
1818
<Link
19-
href="/authentication/login"
19+
href="/authentication"
2020
className="absolute right-4 top-4 md:right-8 md:top-8 flex items-center justify-center gap-1 rounded-full border-2 transition-all h-12 px-6 text-lg text-black border-white bg-white font-paragraph font-semibold tracking-wider hover:drop-shadow-[10px_0_20px_rgba(254,254,254,0.472)]"
2121
>
22-
Login
22+
Register
2323
</Link>
2424
<div className="relative hidden h-screen flex-col bg-muted p-10 text-white lg:flex dark:border-r">
2525
<div className="absolute inset-0" style={{ backgroundImage: "url(https://academy.developerdao.com/_next/image?url=%2Fschoolofcode.png&w=640&q=75)", backgroundPosition: "center", backgroundRepeat: "no-repeat", backgroundSize: "50%" }} />

app/contact/page.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import React from "react";
44

55
export default function HomePage() {
66
return (
7-
<div className="relative flex min-h-screen flex-col bg-background">
7+
<div className="relative flex min-h-screen flex-col bg-background" data-testid="contactpage">
88
<Navigation />
99
<main className="flex-1">
1010

app/page.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ export default function HomePage() {
2323
</div>
2424
</div>
2525
</div>
26-
<div className="flex flex-col items-start mt-12 mb-16 text-left lg:flex-grow lg:w-1/2 lg:pl-6 xl:pl-24 md:mb-0 xl:mt-0">
26+
<div className="flex flex-col items-start mt-12 mb-16 text-left lg:flex-grow lg:w-1/2 lg:pl-6 xl:pl-24 md:mb-0 xl:mt-0" data-testid="mainhero">
2727
<span className="mb-8 text-xs font-bold tracking-widest text-neutral-600 uppercase"> remote procedure call gateway by D_D </span>
28-
<h1 className="mb-8 text-4xl font-bold leading-none tracking-tighter text-neutral-100 md:text-7xl lg:text-5xl">Your gateway to the decentrlaized world.</h1>
28+
<h1 className="mb-8 text-4xl font-bold leading-none tracking-tighter text-neutral-100 md:text-7xl lg:text-5xl">Your gateway to the decentralized world.</h1>
2929
<p className="mb-8 text-base leading-relaxed text-left text-neutral-500">Some other claim why we are building this, other claim why we are building this. Perfecto! </p>
3030
<p className="mb-2 text-base leading-relaxed text-left text-neutral-500">Don't miss the opportunity, register now!</p>
3131
<div className="flex-col mt-0 lg:mt-6 max-w-7xl sm:flex">

components/navigation.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export function Navigation() {
88
<header className="sticky top-0 z-50 w-full bg-zinc-900/95 backdrop-blur supports-[backdrop-filter]:bg-zinc-900/60">
99
<div className="container flex py-4 max-w-screen-2xl items-center">
1010
<div className="mr-4 hidden md:flex">
11-
<Link href="/" className="mr-6 flex items-center space-x-2">
11+
<Link href="/" className="mr-6 flex items-center space-x-2" data-testid="nav-home">
1212
<Icons.logo className="h-12 w-12" />
1313
<span className="hidden font-bold sm:inline-block">
1414
RPC
@@ -19,13 +19,15 @@ export function Navigation() {
1919
href="/about"
2020
className=
2121
" tracking-wide text-neutral-500 p-0 hover:text-white transition-colors"
22+
data-testid="nav-about"
2223
>
2324
About
2425
</Link>
2526
<Link
2627
href="/contact"
2728
className=
2829
" tracking-wide text-neutral-500 p-0 hover:text-white transition-colors"
30+
data-testid="nav-contact"
2931
>
3032
Contact
3133
</Link>
@@ -34,7 +36,7 @@ export function Navigation() {
3436
<div className="flex flex-1 items-center justify-between space-x-2 md:justify-end">
3537
<nav className="flex items-center">
3638

37-
<Link href="/dashboard" className="flex w-fit items-center justify-center gap-1 rounded-full border-2 transition-all h-12 px-6 text-lg text-black border-white bg-white font-paragraph font-semibold tracking-wider hover:drop-shadow-[10px_0_20px_rgba(254,254,254,0.472)]" > Application</Link>
39+
<Link href="/authentication/login" className="flex w-fit items-center justify-center gap-1 rounded-full border-2 transition-all h-12 px-6 text-lg text-black border-white bg-white font-paragraph font-semibold tracking-wider hover:drop-shadow-[10px_0_20px_rgba(254,254,254,0.472)]" data-testid="nav-login"> Application</Link>
3840

3941
</nav>
4042
</div>

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"scripts": {
66
"dev": "next dev",
77
"build": "next build",
8-
"start": "next start",
8+
"start": "next build && next start",
99
"lint": "next lint"
1010
},
1111
"dependencies": {
@@ -31,6 +31,7 @@
3131
"zustand": "^4.5.0"
3232
},
3333
"devDependencies": {
34+
"@playwright/test": "^1.41.2",
3435
"@types/node": "^20",
3536
"@types/react": "^18",
3637
"@types/react-dom": "^18",

playwright.config.ts

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import { defineConfig, devices } from '@playwright/test';
2+
3+
/**
4+
* Read environment variables from file.
5+
* https://github.com/motdotla/dotenv
6+
*/
7+
// require('dotenv').config();
8+
9+
/**
10+
* See https://playwright.dev/docs/test-configuration.
11+
*/
12+
export default defineConfig({
13+
testDir: './tests',
14+
/* Run tests in files in parallel */
15+
fullyParallel: true,
16+
/* Fail the build on CI if you accidentally left test.only in the source code. */
17+
forbidOnly: !!process.env.CI,
18+
/* Retry on CI only */
19+
retries: process.env.CI ? 2 : 0,
20+
/* Opt out of parallel tests on CI. */
21+
workers: process.env.CI ? 1 : undefined,
22+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
23+
reporter: 'html',
24+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
25+
use: {
26+
/* Base URL to use in actions like `await page.goto('/')`. */
27+
baseURL: 'http://127.0.0.1:3000',
28+
29+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
30+
trace: 'on-first-retry',
31+
},
32+
33+
/* Configure projects for major browsers */
34+
projects: [
35+
{
36+
name: 'chromium',
37+
use: { ...devices['Desktop Chrome'] },
38+
},
39+
40+
{
41+
name: 'firefox',
42+
use: { ...devices['Desktop Firefox'] },
43+
},
44+
45+
/* Test against mobile viewports. */
46+
// {
47+
// name: 'Mobile Chrome',
48+
// use: { ...devices['Pixel 5'] },
49+
// },
50+
// {
51+
// name: 'Mobile Safari',
52+
// use: { ...devices['iPhone 12'] },
53+
// },
54+
55+
/* Test against branded browsers. */
56+
// {
57+
// name: 'Microsoft Edge',
58+
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
59+
// },
60+
// {
61+
// name: 'Google Chrome',
62+
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
63+
// },
64+
],
65+
66+
/* Run your local dev server before starting the tests */
67+
webServer: {
68+
command: 'yarn start',
69+
url: 'http://127.0.0.1:3000',
70+
reuseExistingServer: !process.env.CI,
71+
},
72+
});

0 commit comments

Comments
 (0)