From 1aba7f9c1208c19a3db8e958b127d479dc684d73 Mon Sep 17 00:00:00 2001 From: hhhjin Date: Sat, 11 Apr 2026 16:22:04 +0900 Subject: [PATCH 1/9] Add Playwright smoke tests for public uploads --- .github/workflows/ci.yml | 47 +++++++++ .gitignore | 4 +- README.md | 14 +++ .../upload-form/components/PreviewPane.tsx | 1 + .../upload-form/components/SuccessView.tsx | 2 + .../components/TurnstileWidget.tsx | 24 +++-- .../upload-form/components/UploadView.tsx | 3 + .../upload-form/components/WarningDialog.tsx | 9 +- .../features/upload-form/hooks/useUpload.ts | 12 ++- e2e/fixtures/sample.md | 10 ++ e2e/public-upload.spec.ts | 97 +++++++++++++++++++ package.json | 5 + playwright.config.ts | 51 ++++++++++ pnpm-lock.yaml | 38 ++++++++ vite.config.ts | 8 ++ vitest.config.mts | 2 + 16 files changed, 310 insertions(+), 17 deletions(-) create mode 100644 e2e/fixtures/sample.md create mode 100644 e2e/public-upload.spec.ts create mode 100644 playwright.config.ts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9a39dcb..d9b3a7d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,3 +35,50 @@ jobs: - name: Test run: pnpm test + + e2e: + name: Playwright E2E + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: "24.13.0" + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Install Playwright browsers + run: pnpm exec playwright install --with-deps chromium + + - name: Run Playwright tests + run: pnpm test:e2e + env: + ENV: dev + TURNSTILE_SECRET_KEY: dummy-turnstile-secret + BETTER_AUTH_SECRET: dummy-better-auth-secret-32chars + BETTER_AUTH_URL: http://127.0.0.1:4173 + GITHUB_CLIENT_ID: dummy-github-client-id + GITHUB_CLIENT_SECRET: dummy-github-client-secret + + - name: Upload Playwright report + if: always() + uses: actions/upload-artifact@v4 + with: + name: playwright-report + path: playwright-report + if-no-files-found: ignore + + - name: Upload Playwright test results + if: always() + uses: actions/upload-artifact@v4 + with: + name: playwright-test-results + path: test-results + if-no-files-found: ignore diff --git a/.gitignore b/.gitignore index cf40553..8ca8bbf 100644 --- a/.gitignore +++ b/.gitignore @@ -170,7 +170,9 @@ dist # Vite bundled output dist .output +playwright-report/ +test-results/ .DS_Store -.omx \ No newline at end of file +.omx diff --git a/README.md b/README.md index 8d3bcb3..54196fb 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,20 @@ If you encounter type errors, generate Cloudflare Worker types: pnpm cf-typegen ``` +### End-to-End Tests + +Install the Chromium browser used by Playwright: + +```bash +pnpm test:e2e:install +``` + +Run the Playwright smoke tests: + +```bash +pnpm test:e2e +``` + ### Building Build the production bundle: diff --git a/client/features/upload-form/components/PreviewPane.tsx b/client/features/upload-form/components/PreviewPane.tsx index 495ca71..1981d4e 100644 --- a/client/features/upload-form/components/PreviewPane.tsx +++ b/client/features/upload-form/components/PreviewPane.tsx @@ -53,6 +53,7 @@ export function PreviewPane({
import("react-turnstile")); interface TurnstileWidgetProps { onVerify: (token: string) => void; @@ -12,14 +14,16 @@ export function TurnstileWidget({ onError, }: TurnstileWidgetProps) { return ( - + + + ); } diff --git a/client/features/upload-form/components/UploadView.tsx b/client/features/upload-form/components/UploadView.tsx index 208d899..015394d 100644 --- a/client/features/upload-form/components/UploadView.tsx +++ b/client/features/upload-form/components/UploadView.tsx @@ -173,6 +173,7 @@ export function UploadView({