Choose manual profile over scheduled profile if active.

This commit is contained in:
Michelle Tang committed 2025-08-27 15:55:18 -04:00
1 parent 21363f085e
commit 8322bf3ecc
2 files changed
+3 -7

No files matched your search

@@ -49,11 +49,7 @@ object NotificationProfiles {
return manualProfile ?: scheduledProfile
}
return if (manualProfile == scheduledProfile) {
manualProfile
} else {
scheduledProfile
}
return manualProfile
}
private fun shouldClearManualOverride(manualProfile: NotificationProfile?, scheduledProfile: NotificationProfile?): Boolean {
@@ -111,7 +111,7 @@ class NotificationProfilesTest {
}
@Test
fun `when first is scheduled and second is manually enabled forever before first's schedule start then return first`() {
fun `when first is scheduled and second is manually enabled forever before first's schedule start then return second`() {
every { notificationProfileValues.manuallyEnabledProfile } returns second.id
every { notificationProfileValues.manuallyEnabledUntil } returns Long.MAX_VALUE
every { notificationProfileValues.manuallyDisabledAt } returns sunday830am.toMillis(ZoneOffset.UTC)
@@ -119,7 +119,7 @@ class NotificationProfilesTest {
val schedule = NotificationProfileSchedule(id = 3L, true, start = 900, daysEnabled = setOf(DayOfWeek.SUNDAY))
val profiles = listOf(first.copy(schedule = schedule), second)
assertThat(NotificationProfiles.getActiveProfile(profiles, sunday930am.toMillis(ZoneOffset.UTC), utc), "active profile is first").isEqualTo(profiles[0])
assertThat(NotificationProfiles.getActiveProfile(profiles, sunday930am.toMillis(ZoneOffset.UTC), utc), "active profile is second").isEqualTo(profiles[1])
}
@Test