Commit Graph

202 Commits

Author SHA1 Message Date
djalim 401160aa30 refactor(notes): improve error handling and formatting
Check Deno code / Check Deno code (pull_request) Successful in 5s
Tests / Unit tests (pull_request) Successful in 11s
Tests / Integration tests (pull_request) Failing after 1m18s
docs: update CLAUDE.md formatting
2026-04-27 19:45:26 +02:00
djalim 9368e68622 refactor(notes): replace AuthenticatedState with withRules, simplify handlers
refactor: add withRules wrapper to API routes

Use withRules to enforce permissions instead of manual checks.
Remove FORBIDDEN constant, simplify handlers, import withRules,
adjust GET/POST/PUT/DELETE handlers.
Centralizes auth logic.

refactor: replace manual auth checks with withRules wrapper for routes

refactor(student routes): replace manual employee checks with withRules wrapper
2026-04-27 19:45:26 +02:00
djalim e2d22ff4b3 feat(defaults/withRules.ts): add own_teaching_note rule for teacher access 2026-04-27 19:45:26 +02:00
djalim ad64fd0a99 feat(defaults/withRules): add permission rule wrapper 2026-04-27 19:45:26 +02:00
Clément Oudelet f71128a7f3 PMPR-44 : fix missing newline
Check Deno code / Check Deno code (pull_request) Successful in 5s
Tests / Unit tests (pull_request) Successful in 12s
Tests / Integration tests (pull_request) Successful in 1m14s
Check Deno code / Check Deno code (push) Successful in 5s
Tests / Unit tests (push) Successful in 12s
Tests / Integration tests (push) Successful in 1m13s
2026-04-27 17:19:57 +00:00
Clément Oudelet 720a380be8 PMPR-44 : fix formatting 2026-04-27 17:19:57 +00:00
Clément Oudelet 6c602cb10a PMPR-44 : POST /notes/import-xlsx - importer des notes via Excel 2026-04-27 17:19:57 +00:00
djalim bb09c1cce5 chore: formated tests
Check Deno code / Check Deno code (pull_request) Successful in 5s
Tests / Unit tests (pull_request) Successful in 12s
Tests / Integration tests (pull_request) Successful in 1m18s
Check Deno code / Check Deno code (push) Successful in 5s
Tests / Unit tests (push) Successful in 11s
Tests / Integration tests (push) Successful in 1m13s
2026-04-27 18:58:19 +02:00
djalim f162fcaadc feat: add role_write permission and update e2e tests
Check Deno code / Check Deno code (pull_request) Failing after 5s
Tests / Unit tests (pull_request) Successful in 13s
Tests / Integration tests (pull_request) Successful in 1m12s
Add role_write permission to permissions table and update migrations.
Update e2e tests to use DB integration and seed permissions.
Add seedPermissions helper.
2026-04-27 18:56:04 +02:00
djalim 2c5e4ebf11 feat(fresh.gen.ts): add routes for notes edition, recap and island recap
Check Deno code / Check Deno code (pull_request) Failing after 5s
Tests / Unit tests (pull_request) Successful in 12s
Tests / Integration tests (pull_request) Failing after 1m17s
feat(notes): add NoteRecap island component for student grade recap

feat: add adjust controls to UI component

Add placeholder, value binding, onInput handler, apply/reset buttons,
and display of adjusted value.

feat(notes): add edition and recap pages, update styles and links
2026-04-27 18:22:23 +02:00
djalim 757e364af0 chore(docker): add .dockerignore and update Dockerfile
Add .dockerignore to exclude node_modules, .git, coverage, .env.
Update Dockerfile to install nodejs/npm, copy package.json, run npm install, and build.
Update compose.prod.yml to set working_dir, restart no, and use array command.
Move drizzle-kit from devDependencies to dependencies.
2026-04-27 17:29:31 +02:00
djalim 378cbb0c06 style: format import success message and drop zone JSX
Check Deno code / Check Deno code (pull_request) Successful in 5s
Tests / Unit tests (pull_request) Successful in 12s
Tests / Integration tests (pull_request) Failing after 1m7s
Apply consistent string concatenation in ImportNotes and UploadStudents.
Format JSX drop zone for better readability.
2026-04-27 17:11:46 +02:00
djalim d3de5c29e7 refactor: add migration, seed permissions, update permissions API
feat(notes): add XLSX import island and admin route

