Collection Bruno (.bru text files, comme Postman mais file-based versionable) qui couvre l'API V1 actuelle. Open Collection → bruno/ → sélectionner l'environnement "local". Domaines couverts (22 requêtes) : - 00-Auth : Signup, Login, Logout - 01-Account : Get/Update profile - 02-Organizations : Get/Update my org - 03-Clients : List, List+stats, Search, Create, Create duplicate (409), Create without email (422), Get detail, Update - 04-Plans : List, Get by slug, Update (steps remplacés) - 05-Invoices : List, List+filters, Counts, Create, Get detail, Mark paid Environnement local (bruno/environments/local.bru) : - baseUrl, email/password/fullName en dur - token, userId, organizationId, clientId, invoiceId remplis automatiquement par les script:post-response Chaque requête a : - assertions Chai (statut, shape de la réponse) - bloc docs avec sémantique métier + erreurs typiques - inheritance auth Bearer via folder.bru pour ne pas répéter le header Mise à jour de docs/tech/dev-setup.md pour pointer vers la collection. Le parcours recommandé Signup → Update org → Create client → Create invoice → Mark paid couvre le happy path et permet de checker rubisCount qui s'incrémente.
56 lines
1.2 KiB
Plaintext
56 lines
1.2 KiB
Plaintext
meta {
|
|
name: 04 Create
|
|
type: http
|
|
seq: 4
|
|
}
|
|
|
|
post {
|
|
url: {{baseUrl}}/api/v1/invoices
|
|
body: json
|
|
auth: inherit
|
|
}
|
|
|
|
body:json {
|
|
{
|
|
"clientId": "{{clientId}}",
|
|
"clientName": "Boulangerie Martin SARL",
|
|
"numero": "F-2026-0042",
|
|
"amountTtcCents": 124000,
|
|
"issueDate": "2026-04-20T09:00:00.000Z",
|
|
"dueDate": "2026-05-20T09:00:00.000Z"
|
|
}
|
|
|
|
}
|
|
|
|
script:post-response {
|
|
if (res.getStatus() === 201) {
|
|
bru.setEnvVar("invoiceId", res.getBody().data.id);
|
|
}
|
|
}
|
|
|
|
tests {
|
|
test("201 Created", function () {
|
|
expect(res.getStatus()).to.equal(201);
|
|
});
|
|
test("invoiceId saved", function () {
|
|
expect(bru.getEnvVar("invoiceId")).to.not.be.empty;
|
|
});
|
|
test("rubisEarned = 1 (bonus saisie)", function () {
|
|
expect(res.getBody().data.rubisEarned).to.equal(1);
|
|
});
|
|
}
|
|
|
|
docs {
|
|
POST /api/v1/invoices
|
|
|
|
Saisie manuelle. Résolution client en 3 étapes :
|
|
1. `clientId` fourni → utilise tel quel
|
|
2. sinon match par nom (case-insensitive) sur les clients existants
|
|
3. sinon création à la volée — `clientEmail` REQUIS sinon 422
|
|
`client_email_required`
|
|
|
|
Bonus +1 rubis à la création (gamification).
|
|
|
|
Capture `invoiceId` dans l'env pour les requêtes suivantes.
|
|
}
|