fix(transport) : bloc prix par défaut (CLIENT), sens seul en ligne 1, payload omet scalaires vides (422 inline au lieu de 400) (ERP-169)
This commit is contained in:
@@ -761,6 +761,8 @@ describe('carrierPrice (util) — bascule CLIENT/FOURNISSEUR + champs requis par
|
||||
it('isCarrierPriceValid : faux si branche incomplète, vrai si branche complète + communs', () => {
|
||||
const base = { ...emptyCarrierPrice(), containerType: 'BENNE', pricingUnit: 'FORFAIT', price: '10', priceState: 'EN_COURS' }
|
||||
// Direction non choisie → invalide.
|
||||
expect(isCarrierPriceValid({ ...base, direction: null })).toBe(false)
|
||||
// Sens CLIENT par défaut mais branche incomplète → invalide.
|
||||
expect(isCarrierPriceValid(base)).toBe(false)
|
||||
// CLIENT sans adresse/site → invalide.
|
||||
expect(isCarrierPriceValid({ ...base, direction: 'CLIENT', clientIri: CLIENT })).toBe(false)
|
||||
@@ -786,17 +788,28 @@ describe('useCarrierForm — onglet Prix (ERP-169)', () => {
|
||||
return form
|
||||
}
|
||||
|
||||
it('démarre vide ; « + Nouveau prix » autorisé sur liste vide, bloqué si dernier bloc incomplet', () => {
|
||||
it('démarre avec un bloc CLIENT par défaut ; « + Nouveau prix » bloqué tant qu\'il est incomplet', () => {
|
||||
const form = createdForm()
|
||||
expect(form.prices.value).toHaveLength(0)
|
||||
expect(form.canAddPrice.value).toBe(true)
|
||||
|
||||
form.addPrice()
|
||||
// Un bloc présent d'office, sens CLIENT pré-sélectionné.
|
||||
expect(form.prices.value).toHaveLength(1)
|
||||
// Bloc vide → on ne peut pas en ajouter un autre.
|
||||
expect(form.prices.value[0]?.direction).toBe('CLIENT')
|
||||
// Bloc incomplet → on ne peut pas en ajouter un autre.
|
||||
expect(form.canAddPrice.value).toBe(false)
|
||||
form.addPrice()
|
||||
expect(form.prices.value).toHaveLength(1)
|
||||
|
||||
// Une fois le bloc complété, l'ajout est autorisé.
|
||||
const p = form.prices.value[0]
|
||||
if (p) {
|
||||
p.clientIri = '/api/clients/3'
|
||||
p.clientDeliveryAddressIri = '/api/client_addresses/8'
|
||||
p.departureSiteIri = '/api/sites/1'
|
||||
p.price = '120'
|
||||
p.priceState = 'EN_COURS'
|
||||
}
|
||||
expect(form.canAddPrice.value).toBe(true)
|
||||
form.addPrice()
|
||||
expect(form.prices.value).toHaveLength(2)
|
||||
})
|
||||
|
||||
it('submitPrices : POST des nouveaux prix (branche CLIENT), capture l\'id, finalise', async () => {
|
||||
|
||||
Reference in New Issue
Block a user