Skip to content

Commit

Permalink
testing (#9): set up testing ci-cd, added navigation test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
kujo205 committed May 16, 2024
1 parent 2e8ab08 commit bf8378c
Show file tree
Hide file tree
Showing 7 changed files with 627 additions and 5 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Playwright Tests
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies
run: npm install -g pnpm && pnpm install
- name: Install Playwright Browsers
run: pnpm exec playwright install --with-deps
- name: Run Playwright tests
run: pnpm exec playwright test
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"db:generate-migration": "drizzle-kit generate:pg",
"dev": "next dev",
"lint": "next lint",
"start": "next start"
"start": "next start",
"test": "npx playwright test --reporter line"
},
"dependencies": {
"@auth/drizzle-adapter": "^0.3.6",
Expand Down Expand Up @@ -67,6 +68,7 @@
"zod": "^3.22.4"
},
"devDependencies": {
"@playwright/test": "^1.44.0",
"@tailwindcss/typography": "^0.5.12",
"@types/eslint": "^8.44.7",
"@types/node": "^18.17.0",
Expand Down
77 changes: 77 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { defineConfig, devices } from '@playwright/test';

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './tests',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},

/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},

{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},

{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},

/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 5'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },

/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
],

/* Run your local dev server before starting the tests */
// webServer: {
// command: 'npm run start',
// url: 'http://127.0.0.1:3000',
// reuseExistingServer: !process.env.CI,
// },
});
35 changes: 35 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions src/app/projects/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ import { ProjectCard } from "@/app/projects/_components/ProjectCard";

export default function Projects() {
return (
<main className="grid grid-cols-1 gap-6 px-[60px] py-[80px] sm:grid-cols-2 md:grid-cols-3 md:px-[120px]">
{projects.map((project) => (
<ProjectCard project={project} key={project.title} />
))}
<main className="px-15 flex flex-col gap-8 py-20 md:px-32">
<h1 className="self-center text-2xl font-bold">
Here are some of my projects
</h1>
<ul className="grid grid-cols-1 gap-6 sm:grid-cols-2 md:grid-cols-3">
{projects.map((project) => (
<ProjectCard project={project} key={project.title} />
))}
</ul>
</main>
);
}
Loading

0 comments on commit bf8378c

Please sign in to comment.