Skip to content

Commit

Permalink
Merge pull request #6315 from espoon-voltti/discussion-survey-notific…
Browse files Browse the repository at this point in the history
…ation-fix

Korjataan keskustelukyselyiden sähköpostimuistus jos lapsi on varahoidossa
  • Loading branch information
patari authored Jan 30, 2025
2 parents 1ab5b24 + 8decff2 commit bb53049
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import fi.espoo.evaka.shared.async.AsyncJobRunner
import fi.espoo.evaka.shared.auth.AuthenticatedUser
import fi.espoo.evaka.shared.auth.CitizenAuthLevel
import fi.espoo.evaka.shared.auth.UserRole
import fi.espoo.evaka.shared.dev.DevBackupCare
import fi.espoo.evaka.shared.dev.DevCalendarEvent
import fi.espoo.evaka.shared.dev.DevCalendarEventAttendee
import fi.espoo.evaka.shared.dev.DevCalendarEventTime
Expand Down Expand Up @@ -1913,6 +1914,73 @@ class CalendarEventServiceIntegrationTest : FullApplicationTest(resetDbBeforeEac
assertEmails(expectedRecipients, notificationEmailContent, expectedFromAddress)
}

@Test
fun `notifications are sent even child in backup care`() {
val email = "[email protected]"
db.transaction { tx ->
// Email address is needed
tx.updatePersonalDetails(
testAdult_1.id,
PersonalDataUpdate(
preferredName = "",
phone = "",
backupPhone = "",
email = "[email protected]",
),
)
}
db.transaction { tx ->
tx.insert(
DevBackupCare(
childId = testChild_1.id,
unitId = testDaycare2.id,
groupId = groupId2,
period = FiniteDateRange(placementStart, placementEnd),
)
)
}

val form =
CalendarEventForm(
unitId = testDaycare.id,
tree = mapOf(groupId to setOf(testChild_1.id)),
title = "Group survey",
description = "gsu",
period = FiniteDateRange(today.plusDays(3), today.plusDays(3)),
eventType = CalendarEventType.DISCUSSION_SURVEY,
times =
listOf(
CalendarEventTimeForm(
date = today.plusDays(1),
timeRange = TimeRange(LocalTime.of(8, 0), LocalTime.of(9, 0)),
)
),
)

val event = createCalendarEvent(form)

calendarEventNotificationService.scheduleDiscussionSurveyDigests(db, now)

asyncJobRunner.runPendingJobsSync(RealEvakaClock())

val expectedRecipients = listOf(testAdult_1.copy(email = email))

val emailDetails =
DiscussionSurveyCreationNotificationData(
eventId = event.id,
eventTitle = HtmlSafe(event.title),
eventDescription = HtmlSafe(event.description),
)

val notificationEmailContent =
emailMessageProvider.discussionSurveyCreationNotification(
language = Language.fi,
notificationDetails = emailDetails,
)
val expectedFromAddress = "${emailEnv.senderNameFi} <${emailEnv.senderAddress}>"
assertEmails(expectedRecipients, notificationEmailContent, expectedFromAddress)
}

@Test
fun `reminder sent for impending discussion time reservation`() {
val email = "[email protected]"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,11 @@ AND (cea.child_id IS NULL OR EXISTS(
SELECT 1 FROM generate_series(lower(ce.period), upper(ce.period) - INTERVAL '1 day', '1 day') d
JOIN realized_placement_one(d::date) rp ON true
WHERE rp.child_id = cea.child_id
AND (cea.group_id IS NULL OR rp.group_id = cea.group_id)
AND rp.unit_id = cea.unit_id
AND (cea.group_id IS NULL
OR ce.event_type = 'DAYCARE_EVENT' AND rp.group_id = cea.group_id
OR ce.event_type = 'DISCUSSION_SURVEY' AND rp.placement_group_id = cea.group_id)
AND (ce.event_type = 'DAYCARE_EVENT' AND rp.unit_id = cea.unit_id
OR ce.event_type = 'DISCUSSION_SURVEY' AND rp.placement_unit_id = cea.unit_id)
))
GROUP BY ce.id, cea.unit_id, eu.id
"""
Expand Down

0 comments on commit bb53049

Please sign in to comment.