From 849bcd1ff55633de28469dfd812b21a6cb9805b6 Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 14 Jan 2025 13:39:43 +0100 Subject: [PATCH] feat: refs #6629 test back updateObservations --- .../client/specs/updateAddress.spec.js | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/modules/client/back/methods/client/specs/updateAddress.spec.js b/modules/client/back/methods/client/specs/updateAddress.spec.js index 0453332d7..e8d6bb8d8 100644 --- a/modules/client/back/methods/client/specs/updateAddress.spec.js +++ b/modules/client/back/methods/client/specs/updateAddress.spec.js @@ -157,4 +157,57 @@ describe('Address updateAddress', () => { throw e; } }); + + fit('should update ticket observations when updateObservations is true', async() => { + const tx = await models.Client.beginTransaction({}); + const client = 1103; + const address = 123; + const ticket = 31; + const observationType = 3; + + const salesAssistantId = 21; + const addressObservation = 'nuevo texto'; + const ticketObservation = 'texto a modificar'; + + try { + const options = {transaction: tx}; + ctx.req.accessToken.userId = salesAssistantId; + ctx.args = { + updateObservations: true, + incotermsFk: incotermsId, + provinceFk: provinceId, + customsAgentFk: customAgentOneId + }; + + await models.AddressObservation.create({ + addressFk: address, + observationTypeFk: observationType, + description: addressObservation + }, options); + + await models.TicketObservation.create({ + ticketFk: ticket, + observationTypeFk: observationType, + description: ticketObservation + }, options); + + await models.Client.updateAddress(ctx, client, address, options); + + const updatedObservation = await models.TicketObservation.findOne({ + where: {ticketFk: ticket, observationTypeFk: observationType} + }, options); + + // const address = await models.Address.findById(addressId, null, options); + + // const addressObservation = await models.addressObservation.findById(addressId, null, options); + + expect(updatedObservation).toEqual(addressObservation); + // expect(1).toEqual(1); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); });