refs #6882 absence #2271
|
@ -27,7 +27,7 @@ describe('Worker calendar path', () => {
|
|||
});
|
||||
|
||||
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.waitForTimeout(reasonableTimeBetweenClicks);
|
||||
await page.click(selectors.workerCalendar.penultimateMondayOfJanuary);
|
||||
|
@ -56,7 +56,7 @@ describe('Worker calendar path', () => {
|
|||
await page.waitForTimeout(reasonableTimeBetweenClicks);
|
||||
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)
|
||||
throw new UserError(`Cannot add holidays on this day`);
|
||||
|
||||
if ((isHalfHoliday && hasHalfHoliday) && isFestive)
|
||||
throw new UserError(`Cannot add more than one '1/2 day vacation'`);
|
||||
if (isHalfHoliday && (hasHalfHoliday || isFestive))
|
||||
throw new UserError(`Cannot add more than one '1/2 day vacation`);
|
||||
|
||||
const absence = await models.Calendar.create({
|
||||
businessFk: labour.businessFk,
|
||||
|
|
|
@ -101,7 +101,36 @@ describe('Worker createAbsence()', () => {
|
|||
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() => {
|
||||
|
|
Loading…
Reference in New Issue