fixed the absences unit test #423
|
@ -55,15 +55,18 @@ describe('Client credit insurance path', () => {
|
|||
expect(message.text).toEqual('The grade must be similar to the last one');
|
||||
});
|
||||
|
||||
it('should provide a correct grade and succesfully save a new credit then be redirected to the credit index', async() => {
|
||||
it('should provide a correct grade and succesfully save a new credit', async() => {
|
||||
await page.write(selectors.clientCreditInsurance.newInsuranceGrade, '999');
|
||||
await page.waitToClick(selectors.clientCreditInsurance.saveNewInsuranceCredit);
|
||||
const message = await page.waitForSnackbar();
|
||||
await page.waitForState('client.card.creditInsurance.insurance.index');
|
||||
|
||||
expect(message.text).toEqual('Data saved!');
|
||||
});
|
||||
|
||||
it('should be redirected to the credit index', async() => {
|
||||
await page.waitForState('client.card.creditInsurance.insurance.index');
|
||||
});
|
||||
|
||||
it('should check the amount of credits is the expected', async() => {
|
||||
const result = await page.countElement(selectors.clientCreditInsurance.anyCreditInsuranceLine);
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
// 2066
|
||||
xdescribe('Worker absences()', () => {
|
||||
describe('Worker absences()', () => {
|
||||
it('should get the absence calendar for a full year contract', async() => {
|
||||
let ctx = {req: {accessToken: {userId: 106}}};
|
||||
let workerFk = 106;
|
||||
|
@ -84,14 +83,16 @@ xdescribe('Worker absences()', () => {
|
|||
yearStart.setDate(1);
|
||||
|
||||
const yearEnd = new Date();
|
||||
yearEnd.setHours(23, 59, 59, 59);
|
||||
yearEnd.setMonth(11);
|
||||
yearEnd.setDate(31);
|
||||
const currentYear = yearEnd.getFullYear();
|
||||
yearEnd.setFullYear(currentYear + 1);
|
||||
yearEnd.setHours(0, 0, 0, 0);
|
||||
yearEnd.setMonth(0);
|
||||
yearEnd.setDate(1);
|
||||
const startedTime = yearStart.getTime();
|
||||
const endedTime = yearEnd.getTime();
|
||||
const dayTimestamp = 1000 * 60 * 60 * 24;
|
||||
|
||||
const daysInYear = Math.floor((endedTime - startedTime) / dayTimestamp);
|
||||
const daysInYear = Math.round((endedTime - startedTime) / dayTimestamp);
|
||||
|
||||
// sets the holidays per year to the amount of days in the current year
|
||||
let holidaysConfig = await app.models.WorkCenterHoliday.findOne({
|
||||
|
@ -102,17 +103,11 @@ xdescribe('Worker absences()', () => {
|
|||
|
||||
let originalHolidaysValue = holidaysConfig.days;
|
||||
|
||||
await app.models.WorkCenterHoliday.updateAll(
|
||||
{
|
||||
workCenterFk: 1,
|
||||
year: today.getFullYear()
|
||||
},
|
||||
{
|
||||
days: daysInYear
|
||||
}
|
||||
);
|
||||
await holidaysConfig.updateAttribute('days', daysInYear);
|
||||
|
||||
// normal test begins
|
||||
const contract = await app.models.WorkerLabour.findById(106);
|
||||
const userId = 106;
|
||||
const contract = await app.models.WorkerLabour.findById(userId);
|
||||
const contractStartDate = contract.started;
|
||||
|
||||
const startingContract = new Date();
|
||||
|
@ -121,14 +116,13 @@ xdescribe('Worker absences()', () => {
|
|||
startingContract.setDate(1);
|
||||
|
||||
await app.models.WorkerLabour.rawSql(
|
||||
`UPDATE postgresql.business SET date_start = ? WHERE business_id = ?`,
|
||||
[startingContract, contract.businessFk]
|
||||
`UPDATE postgresql.business SET date_start = ?, date_end = ? WHERE business_id = ?`,
|
||||
[startingContract, yearEnd, contract.businessFk]
|
||||
);
|
||||
|
||||
let ctx = {req: {accessToken: {userId: 106}}};
|
||||
let workerFk = 106;
|
||||
let ctx = {req: {accessToken: {userId: userId}}};
|
||||
|
||||
let result = await app.models.Calendar.absences(ctx, workerFk, yearStart, yearEnd);
|
||||
let result = await app.models.Calendar.absences(ctx, userId, yearStart, yearEnd);
|
||||
let calendar = result[0];
|
||||
let absences = result[1];
|
||||
|
||||
|
|
Loading…
Reference in New Issue