refs #6882 absence #2271
|
@ -27,7 +27,7 @@ describe('Worker calendar path', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('as hr', () => {
|
describe('as hr', () => {
|
||||||
it('should set two days as holidays on the calendar and check the total holidays increased by 1.5', async() => {
|
it('should set two days as holidays on the calendar and check the total holidays increased by 1', async() => {
|
||||||
await page.waitToClick(selectors.workerCalendar.holidays);
|
await page.waitToClick(selectors.workerCalendar.holidays);
|
||||||
await page.waitForTimeout(reasonableTimeBetweenClicks);
|
await page.waitForTimeout(reasonableTimeBetweenClicks);
|
||||||
await page.click(selectors.workerCalendar.penultimateMondayOfJanuary);
|
await page.click(selectors.workerCalendar.penultimateMondayOfJanuary);
|
||||||
|
@ -56,7 +56,7 @@ describe('Worker calendar path', () => {
|
||||||
await page.waitForTimeout(reasonableTimeBetweenClicks);
|
await page.waitForTimeout(reasonableTimeBetweenClicks);
|
||||||
await page.click(selectors.workerCalendar.secondFridayOfJun);
|
await page.click(selectors.workerCalendar.secondFridayOfJun);
|
||||||
|
|
||||||
expect(await page.getProperty(selectors.workerCalendar.totalHolidaysUsed, 'innerText')).toContain(' 1.5 ');
|
expect(await page.getProperty(selectors.workerCalendar.totalHolidaysUsed, 'innerText')).toContain(' 1 ');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -110,8 +110,8 @@ module.exports = Self => {
|
||||||
if (holiday && isFestive)
|
if (holiday && isFestive)
|
||||||
throw new UserError(`Cannot add holidays on this day`);
|
throw new UserError(`Cannot add holidays on this day`);
|
||||||
|
|
||||||
carlossa marked this conversation as resolved
Outdated
|
|||||||
if ((isHalfHoliday && hasHalfHoliday) && isFestive)
|
if (isHalfHoliday && (hasHalfHoliday || isFestive))
|
||||||
carlossa marked this conversation as resolved
Outdated
alexm
commented
El error este el posaria de lo primer (aixina no cal fer peticions) i sobra el isFestive El error este el posaria de lo primer (aixina no cal fer peticions) i sobra el isFestive
|
|||||||
throw new UserError(`Cannot add more than one '1/2 day vacation'`);
|
throw new UserError(`Cannot add more than one '1/2 day vacation`);
|
||||||
|
|
||||||
const absence = await models.Calendar.create({
|
const absence = await models.Calendar.create({
|
||||||
businessFk: labour.businessFk,
|
businessFk: labour.businessFk,
|
||||||
|
|
|
@ -101,7 +101,36 @@ describe('Worker createAbsence()', () => {
|
||||||
error = e;
|
error = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(error.message).toEqual(`Cannot add more than one '1/2 day vacation'`);
|
expect(error.message).toEqual(`Cannot add more than one '1/2 day vacation`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should throw an error when adding a "Holiday" absence if there's a festivity`, async() => {
|
||||||
|
const ctx = {
|
||||||
|
req: {accessToken: {userId: 9}},
|
||||||
|
args: {
|
||||||
|
id: 3,
|
||||||
|
businessFk: 3,
|
||||||
|
absenceTypeId: 1,
|
||||||
|
dated: '2001-12-08T23:00:00.000Z'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const workerId = 1;
|
||||||
|
|
||||||
|
const tx = await app.models.Calendar.beginTransaction({});
|
||||||
|
|
||||||
|
let error;
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
await app.models.Worker.createAbsence(ctx, workerId, options);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
error = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(error.message).toEqual(`Cannot add holidays on this day`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should throw an error when adding a absence if the worker has hours recorded that day and not is a half absence`, async() => {
|
it(`should throw an error when adding a absence if the worker has hours recorded that day and not is a half absence`, async() => {
|
||||||
|
|
Loading…
Reference in New Issue
if (isHalfHoliday && (hasHalfHoliday || isFestive))