Skip to content

Commit

Permalink
Merge pull request #5930 from espoon-voltti/generated-holidays
Browse files Browse the repository at this point in the history
Generoidaan pyhäpäivät sen sijaan että pidettäisiin niitä tietokannassa
  • Loading branch information
akheron authored Nov 13, 2024
2 parents 8a1d4df + 5328b55 commit 64dc63d
Show file tree
Hide file tree
Showing 56 changed files with 541 additions and 486 deletions.
20 changes: 3 additions & 17 deletions frontend/src/e2e-test/dev-api/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ import {
createEmployeePins,
createFeeThresholds,
createFridgeChild,
createHoliday,
createHolidayPeriod,
createHolidayQuestionnaire,
createIncome,
Expand Down Expand Up @@ -128,7 +127,6 @@ import {
DevEmployee,
DevEmployeePin,
DevFridgeChild,
DevHoliday,
DevIncome,
DevInvoice,
DevParentship,
Expand Down Expand Up @@ -872,14 +870,6 @@ export class Fixture {
})
}

static holiday(initial?: Partial<DevHoliday>): HolidayBuilder {
return new HolidayBuilder({
date: LocalDate.todayInHelsinkiTz(),
description: 'Holiday description',
...initial
})
}

static guardian(child: DevPerson, guardian: DevPerson) {
return new GuardianBuilder({
childId: child.id,
Expand Down Expand Up @@ -1647,13 +1637,6 @@ export class HolidayQuestionnaireBuilder extends FixtureBuilder<FixedPeriodQuest
}
}

export class HolidayBuilder extends FixtureBuilder<DevHoliday> {
async save() {
await createHoliday({ body: this.data })
return this.data
}
}

export class GuardianBuilder extends FixtureBuilder<{
guardianId: string
childId: string
Expand Down Expand Up @@ -3073,6 +3056,9 @@ export const testDaycareGroup: DevDaycareGroup = {
jamixCustomerNumber: null
}

/**
* @deprecated Use `Fixture.placement()` instead
**/
export function createDaycarePlacementFixture(
id: string,
childId: string,
Expand Down
22 changes: 0 additions & 22 deletions frontend/src/e2e-test/generated/api-clients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ import { DevFosterParent } from './api-types'
import { DevFridgeChild } from './api-types'
import { DevFridgePartner } from './api-types'
import { DevGuardian } from './api-types'
import { DevHoliday } from './api-types'
import { DevIncome } from './api-types'
import { DevInvoice } from './api-types'
import { DevMobileDevice } from './api-types'
Expand Down Expand Up @@ -1044,27 +1043,6 @@ export async function createFridgePartner(
}


/**
* Generated from fi.espoo.evaka.shared.dev.DevApi.createHoliday
*/
export async function createHoliday(
request: {
body: DevHoliday
}
): Promise<void> {
try {
const { data: json } = await devClient.request<JsonOf<void>>({
url: uri`/holiday`.toString(),
method: 'POST',
data: request.body satisfies JsonCompatible<DevHoliday>
})
return json
} catch (e) {
throw new DevApiError(e)
}
}


/**
* Generated from fi.espoo.evaka.shared.dev.DevApi.createHolidayPeriod
*/
Expand Down
16 changes: 0 additions & 16 deletions frontend/src/e2e-test/generated/api-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -610,14 +610,6 @@ export interface DevGuardian {
guardianId: UUID
}

/**
* Generated from fi.espoo.evaka.shared.dev.DevHoliday
*/
export interface DevHoliday {
date: LocalDate
description: string
}

/**
* Generated from fi.espoo.evaka.shared.dev.DevIncome
*/
Expand Down Expand Up @@ -1382,14 +1374,6 @@ export function deserializeJsonDevFridgePartner(json: JsonOf<DevFridgePartner>):
}


export function deserializeJsonDevHoliday(json: JsonOf<DevHoliday>): DevHoliday {
return {
...json,
date: LocalDate.parseIso(json.date)
}
}


export function deserializeJsonDevIncome(json: JsonOf<DevIncome>): DevIncome {
return {
...json,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ let page: Page
let header: CitizenHeader
let calendarPage: CitizenCalendarPage
let children: DevPerson[]
const today = LocalDate.of(2022, 1, 5)
const today = LocalDate.of(2022, 1, 12)

const groupEventId = uuidv4()
const unitEventId = uuidv4()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ let page: Page
let header: CitizenHeader
let calendarPage: CitizenCalendarPage
let children: DevPerson[]
const today = LocalDate.of(2022, 1, 3)
const today = LocalDate.of(2022, 1, 10)

const groupId = uuidv4()
const groupEventId = uuidv4()
Expand Down Expand Up @@ -300,7 +300,7 @@ describe.each(e)('Citizen calendar discussion surveys (%s)', (env) => {
testChild.id,
'Individual survey',
reservationId,
`to 6.1. klo 12:00 - 12:30`,
`to 13.1. klo 12:00 - 12:30`,
true
)

Expand All @@ -309,7 +309,7 @@ describe.each(e)('Citizen calendar discussion surveys (%s)', (env) => {
testChild.id,
'Restricted survey',
noncancellableEventTimeId,
`ti 4.1. klo 10:00 - 10:30`,
`ti 11.1. klo 10:00 - 10:30`,
false
)
})
Expand All @@ -329,7 +329,7 @@ describe.each(e)('Citizen calendar discussion surveys (%s)', (env) => {
testChild.id,
'Group-wide survey',
groupReservationId,
`to 6.1. klo 09:00 - 09:30`,
`to 13.1. klo 09:00 - 09:30`,
true
)
})
Expand Down Expand Up @@ -370,7 +370,7 @@ describe.each(e)('Citizen calendar discussion surveys (%s)', (env) => {
testChild.id,
'Individual survey',
reservationId,
`to 6.1. klo 12:00 - 12:30`,
`to 13.1. klo 12:00 - 12:30`,
true
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ describe('Holiday periods and questionnaires', () => {
const assertFreeAbsences = (hasFreeAbsences: boolean) =>
assertCalendarDayRange(
calendar,
LocalDate.of(2035, 12, 26),
LocalDate.of(2036, 1, 1),
LocalDate.of(2035, 12, 27),
LocalDate.of(2035, 12, 31),
[
{
childIds: [child.id],
Expand Down Expand Up @@ -244,8 +244,8 @@ describe('Holiday periods and questionnaires', () => {
const assertFreeAbsences = (hasFreeAbsences: boolean) =>
assertCalendarDayRange(
calendar,
LocalDate.of(2035, 12, 26),
LocalDate.of(2036, 1, 1),
LocalDate.of(2035, 12, 27),
LocalDate.of(2035, 12, 31),
[
{
childIds: [child.id, child2.id],
Expand All @@ -271,7 +271,7 @@ describe('Holiday periods and questionnaires', () => {

await assertFreeAbsences(true)

const dayView = await calendar.openDayView(LocalDate.of(2035, 12, 26))
const dayView = await calendar.openDayView(LocalDate.of(2035, 12, 27))
await dayView.assertAbsence(
child.id,
'Henkilökunnan merkitsemä poissaolo'
Expand Down Expand Up @@ -357,16 +357,16 @@ describe('Holiday periods and questionnaires', () => {
await holidayModal.assertNotEligible(child2)
await holidayModal.markHoliday(child, '26.12.2035 - 01.01.2036')

let today = LocalDate.of(2035, 12, 26)
while (today.isEqualOrBefore(LocalDate.of(2036, 1, 1))) {
let today = LocalDate.of(2035, 12, 27)
while (today.isEqualOrBefore(LocalDate.of(2035, 12, 31))) {
await calendar.assertDay(today, [
{ childIds: [child.id], text: 'Maksuton poissaolo' },
{ childIds: [child2.id], text: 'Ilmoitus puuttuu' }
])
today = today.addBusinessDays(1)
}

const dayView = await calendar.openDayView(LocalDate.of(2035, 12, 26))
const dayView = await calendar.openDayView(LocalDate.of(2035, 12, 27))
await dayView.assertAbsence(
child.id,
'Henkilökunnan merkitsemä poissaolo'
Expand Down
45 changes: 23 additions & 22 deletions frontend/src/e2e-test/specs/0_citizen/citizen-reservations.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -608,15 +608,14 @@ describe.each(e)('Citizen attendance reservations (%s)', (env) => {

test('Citizen creates a weekly reservation that spans a holiday', async () => {
// Monday
const reservationDay = today.addDays(19)
const reservationDay = LocalDate.of(2022, 4, 4)
const reservationRange = new FiniteDateRange(
reservationDay,
reservationDay.addWeeks(2)
reservationDay.addWeeks(2).subDays(1)
)

// Wednesday
const holiday = today.addDays(21)
await Fixture.holiday({ date: holiday }).save()
// Pitkäperjantai
const holiday = LocalDate.of(2022, 4, 15)

const calendarPage = await openCalendarPage(env)

Expand All @@ -636,14 +635,19 @@ describe.each(e)('Citizen attendance reservations (%s)', (env) => {
await reservationsModal.save()

for (const date of reservationRange.dates()) {
if (date.isWeekend()) continue
if (date.isEqual(holiday)) continue
await calendarPage.assertDay(date, [
{
childIds: [testChild.id, testChild2.id, testChildRestricted.id],
text: '08:00–16:00'
}
])
if (date.isWeekend()) {
// nothing
} else if (date.isEqual(holiday)) {
await calendarPage.assertHoliday(date)
await calendarPage.assertDay(date, [])
} else {
await calendarPage.assertDay(date, [
{
childIds: [testChild.id, testChild2.id, testChildRestricted.id],
text: '08:00–16:00'
}
])
}
}
})
})
Expand Down Expand Up @@ -682,13 +686,13 @@ describe.each(e)('Calendar day content (%s)', (env) => {

it('Holiday', async () => {
await init()
await Fixture.holiday({ date: today }).save()
const holiday = LocalDate.of(2022, 1, 6)

const calendarPage = await openCalendarPage(env)
await calendarPage.assertHoliday(today)
await calendarPage.assertDay(today, [])
await calendarPage.assertHoliday(holiday)
await calendarPage.assertDay(holiday, [])

const day = await calendarPage.openDayView(today)
const day = await calendarPage.openDayView(holiday)
await day.assertNoActivePlacementsMsgVisible()
})

Expand Down Expand Up @@ -1313,11 +1317,8 @@ describe('Citizen calendar child visibility', () => {
shiftCare: 'FULL'
}).save()

const firstReservationDay = today.addDays(14)
await Fixture.holiday({
date: firstReservationDay,
description: 'Test holiday 1'
}).save()
// Pitkäperjantai
const firstReservationDay = LocalDate.of(2022, 4, 15)

const calendarPage = await openCalendarPage('desktop')
await calendarPage.assertChildCountOnDay(firstReservationDay, 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,12 @@ describe('Service time alert', () => {
while (i < 31) {
const date = LocalDate.of(2022, 1, i)
i++
if (date.getIsoDayOfWeek() === 6 || date.getIsoDayOfWeek() === 7) continue

// skip holidays and weekends
if (date.isEqual(LocalDate.of(2022, 1, 1))) continue
if (date.isEqual(LocalDate.of(2022, 1, 6))) continue
if (date.isWeekend()) continue

await Fixture.attendanceReservation({
type: 'RESERVATIONS',
date: date,
Expand All @@ -246,7 +251,7 @@ describe('Service time alert', () => {
unitId: testDaycare.id,
date: date,
arrived: LocalTime.of(8, 0),
departed: LocalTime.of(15, 32)
departed: LocalTime.of(16, 30)
}).save()
}

Expand All @@ -259,8 +264,8 @@ describe('Service time alert', () => {
await summary.textElement.assertTextEquals(
'Kaarina\n' +
'\n' +
'Suunnitelma 60 h / 75 h\n' +
'Toteuma 75 h 20 min / 75 h'
'Suunnitelma 57 h / 75 h\n' +
'Toteuma 76 h 30 min / 75 h'
)
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,7 @@ describe.each(e)(
})

test('Citizen creates a repeating reservation on a bank holiday', async () => {
const firstReservationDay = june7th2023.addDays(14).addDays(2) //Friday, holiday

await Fixture.holiday({
date: firstReservationDay,
description: 'Test holiday 1'
}).save()
const firstReservationDay = june7th2023.addDays(14).addDays(2) //Friday, juhannusaatto

const { child, parent } = await addTestData(june7th2023)
const calendarPage = await openCalendarPage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ describe('Employee - Unit month calendar', () => {
})

describe('Holiday period reservations', () => {
const holidayStart = today.addMonths(1).addDays(2) // Monday
const holidayStart = today.addMonths(1).addDays(16) // Monday
const holidayEnd = holidayStart.addDays(4) // Friday
const holidayRange = new FiniteDateRange(holidayStart, holidayEnd)

Expand Down
Loading

0 comments on commit 64dc63d

Please sign in to comment.