feat(upload): add drag‑and‑drop upload, template download, UI tweaks
2026-04-27 17:08:58 +02:00
djalim 733259e317 feat : fixed some page not being as described in the figma 2026-04-27 11:21:32 +02:00
djalim 56019ad372 fix: fixed test ci 2026-04-27 00:04:28 +02:00
djalim fcc9547a30 feat(dev): add compose files and dev-login bypass route
- compose.prod.yml: production stack with registry image, healthcheck,
  migration service
- compose.test.yml: local test stack with source mount and LOCAL=true
- routes/dev-login.ts: fake admin JWT login, only active when LOCAL=true
- routes/_middleware.ts: expose /dev-login as public route

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 23:01:59 +02:00
djalim 5ba8b8cb68 feat(ui): implement full UI layer for all modules
Add interactive island components and server partials for notes,
students, and admin modules, following the Figma prototype design.

- static/styles/ui.css: shared component library (buttons, tables,
  chips, cards, filters, tabs, form inputs)
- notes: NotesView (student grade view with UE cards, promo tabs,
  weighted averages), AdminConsultNotes, AdminUEs islands + partials
- students: ConsultStudents (list/filter/delete), AdminPromotions
  (CRUD) islands + partials
- admin: AdminModules, AdminUsers, AdminRoles islands + partials
- All partials use State type with unknown cast for session access

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 22:54:10 +02:00
djalim 34b7ac0231 docs: update CLAUDE.md to reflect completed API layer
Mark all implemented endpoints as , document the 3-level test
architecture, and clarify that UI pages are the next priority.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 22:29:10 +02:00
djalim 714486f43c chore: formated tests
Check Deno code / Check Deno code (pull_request) Successful in 5s
Tests / Unit tests (pull_request) Successful in 12s
Tests / Integration tests (pull_request) Successful in 1m9s
Check Deno code / Check Deno code (push) Successful in 6s
Tests / Unit tests (push) Successful in 12s
Tests / Integration tests (push) Successful in 1m13s
2026-04-26 19:07:15 +02:00
djalim b0930b8da2 fix: correct handler bugs exposed by test suite
Check Deno code / Check Deno code (pull_request) Failing after 6s
Tests / Unit tests (pull_request) Successful in 13s
Tests / Integration tests (pull_request) Successful in 1m17s
- ajustements [numEtud]/[idUE]: fix .where() missing and() — PUT/DELETE
  were applying only numEtud condition, modifying all rows for a student
- modules/users/enseignements POST: add try/catch, return 500 on invalid JSON
- modules/[idModule] PUT: add try/catch + type check on nom (string required)
- modules POST: add .trim() check to reject whitespace-only id/nom
- users POST: add .trim() check to reject whitespace-only id/nom/prenom
- ues POST: add .trim() check to reject whitespace-only nom
- notes POST: add type check (typeof number) and bounds check (0 ≤ note ≤ 20)
- ue-modules POST: add coeff >= 0 validation

Update robustness tests to reflect fixed behavior (remove [BUG] labels,
replace assertRejects with status code assertions).
2026-04-26 19:01:53 +02:00
djalim 2f4d8db1bf test: add full test coverage for notes, ues, ue-modules, ajustements, enseignements, users
Check Deno code / Check Deno code (pull_request) Failing after 6s
Tests / Unit tests (pull_request) Successful in 13s
Tests / Integration tests (pull_request) Failing after 1m14s
- Unit tests (mock DB + API) for all missing endpoints
- Integration tests (Drizzle direct) for all missing entities
- E2E tests (handler + real DB) for all missing endpoints
- Robustness tests: invalid inputs, SQL injection, type errors, business rule violations
- Seed helpers: seedNotes, seedUeModules, seedEnseignements, seedAjustements
- Add test:coverage and test:coverage:html tasks to deno.json

