Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .cursor/rules/github-actions.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
alwaysApply: false
---

## Github Action Rules

- Check if `package.json` exists in project root and summarize key scripts
- Check if `.nvmrc` exists in project root
- Check if `.env.example` exists in project root to identify key `env:` variables
- Always use `git branch -a | cat` to verify whether we use `main` or `master` branch
- Always use `env:` variables and secrets attached to jobs instead of global workflows
- Always use `npm ci` for Node-based dependency setup
- Extract common steps into composite actions in separate files
- Once you're done, as a final step conduct the following:

1. For each public action always use <tool>"Run Terminal"</tool> to see what is the most up-to-date version (use only major version):

```bash
curl -s https://api.github.com/repos/{owner}/{repo}/releases/latest | grep '"tag_name":' | sed -E 's/.*"v([0-9]+).*/\1/'
```

2. (Ask if needed) Use <tool>"Run Terminal"</tool> to fetch README.md and see if we're not using any deprecated actions by mistake:

```bash
curl -s https://raw.githubusercontent.com/{owner}/{repo}/refs/tags/v{TAG_VERSION}/README.md
```

3. (Ask if needed) Use <tool>"Run Terminal"</tool> to fetch repo metadata and see if we're not using any deprecated actions by mistake:

```bash
curl -s https://api.github.com/repos/{owner}/{repo} | grep '"archived":'
```

4. (Ask if needed) In case of linter issues related to action parameters, try to fetch action description directly from GitHub and use the following command:

```bash
curl -s https://raw.githubusercontent.com/{owner}/{repo}/refs/heads/{main/master}/action.yml
```
2 changes: 1 addition & 1 deletion .env.test.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ NEXT_PUBLIC_SUPABASE_ANON_KEY=
SUPABASE_ACCESS_TOKEN=
E2E_USERNAME_ID=
E2E_USERNAME=
E2E_PASSWORD=
E2E_PASSWORD=
126 changes: 126 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
name: Pull Request

on:
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review

env:
CI: "true"

jobs:
lint:
name: Lintowanie
runs-on: ubuntu-latest
environment: Integration
env:
NODE_ENV: development
NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.NEXT_PUBLIC_SUPABASE_URL }}
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }}
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version-file: .nvmrc

- name: Install dependencies
run: npm ci

- name: Run lint
run: npm run lint

unit-test:
name: Unit tests (coverage)
runs-on: ubuntu-latest
needs: lint
environment: Integration
env:
NODE_ENV: development
NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.NEXT_PUBLIC_SUPABASE_URL }}
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }}
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version-file: .nvmrc

- name: Install dependencies
run: npm ci

- name: Run unit tests with coverage
run: npm run test:coverage

- name: Upload unit test coverage
uses: actions/upload-artifact@v4
with:
name: vitest-coverage
path: coverage

e2e-test:
name: Playwright E2E tests
runs-on: ubuntu-latest
needs: lint
environment: Tests
env:
NODE_ENV: development
NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.NEXT_PUBLIC_SUPABASE_URL }}
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }}
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
E2E_USERNAME_ID: ${{ secrets.E2E_USERNAME_ID }}
E2E_USERNAME: ${{ secrets.E2E_USERNAME }}
E2E_PASSWORD: ${{ secrets.E2E_PASSWORD }}
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version-file: .nvmrc

- name: Install dependencies
run: npm ci

- name: Install Playwright browsers
run: npx playwright install chromium

- name: Run Playwright tests
run: npm run test:e2e

- name: Upload Playwright report
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: playwright-report

status-comment:
name: Status PR
runs-on: ubuntu-latest
needs:
- lint
- unit-test
- e2e-test
permissions:
contents: write
pull-requests: write
steps:
- name: Comment PR status
uses: peter-evans/create-or-update-comment@v5
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
✅ Wszystkie kontrole zakończone pomyślnie.
- Lintowanie: ✅
- Testy jednostkowe (z coverage): ✅
- Testy end-to-end: ✅
29 changes: 24 additions & 5 deletions PLAYWRIGHT_CONFIG_EXPLAINED.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,54 @@
## 🎯 Kluczowe ustawienia

### `fullyParallel: false`

