- 00-Auth/02 Login : trailing whitespace - 03-Clients/04 Create : test data variant (Martin2, siret/phone différents) pour éviter le conflit unique sur les exécutions successives - 05-Invoices/04 Create : numéro F-2026-0047, dueDate au 2026-04-01 (passée → déclenche l'envoi immédiat des RelanceTasks BullMQ pour tester le pipeline outbound) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
69 lines
1.7 KiB
Plaintext
69 lines
1.7 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-0047",
|
|
"amountTtcCents": 124000,
|
|
"issueDate": "2026-04-20T09:00:00.000Z",
|
|
"dueDate": "2026-04-01T09: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).
|
|
|
|
Si `planId` est fourni : programme automatiquement les RelanceTasks
|
|
BullMQ pour chaque step du plan (sendAt = dueDate + offsetDays).
|
|
Les jobs scheduled sont visibles via :
|
|
`docker exec rubis-redis redis-cli zrange bull:relances:delayed 0 -1`
|
|
|
|
Pour tester l'envoi immédiat : passer une `dueDate` dans le passé →
|
|
la première RelanceTask est programmée à `now + 1min`. Mailpit
|
|
http://localhost:8025 affichera le mail capté ~1min plus tard.
|
|
|
|
Capture `invoiceId` dans l'env pour les requêtes suivantes.
|
|
}
|