refs #6882 absence #2271

Merged
carlossa merged 13 commits from 6682-notHolidays into dev 2024-05-08 10:27:21 +00:00
3 changed files with 34 additions and 5 deletions
Showing only changes of commit c355595384 - Show all commits

View File

@ -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 ');
});
});

View File

@ -110,8 +110,8 @@ module.exports = Self => {
if (holiday && isFestive)
throw new UserError(`Cannot add holidays on this day`);
carlossa marked this conversation as resolved Outdated
Outdated
Review

if (isHalfHoliday && (hasHalfHoliday || isFestive))

if (isHalfHoliday && (hasHalfHoliday || isFestive))
if ((isHalfHoliday && hasHalfHoliday) && isFestive)
throw new UserError(`Cannot add more than one '1/2 day vacation'`);
if (isHalfHoliday && (hasHalfHoliday || isFestive))
carlossa marked this conversation as resolved Outdated
Outdated
Review

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`);
const absence = await models.Calendar.create({
businessFk: labour.businessFk,

View File

@ -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() => {