Tests expose known handler bugs (marked [BUG] in test names):
- ajustements PUT/DELETE: .where() without and() modifies all rows for student
- Missing try/catch in modules, users, enseignements handlers
- Whitespace accepted as valid string values
- No type or business rule validation (note bounds, coeff >= 0)
2026-04-26 18:25:00 +02:00
djalim a3b55d0a1b fix: remove unused body variable in permissions e2e test
Check Deno code / Check Deno code (pull_request) Successful in 6s
Tests / Unit tests (pull_request) Successful in 11s
Tests / Integration tests (pull_request) Successful in 1m19s
Check Deno code / Check Deno code (push) Successful in 6s
Tests / Unit tests (push) Successful in 11s
Tests / Integration tests (push) Successful in 1m7s
2026-04-26 13:34:43 +00:00
djalim 86080b8042 test(permissions): add unit and e2e tests for GET /permissions (#115)
Handler is static (no DB), tests verify the 9 known permissions are returned
with correct id/nom shapes.
2026-04-26 13:34:43 +00:00
djalim e3a7e20993 fix: remove unused assertExists import
Check Deno code / Check Deno code (pull_request) Successful in 5s
Tests / Unit tests (pull_request) Successful in 12s
Tests / Integration tests (pull_request) Successful in 1m1s
Check Deno code / Check Deno code (push) Successful in 5s
Tests / Unit tests (push) Successful in 11s
Tests / Integration tests (push) Successful in 1m10s
2026-04-26 13:34:27 +00:00
djalim c5d02a2890 style: fix deno fmt and lint 2026-04-26 13:34:27 +00:00
djalim c86d20ca81 test(modules): add unit, integration and e2e tests for /modules (#113)
- unit: fixture shapes, mock API (GET/POST/PUT/DELETE + 409), mock DB CRUD
- integration: list, create, get, duplicate rejection, update, delete
- e2e: handler calls with mock context + real DB, covers 400/403/404/409
2026-04-26 13:34:27 +00:00
djalim f038e4020b style: fix deno fmt and lint
Check Deno code / Check Deno code (pull_request) Successful in 6s
Tests / Unit tests (pull_request) Successful in 11s
Tests / Integration tests (pull_request) Successful in 59s
Check Deno code / Check Deno code (push) Successful in 6s
Tests / Unit tests (push) Successful in 11s
Tests / Integration tests (push) Successful in 1m2s
2026-04-26 13:34:09 +00:00
djalim e75098083a test(roles): add unit, integration and e2e tests for /roles (#112)
- unit: fixture shapes, mock API (GET/POST/PUT/DELETE), mock DB CRUD
- integration: list, create, assign permissions, update, reset perms, delete
- e2e: handler calls with mock context + real DB, covers 400/404 cases
2026-04-26 13:34:09 +00:00
djalim e3eefd945c chore: remove .github workflows (act only uses .gitea)
Check Deno code / Check Deno code (pull_request) Successful in 5s
Tests / Unit tests (pull_request) Successful in 12s
Tests / Integration tests (pull_request) Successful in 1m3s
Check Deno code / Check Deno code (push) Successful in 5s
Tests / Unit tests (push) Successful in 12s
Tests / Integration tests (push) Successful in 1m3s
2026-04-26 13:08:03 +00:00
djalim d25c353018 fix: remove unused assertExists import 2026-04-26 13:08:03 +00:00
djalim b3eb1b60a5 style: fix deno fmt and lint 2026-04-26 13:08:03 +00:00
djalim 222c3237f0 test(promotions): add unit, integration and e2e tests for /promotions (#110)
- unit: fixture shapes, mock API (GET/POST/PUT/DELETE), mock DB CRUD
- integration: real DB list, create, get, update, delete, not-found cases
- e2e: handler calls with mock context + real DB, covers 400/403/404 cases
2026-04-26 13:08:03 +00:00
djalim e2f5bf7b95 ci: remove Run tests step from lint workflow
Check Deno code / Check Deno code (push) Successful in 6s
Tests / Unit tests (push) Successful in 12s
Tests / Integration tests (push) Successful in 57s
Check Deno code / Check Deno code (pull_request) Successful in 6s
Tests / Unit tests (pull_request) Successful in 12s
Tests / Integration tests (pull_request) Successful in 1m3s
2026-04-26 14:30:40 +02:00
djalim cd5c524ff0 style: fix deno fmt on students tests and drizzle.config
Check Deno code / Check Deno code (pull_request) Failing after 8s
Tests / Unit tests (pull_request) Successful in 11s
Tests / Integration tests (pull_request) Successful in 58s
2026-04-26 14:18:09 +02:00
djalim e5c6c389ea test(students): add unit, integration and e2e tests for /students (#109)
Check Deno code / Check Deno code (pull_request) Failing after 5s
Tests / Unit tests (pull_request) Successful in 12s
Tests / Integration tests (pull_request) Successful in 58s
- unit: fixture shapes, mock API (GET/POST/PUT/DELETE), mock DB operations
- integration: real DB CRUD via testDb (list, filter, create, get, update, delete)
- e2e: handler calls directly with mock FreshContext + real DB
  covers auth (employee vs non-employee), 400/403/404 cases
- adds test:e2e deno task and CI step
- adds tests/helpers/handler.ts with makeEmployeeContext, makeContextWithAffiliation,
  makeGetRequest, makeJsonRequest utilities

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 14:00:38 +02:00
djalim daa7f4951f fix(ci): fix postgres TCP setup and truncateAll superuser error
Check Deno code / Check Deno code (push) Failing after 5s
Tests / Unit tests (push) Successful in 11s
Tests / Integration tests (push) Successful in 55s
- Use apt-get install + configure listen_addresses + md5 auth in pg_hba
  so psql can connect via 127.0.0.1 (not just Unix socket)
- Use pg_ctlcluster restart after config changes + wait for pg_isready
- Replace session_replication_role (requires superuser) with a single
  TRUNCATE ... CASCADE which handles FK deps without elevated privileges
- All 3 integration tests now pass in CI (act + Gitea Actions)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 11:30:33 +00:00
djalim a95818e3bf fix(ci): use connection URL with ssl:false in drizzle config 2026-04-26 11:30:33 +00:00
djalim 26eedcc4f2 debug(ci): add connection diagnostics before migrate 2026-04-26 11:30:33 +00:00
djalim ce4782580d fix(ci): remove unsupported --verbose from drizzle-kit migrate 2026-04-26 11:30:33 +00:00
djalim 91248370da fix(ci): add GRANT on public schema and verbose migrate output 2026-04-26 11:30:33 +00:00
djalim 6b8b5e6aa3 fix(ci): start postgres with pg_ctlcluster instead of systemctl 2026-04-26 11:30:33 +00:00
djalim d1c3b93755 fix(ci): install postgres via apt-get instead of docker 2026-04-26 11:30:33 +00:00
djalim f42df29f06 fix(ci): use docker run instead of services for postgres 2026-04-26 11:30:33 +00:00
djalim c8b808f509 fix(ci): use bash /dev/tcp for postgres readiness check 2026-04-26 11:30:33 +00:00
djalim fdfdd74894 fix(ci): replace pg_isready with nc for postgres readiness check 2026-04-26 11:30:33 +00:00
djalim 60dde4675c fix(ci): use deno install for unit tests, add postgres readiness check 2026-04-26 11:30:33 +00:00
djalim fef9457795 fix(ci): install npm deps before running unit tests 2026-04-26 11:30:33 +00:00
djalim 6db04045f4 fix(lint): add version to drizzle-orm imports and prefix unused NOT_FOUND 2026-04-26 11:30:33 +00:00
djalim cdd9c0bf06 chore(test): set up integration test framework with postgres
- Generate Drizzle migrations (databases/migrations/)
- Add databases/schema.kit.ts for drizzle-kit (Node-compatible imports)
- Update drizzle.config.ts to use schema.kit.ts
- Add deno tasks: test:unit, test:integration, migrate
- Add tests/helpers/db_integration.ts: testDb, truncateAll, seed helpers
- Add .gitea/workflows/test.yml: CI with postgres service container
- Update lint.yml: run test:unit only (no DB needed)
- Update deploy.yml: add check-code job, gate deploy on it
2026-04-26 11:30:33 +00:00
djalim 980efcfbc3 ci: add Deno code check job and enable lint on develop
Check Deno code / Check Deno code (pull_request) Failing after 9s
Check Deno code / Check Deno code (push) Failing after 6s
2026-04-23 14:29:08 +02:00