7430_devToTest #2490
|
@ -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', async() => {
|
it('should set two days as holidays on the calendar and check the total holidays increased by 1.5', 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 ');
|
expect(await page.getProperty(selectors.workerCalendar.totalHolidaysUsed, 'innerText')).toContain(' 1.5 ');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -95,6 +95,9 @@ module.exports = Self => {
|
||||||
const hasHalfHoliday = result.halfHolidayCounter > 0;
|
const hasHalfHoliday = result.halfHolidayCounter > 0;
|
||||||
const isHalfHoliday = absenceType.code === 'halfHoliday';
|
const isHalfHoliday = absenceType.code === 'halfHoliday';
|
||||||
|
|
||||||
|
if (isHalfHoliday && hasHalfHoliday)
|
||||||
|
throw new UserError(`Cannot add more than one '1/2 day vacation`);
|
||||||
|
|
||||||
const isFestive = absenceType.isFestiveEligible;
|
const isFestive = absenceType.isFestiveEligible;
|
||||||
|
|
||||||
const workCenter = await models.Business.findOne({
|
const workCenter = await models.Business.findOne({
|
||||||
|
@ -106,13 +109,11 @@ module.exports = Self => {
|
||||||
dated: args.dated,
|
dated: args.dated,
|
||||||
workCenterFk: workCenter.workCenterFk
|
workCenterFk: workCenter.workCenterFk
|
||||||
}
|
}
|
||||||
},);
|
});
|
||||||
|
|
||||||
if (holiday && isFestive)
|
if (holiday && isFestive)
|
||||||
throw new UserError(`Cannot add holidays on this day`);
|
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`);
|
|
||||||
|
|
||||||
const absence = await models.Calendar.create({
|
const absence = await models.Calendar.create({
|
||||||
businessFk: labour.businessFk,
|
businessFk: labour.businessFk,
|
||||||
dayOffTypeFk: args.absenceTypeId,
|
dayOffTypeFk: args.absenceTypeId,
|
||||||
|
|
Loading…
Reference in New Issue