test(mobile): blindage contrat API — suite apiClient + durcissement INVALID_RESPONSE

- tests/apiClient.test.ts (tsx/node:test, fetch stubbé) : paths/méthodes/query/body de tous les endpoints, multipart FormData sans Content-Type manuel, enveloppe {data,meta}, Bearer (présent/absent/fusion)
- cas hostiles : 2xx HTML/corps vide/JSON invalide/objet sans data/error → ApiError INVALID_RESPONSE (jamais de TypeError ni data indéfini) ; bare 5xx → HTTP_<status> ; fetch rejeté (dont AbortError) → NETWORK_ERROR ; [] toléré en data
- client.ts : parse d'enveloppe stricte dans request() (nouveau code client INVALID_RESPONSE)
- package.json : scripts test:api + test (db + api)
This commit is contained in:
m
2026-09-10 20:16:27 +02:00
parent d5886c678b
commit eddab392a2
3 changed files with 226 additions and 3 deletions
+3 -1
View File
@@ -34,7 +34,9 @@
"ios": "expo run:ios",
"web": "expo start --web",
"test:db": "tsx --test tests/migrations.test.ts tests/repositories.test.ts",
"test:migrations": "tsx --test tests/migrations.test.ts"
"test:migrations": "tsx --test tests/migrations.test.ts",
"test:api": "tsx --test tests/apiClient.test.ts",
"test": "npm run test:db && npm run test:api"
},
"private": true
}