diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..5a4a70df --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,152 @@ +name: Tests & Coverage + +on: + pull_request: + branches: [main, dev] + push: + branches: [main, dev, "feat/**", "fix/**", "refactor/**"] + +jobs: + unit-tests: + name: Unit Tests + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: "20" + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + version: 10 + run_install: false + + - name: Cache pnpm store + uses: actions/cache@v4 + with: + path: ~/.pnpm-store + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Run unit tests + run: pnpm vitest run + env: + CI: true + + e2e-tests: + name: E2E Tests + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: "20" + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + version: 10 + run_install: false + + - name: Cache pnpm store + uses: actions/cache@v4 + with: + path: ~/.pnpm-store + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Install Playwright browsers + run: npx playwright install --with-deps chromium + + - name: Build application + run: pnpm build + env: + CI: true + + - name: Run E2E tests + run: pnpm exec playwright test + env: + CI: true + + - name: Upload Playwright report + if: always() + uses: actions/upload-artifact@v4 + with: + name: playwright-report + path: playwright-report/ + retention-days: 14 + + coverage-report: + name: Coverage Report + if: github.event_name == 'pull_request' + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: "20" + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + version: 10 + run_install: false + + - name: Cache pnpm store + uses: actions/cache@v4 + with: + path: ~/.pnpm-store + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Run unit tests with coverage + run: pnpm test:ci + env: + CI: true + + - name: Coverage report on PR + if: always() + uses: davelosert/vitest-coverage-report-action@v2 + with: + json-summary-path: coverage/coverage-summary.json + json-final-path: coverage/coverage-final.json + + - name: Upload coverage artifacts + if: always() + uses: actions/upload-artifact@v4 + with: + name: coverage-report + path: coverage/ + retention-days: 14 diff --git a/README.md b/README.md index 6668f1a3..e067a548 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,17 @@ Le projet Edukai vise à simplifier la création de matériel de révision perso L'application est lancée sur le port 3000 de votre machine (`http://localhost:3000`).
+## 🧪 Tests + +```bash +pnpm test # Unit tests (watch mode) +pnpm test:ci # Unit tests + coverage +pnpm test:e2e # Playwright E2E tests +pnpm test:e2e:headed # E2E with visible browser +``` + +See [docs/TESTING.md](docs/TESTING.md) for details on test structure and patterns. + ## 👥 Équipe - **Tristan Hourtoulle** - Développeur Frontend diff --git a/components/auth/signin-form.tsx b/components/auth/signin-form.tsx index 2c9858ee..eeed8e46 100644 --- a/components/auth/signin-form.tsx +++ b/components/auth/signin-form.tsx @@ -98,7 +98,7 @@ export function SigninForm({ render={({ field }) => ( - + @@ -124,7 +124,7 @@ export function SigninForm({ render={({ field }) => ( - + diff --git a/components/auth/signup-form.tsx b/components/auth/signup-form.tsx index 19f5818b..9c8342fd 100644 --- a/components/auth/signup-form.tsx +++ b/components/auth/signup-form.tsx @@ -96,7 +96,7 @@ export function SignupForm({ onSuccess, onError }: SignupFormProps) { htmlFor="firstName" className="text-sm font-medium text-gray-700 flex items-center gap-2" > - +