**Co to robi:** Testy uruchamiają się jeden po drugim
**Dlaczego:** Łatwiej debugować na początku. Zmień na `true` gdy będziesz mieć dużo stabilnych testów.

### `workers: 1`

**Co to robi:** Tylko jedna przeglądarka w tym samym czasie
**Dlaczego:** Stabilniejsze, łatwiej śledzić co się dzieje

### `trace: "on"`

**Co to robi:** Zapisuje każdy krok testu (kliknięcia, nawigacja, itp.)
**Jak zobaczyć:** `npx playwright show-trace playwright-report/trace.zip`
**Kiedy:** Zawsze - zobaczysz dokładnie co poszło nie tak

### `screenshot: "only-on-failure"`

**Co to robi:** Robi zdjęcie ekranu gdy test failuje
**Gdzie:** `playwright-report/` folder

### `video: "off"`

**Co to robi:** Nie nagrywa wideo
**Dlaczego:** Trace + screenshoty wystarczą, wideo zajmuje dużo miejsca
**Kiedy włączyć:** Jak będziesz mieć bardzo trudny do zreprodukowania bug

### `baseURL: "http://localhost:3000"`

**Co to robi:** Możesz pisać `page.goto('/')` zamiast `page.goto('http://localhost:3000/')`
**Przykład:**

```typescript
// Zamiast tego:
await page.goto('http://localhost:3000/dashboard');
await page.goto("http://localhost:3000/dashboard");

// Piszesz:
await page.goto('/dashboard');
await page.goto("/dashboard");
```

### `webServer`

**Co to robi:** Automatycznie uruchamia `npm run dev` przed testami
**Bonus:** `reuseExistingServer: true` - jeśli masz już uruchomiony dev server, użyje go (szybciej)

## 🚀 Jak używać

### Pierwszy test

```bash
# Uruchom testy E2E
npm run test:e2e
Expand All @@ -52,6 +61,7 @@ npm run test:e2e
```

### Gdy test failuje

```bash
# Playwright automatycznie:
# 1. Zrobi screenshot → playwright-report/
Expand All @@ -68,6 +78,7 @@ npm run test:e2e:report
```

### Debugowanie

```bash
# Tryb debug - zatrzymuje test i pokazuje przeglądarkę
npm run test:e2e:debug
Expand All @@ -83,26 +94,32 @@ npm run test:e2e:ui
## 💡 Tipsy

### 1. Zacznij od prostych testów

```typescript
test('should load homepage', async ({ page }) => {
await page.goto('/');
test("should load homepage", async ({ page }) => {
await page.goto("/");
await expect(page).toHaveTitle(/Pathly/);
});
```

### 2. Używaj UI mode podczas pisania testów

```bash
npm run test:e2e:ui
```

Zobaczysz na żywo co robi Twój test!

### 3. Trace to Twój najlepszy przyjaciel

Gdy test failuje:

1. Otwórz `npm run test:e2e:report`
2. Kliknij na failed test
3. Zobacz trace - zobaczysz DOKŁADNIE co się stało, krok po kroku

### 4. Nie martw się o wydajność na początku

- `workers: 1` jest OK
- `fullyParallel: false` jest OK
- `trace: "on"` jest OK
Expand All @@ -112,18 +129,21 @@ Optymalizujesz później, gdy będziesz mieć dużo testów.
## 🎨 Kiedy zmienić ustawienia

### Masz już 10+ stabilnych testów?

```typescript
fullyParallel: true, // Szybsze testy
workers: 4, // 4 przeglądarki naraz
trace: "retain-on-failure", // Trace tylko przy failach
```

### Potrzebujesz wideo?

```typescript
video: "retain-on-failure", // Tylko przy failach
```

### Testujesz mobile?

```typescript
projects: [
{ name: "chromium", use: { ...devices["Desktop Chrome"] } },
Expand All @@ -147,4 +167,3 @@ A: To "nagranie" testu - każdy klik, nawigacja, assertion. Bezcenne przy debugo

**Q: Muszę testować na Firefox/Safari?**
A: Na początku nie. Chromium wystarczy. Dodasz później jeśli będzie potrzeba.

Loading