7565-testToMaster #2567

Merged
alexm merged 250 commits from 7565-testToMaster into master 2024-06-11 06:31:18 +00:00
6 changed files with 20 additions and 133 deletions
Showing only changes of commit f78f8ab6b0 - Show all commits

View File

@ -1819,17 +1819,14 @@ INSERT INTO `vn`.`clientSample`(`id`, `clientFk`, `typeFk`, `created`, `workerFk
INSERT INTO `vn`.`claimState`(`id`, `code`, `description`, `roleFk`, `priority`, `hasToNotify`) INSERT INTO `vn`.`claimState`(`id`, `code`, `description`, `roleFk`, `priority`, `hasToNotify`)
VALUES VALUES
( 1, 'pending', 'Pendiente', 1, 1, 0), ( 1, 'pending', 'Pendiente', 1, 1, 0),
( 2, 'managed', 'Gestionado', 72, 5, 0),
( 3, 'resolved', 'Resuelto', 72, 7, 0), ( 3, 'resolved', 'Resuelto', 72, 7, 0),
( 4, 'canceled', 'Anulado', 72, 6, 1), ( 4, 'canceled', 'Anulado', 72, 6, 1),
( 5, 'incomplete', 'Incompleta', 1, 3, 1), ( 5, 'incomplete', 'Incompleta', 1, 3, 1);
( 6, 'mana', 'Mana', 72, 4, 0),
( 7, 'lack', 'Faltas', 72, 2, 0);
INSERT INTO `vn`.`claim`(`id`, `ticketCreated`, `claimStateFk`, `clientFk`, `workerFk`, `responsibility`, `isChargedToMana`, `created`, `packages`, `ticketFk`) INSERT INTO `vn`.`claim`(`id`, `ticketCreated`, `claimStateFk`, `clientFk`, `workerFk`, `responsibility`, `isChargedToMana`, `created`, `packages`, `ticketFk`)
VALUES VALUES
(1, util.VN_CURDATE(), 1, 1101, 18, 3, 0, util.VN_CURDATE(), 0, 11), (1, util.VN_CURDATE(), 1, 1101, 18, 3, 0, util.VN_CURDATE(), 0, 11),
(2, util.VN_CURDATE(), 2, 1101, 18, 3, 0, util.VN_CURDATE(), 1, 16), (2, util.VN_CURDATE(), 4, 1101, 18, 3, 0, util.VN_CURDATE(), 1, 16),
(3, util.VN_CURDATE(), 3, 1101, 18, 1, 1, util.VN_CURDATE(), 5, 7), (3, util.VN_CURDATE(), 3, 1101, 18, 1, 1, util.VN_CURDATE(), 5, 7),
(4, util.VN_CURDATE(), 3, 1104, 18, 5, 0, util.VN_CURDATE(), 10, 8); (4, util.VN_CURDATE(), 3, 1104, 18, 5, 0, util.VN_CURDATE(), 10, 8);

View File

@ -0,0 +1,8 @@
UPDATE vn.claim c
JOIN vn.claimState cs ON cs.id = c.claimStateFk
JOIN vn.claimState ns ON ns.code = 'resolved'
SET c.claimStateFk = ns.id
WHERE cs.code IN ('managed', 'mana', 'lack', 'relocation');
DELETE FROM vn.claimState
WHERE code IN ('managed', 'mana', 'lack', 'relocation');

View File

@ -21,7 +21,7 @@ describe('Claim edit basic data path', () => {
}); });
it(`should edit claim state and observation fields`, async() => { it(`should edit claim state and observation fields`, async() => {
await page.autocompleteSearch(selectors.claimBasicData.claimState, 'Gestionado'); await page.autocompleteSearch(selectors.claimBasicData.claimState, 'Resuelto');
await page.clearInput(selectors.claimBasicData.packages); await page.clearInput(selectors.claimBasicData.packages);
await page.write(selectors.claimBasicData.packages, '2'); await page.write(selectors.claimBasicData.packages, '2');
await page.waitToClick(selectors.claimBasicData.saveButton); await page.waitToClick(selectors.claimBasicData.saveButton);
@ -48,7 +48,7 @@ describe('Claim edit basic data path', () => {
await page.waitForSelector(selectors.claimBasicData.claimState); await page.waitForSelector(selectors.claimBasicData.claimState);
const result = await page.waitToGetProperty(selectors.claimBasicData.claimState, 'value'); const result = await page.waitToGetProperty(selectors.claimBasicData.claimState, 'value');
expect(result).toEqual('Gestionado'); expect(result).toEqual('Resuelto');
}); });
it('should confirm the "is paid with mana" and "Pick up" checkbox are checked', async() => { it('should confirm the "is paid with mana" and "Pick up" checkbox are checked', async() => {

View File

@ -64,7 +64,7 @@ describe('claimstate isEditable()', () => {
const options = {transaction: tx}; const options = {transaction: tx};
const ctx = {req: {accessToken: {userId: claimManagerId}}}; const ctx = {req: {accessToken: {userId: claimManagerId}}};
const result = await app.models.ClaimState.isEditable(ctx, 7, options); const result = await app.models.ClaimState.isEditable(ctx, 5, options);
expect(result).toEqual(true); expect(result).toEqual(true);

View File

@ -21,12 +21,13 @@ describe('Update Claim', () => {
claimStatesMap = claimStates.reduce((acc, state) => ({...acc, [state.code]: state.id}), {}); claimStatesMap = claimStates.reduce((acc, state) => ({...acc, [state.code]: state.id}), {});
}); });
const newDate = Date.vnNew(); const newDate = Date.vnNew();
const claimManagerId = 72;
const originalData = { const originalData = {
ticketFk: 3, ticketFk: 3,
clientFk: 1101, clientFk: 1101,
ticketCreated: newDate, ticketCreated: newDate,
workerFk: 18, workerFk: 18,
claimStateFk: 2, claimStateFk: 5,
isChargedToMana: true, isChargedToMana: true,
responsibility: 4, responsibility: 4,
observation: 'observation' observation: 'observation'
@ -77,7 +78,6 @@ describe('Update Claim', () => {
spyOn(chatModel, 'sendCheckingPresence').and.callThrough(); spyOn(chatModel, 'sendCheckingPresence').and.callThrough();
const pendingState = claimStatesMap.pending; const pendingState = claimStatesMap.pending;
const claimManagerId = 72;
const ctx = { const ctx = {
req: { req: {
accessToken: {userId: claimManagerId}, accessToken: {userId: claimManagerId},
@ -104,85 +104,7 @@ describe('Update Claim', () => {
} }
}); });
it(`should success to update the claimState to 'managed' and send a rocket message`, async() => { it(`should success to update the claimState to 'canceled' and send two rocket message`, async() => {
const tx = await app.models.Claim.beginTransaction({});
try {
const options = {transaction: tx};
const newClaim = await app.models.Claim.create(originalData, options);
const chatModel = app.models.Chat;
spyOn(chatModel, 'sendCheckingPresence').and.callThrough();
const managedState = claimStatesMap.managed;
const claimManagerId = 72;
const ctx = {
req: {
accessToken: {userId: claimManagerId},
headers: {origin: url}
},
args: {
observation: 'valid observation',
claimStateFk: managedState,
hasToPickUp: false
}
};
ctx.req.__ = i18n.__;
await app.models.Claim.updateClaim(ctx, newClaim.id, options);
let updatedClaim = await app.models.Claim.findById(newClaim.id, null, options);
expect(updatedClaim.observation).toEqual(ctx.args.observation);
expect(chatModel.sendCheckingPresence).toHaveBeenCalled();
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it(`should success to update the claimState to 'resolved' and send a rocket message`, async() => {
const tx = await app.models.Claim.beginTransaction({});
try {
const options = {transaction: tx};
const newClaim = await app.models.Claim.create(originalData, options);
const chatModel = app.models.Chat;
spyOn(chatModel, 'sendCheckingPresence').and.callThrough();
const resolvedState = claimStatesMap.resolved;
const claimManagerId = 72;
const ctx = {
req: {
accessToken: {userId: claimManagerId},
headers: {origin: url}
},
args: {
observation: 'valid observation',
claimStateFk: resolvedState,
hasToPickUp: false
}
};
ctx.req.__ = i18n.__;
await app.models.Claim.updateClaim(ctx, newClaim.id, options);
let updatedClaim = await app.models.Claim.findById(newClaim.id, null, options);
expect(updatedClaim.observation).toEqual(ctx.args.observation);
expect(chatModel.sendCheckingPresence).toHaveBeenCalled();
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it(`should success to update the claimState to 'canceled' and send a rocket message`, async() => {
const tx = await app.models.Claim.beginTransaction({}); const tx = await app.models.Claim.beginTransaction({});
try { try {
@ -194,7 +116,6 @@ describe('Update Claim', () => {
spyOn(chatModel, 'sendCheckingPresence').and.callThrough(); spyOn(chatModel, 'sendCheckingPresence').and.callThrough();
const canceledState = claimStatesMap.canceled; const canceledState = claimStatesMap.canceled;
const claimManagerId = 72;
const ctx = { const ctx = {
req: { req: {
accessToken: {userId: claimManagerId}, accessToken: {userId: claimManagerId},
@ -212,46 +133,7 @@ describe('Update Claim', () => {
let updatedClaim = await app.models.Claim.findById(newClaim.id, null, options); let updatedClaim = await app.models.Claim.findById(newClaim.id, null, options);
expect(updatedClaim.observation).toEqual(ctx.args.observation); expect(updatedClaim.observation).toEqual(ctx.args.observation);
expect(chatModel.sendCheckingPresence).toHaveBeenCalled(); expect(chatModel.sendCheckingPresence).toHaveBeenCalledTimes(2);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it(`should success to update the claimState to 'incomplete' and send a rocket message`, async() => {
const tx = await app.models.Claim.beginTransaction({});
try {
const options = {transaction: tx};
const newClaim = await app.models.Claim.create(originalData, options);
const chatModel = app.models.Chat;
spyOn(chatModel, 'sendCheckingPresence').and.callThrough();
const incompleteState = 5;
const claimManagerId = 72;
const ctx = {
req: {
accessToken: {userId: claimManagerId},
headers: {origin: url}
},
args: {
observation: 'valid observation',
claimStateFk: incompleteState,
hasToPickUp: false
}
};
ctx.req.__ = i18n.__;
await app.models.Claim.updateClaim(ctx, newClaim.id, options);
let updatedClaim = await app.models.Claim.findById(newClaim.id, null, options);
expect(updatedClaim.observation).toEqual(ctx.args.observation);
expect(chatModel.sendCheckingPresence).toHaveBeenCalled();
await tx.rollback(); await tx.rollback();
} catch (e) { } catch (e) {

View File

@ -21,7 +21,7 @@ describe('Update Claim', () => {
clientFk: 1101, clientFk: 1101,
ticketCreated: newDate, ticketCreated: newDate,
workerFk: 18, workerFk: 18,
claimStateFk: 2, claimStateFk: 1,
isChargedToMana: true, isChargedToMana: true,
responsibility: 4, responsibility: 4,
observation: 'observation' observation: 'observation'