fix: add expected message result
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Alex Moreno 2024-11-28 13:02:58 +01:00
parent 6785779fe5
commit 838296e744
1 changed files with 2 additions and 4 deletions

View File

@ -24,7 +24,6 @@ module.exports = Self => {
Self.cancelShipment = async expeditionFk => {
const models = Self.app.models;
const mrw = await models.MrwConfig.findOne();
const {externalId} = await models.Expedition.findById(expeditionFk);
const clientType = await models.MrwConfig.getClientType(expeditionFk);
@ -39,12 +38,11 @@ module.exports = Self => {
});
const xmlString = response.data;
await Self.rawSql('CALL util.debugAdd(?,?);', ['cancelShipmentResponse', xmlString]);
const parser = new DOMParser();
const xmlDoc = parser.parseFromString(xmlString, 'text/xml');
console.log('xmlDoc', xmlDoc);
const result = xmlDoc.getElementsByTagName('Mensaje')[0].textContent;
return result.toLowerCase().includes('se ha cancelado correctamente');
return ['no se ha encontrado', 'se ha cancelado correctamente'].some(r => r.includes(result.toLowerCase()));
};
};