@@ -179,6 +179,8 @@ class UITestFixture {
179179 /* *
180180 * Sets up lightweight mocking to prevent calendar reloads from clearing test events.
181181 * This mocks ApplicationController.onMainActivityResumed to skip the calendar rescan.
182+ * Also mocks alarm-triggered notification posting to prevent flaky tests from stale
183+ * AlarmManager alarms that persist across test runs on local emulators.
182184 */
183185 private fun setupCalendarReloadPrevention () {
184186 DevLog .info(LOG_TAG , " Setting up calendar reload prevention" )
@@ -196,6 +198,17 @@ class UITestFixture {
196198 ApplicationController .onCalendarChanged(any())
197199 } just Runs
198200
201+ // Mock alarm-triggered methods to prevent notifications from stale AlarmManager alarms.
202+ // Local emulators persist alarms across test runs, causing flaky notification interference.
203+ // (GitHub Actions uses fresh emulators so this is less common there.)
204+ every {
205+ ApplicationController .onEventAlarm(any())
206+ } just Runs
207+
208+ every {
209+ ApplicationController .fireEventReminder(any(), any(), any())
210+ } just Runs
211+
199212 calendarReloadPrevented = true
200213 DevLog .info(LOG_TAG , " Calendar reload prevention active" )
201214 }
@@ -551,6 +564,9 @@ class UITestFixture {
551564
552565 /* *
553566 * Launches MainActivity with ActivityScenario.
567+ *
568+ * If calendar reload prevention is active, also clears any pre-existing notifications
569+ * to prevent them from interfering with UI tests (e.g., blocking toolbar buttons).
554570 */
555571 fun launchMainActivity (): ActivityScenario <MainActivity > {
556572 DevLog .info(LOG_TAG , " Launching MainActivity" )
@@ -560,6 +576,13 @@ class UITestFixture {
560576 DevLog .info(LOG_TAG , " MainActivity is ready: ${activity.javaClass.simpleName} " )
561577 }
562578 dismissStartupDialogs()
579+
580+ // Clear any pre-existing notifications that could interfere with UI tests
581+ // (e.g., heads-up notifications blocking toolbar buttons)
582+ if (calendarReloadPrevented) {
583+ cancelAllNotifications()
584+ }
585+
563586 return scenario
564587 }
565588
0 commit comments