2.3 KiB
2.3 KiB
FitOS — zasady pracy z kodem
Struktura
app(React+Vite, 5173),admin(React+Vite, 5174),api(Express+Prisma+PostgreSQL, 9002).
Testy — obowiązkowe po każdej zmianie
- Konwencja: WSZYSTKIE testy projektu żyją w
<pkg>/test/— unit/komponent wtest/*(api:test/unit/+test/integration/), e2e wtest/e2e/. Rezultaty i artefakty też podtest/:test/results/(trace/screenshoty Playwright) itest/report/(raport HTML) — oba gitignore'owane. Nie twórz katalogów testowych pozatest/. app/admin:npm test(vitest),npm run test:e2e(Playwright, API mockowane, dev server sam).api:npm test(unit+integration, supertest).- Testy aktualizujesz w tej samej zmiance co kod. Zmiana UI → najpierw grep starych tekstów/selectorów w testach.
- e2e:
import { test } from './fixtures'(NIE@playwright/test) — guard FAIL przyconsole.error/pageerror; wyjątek:allowConsoleError(page, /re/)+ komentarz. Ignorowane: 401. 403/404/5xx = FAIL. - e2e bez API/DB:
mockApi(page, ...)ztest/e2e/mock-api.ts. Nowe pliki:test/e2e/<obszar>.spec.ts, opisy PL. - Selektory:
getByRole/getByText/input[type=...]—getByLabelNIE działa (Fieldbez<label>).
Zmiana kontraktu API — aktualizuj WSZYSTKO w jednej zmiance
api/src/routes/**+ walidacja zod +api/test/**- typy:
app/src/api/types.tsi/lubadmin/src/api/types.ts - front:
api/queries.ts,pages/**,store/auth.ts - mocki
app|admin/test/e2e/mock-api.ts+ testy e2e npm test(api) +npm test/test:e2e(dotknięte fronty)
prisma/schema.prisma → npm run prisma:migrate (kontener API sam robi migrate deploy + seed przy starcie).
Kontenery — rebuilduj tylko dotknięte
api/:fitos-api(9002) +fitos-db(pg16, wolumenfitos_pgdata).admin/: 9000 (nginx+dist).app/: 9001 (nginx+dist).- Zmiana
<pkg>/src/**(alboapi/prisma/**,index.html) → w katalogu<pkg>/:docker compose build <pkg> && docker compose up -d. .envapi →up -d --force-recreate api. Nigdy nie ruszaj wolumenufitos_pgdata.- Weryfikacja po zmianie api:
docker compose ps+curl localhost:9002/health.
Komendy
| komenda | |
|---|---|
| app/admin | npm test, npm run test:e2e, test:e2e:ui, test:e2e:install |
| api | npm test, npm run seed, npm run prisma:migrate |