modify test updatePortfolio
This commit is contained in:
parent
a9b6dcacfe
commit
7e8c15e413
|
@ -1,9 +1,10 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
xdescribe('Client updatePortfolio', () => {
|
||||
const salesPersonId = 18;
|
||||
describe('Client updatePortfolio', () => {
|
||||
const clientId = 1108;
|
||||
it('should update the portfolioWeight', async() => {
|
||||
it('should update the portfolioWeight when the salesPerson of a client changes', async() => {
|
||||
const salesPersonId = 18;
|
||||
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
|
||||
try {
|
||||
|
@ -15,9 +16,34 @@ xdescribe('Client updatePortfolio', () => {
|
|||
|
||||
await models.Client.updatePortfolio();
|
||||
|
||||
let [vendedores] = await models.Client.rawSql(`SELECT portfolioWeight FROM bs.vendedores WHERE Id_Trabajador = ${salesPersonId}; `, null, options);
|
||||
let [salesPerson] = await models.Client.rawSql(`SELECT portfolioWeight FROM bs.salesPerson WHERE workerFk = ${salesPersonId}; `, null, options);
|
||||
|
||||
expect(vendedores.portfolioWeight).toEqual(expectedResult);
|
||||
expect(salesPerson.portfolioWeight).toEqual(expectedResult);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
// 3742 first have to migrate vn2008.Clientes_cedidos to vn
|
||||
xit('should keep the same portfolioWeight when a salesperson is unassigned of a client', async() => {
|
||||
const salesPersonId = 19;
|
||||
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const expectedResult = 34.40;
|
||||
|
||||
await models.Client.rawSql(`UPDATE vn.client SET salesPersonFk = NULL WHERE id = ${clientId}; `);
|
||||
|
||||
await models.Client.updatePortfolio();
|
||||
|
||||
let [salesPerson] = await models.Client.rawSql(`SELECT portfolioWeight FROM bs.salesPerson WHERE workerFk = ${salesPersonId}; `, null, options);
|
||||
|
||||
expect(salesPerson.portfolioWeight).toEqual(expectedResult);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
|
|
Loading…
Reference in New Issue