@@ -321,67 +321,86 @@ public function online_activities_month_filter_only_shows_events_for_selected_mo
321321 }
322322
323323 #[Test]
324- public function online_activities_page_lists_activities_already_under_way (): void
324+ public function online_activities_page_excludes_activities_that_already_started (): void
325325 {
326326 $ this ->seed ('RolesAndPermissionsSeeder ' );
327327
328- $ ongoing = \App \Event::factory ()->create ([
329- 'start_date ' => Carbon::now ()->subMonths (4 ),
330- 'end_date ' => Carbon::now ()->addMonths (6 ),
328+ // Reported by the community: activities dated 2020-2022 were on the page because
329+ // they carry an end date years in the future.
330+ $ staleStartDate = \App \Event::factory ()->create ([
331+ 'start_date ' => Carbon::now ()->subYears (5 ),
332+ 'end_date ' => Carbon::now ()->addYear (),
331333 'status ' => 'APPROVED ' ,
332334 'activity_type ' => 'open-online ' ,
333335 'highlighted_status ' => 'NONE ' ,
334336 'language ' => ['en ' ],
335- 'title ' => 'Still Running Open Online Activity ' ,
337+ 'title ' => 'Started Years Ago Ends Far Away ' ,
336338 ]);
337339
338- $ finished = \App \Event::factory ()->create ([
339- 'start_date ' => Carbon::now ()->subMonths ( 4 ),
340- 'end_date ' => Carbon::now ()->subMonth ( ),
340+ $ startedThisMonth = \App \Event::factory ()->create ([
341+ 'start_date ' => Carbon::now ()->startOfMonth ( ),
342+ 'end_date ' => Carbon::now ()->addMonths ( 2 ),
341343 'status ' => 'APPROVED ' ,
342344 'activity_type ' => 'open-online ' ,
343345 'highlighted_status ' => 'NONE ' ,
344346 'language ' => ['en ' ],
345- 'title ' => 'Already Finished Open Online Activity ' ,
347+ 'title ' => 'Started Earlier This Month ' ,
348+ ]);
349+
350+ $ upcoming = \App \Event::factory ()->create ([
351+ 'start_date ' => Carbon::now ()->addWeek (),
352+ 'end_date ' => Carbon::now ()->addWeek ()->addDay (),
353+ 'status ' => 'APPROVED ' ,
354+ 'activity_type ' => 'open-online ' ,
355+ 'highlighted_status ' => 'NONE ' ,
356+ 'language ' => ['en ' ],
357+ 'title ' => 'Genuinely Upcoming Activity ' ,
346358 ]);
347359
348360 $ this ->get ('/online-activities ' )
349361 ->assertStatus (200 )
350- ->assertSee ($ ongoing ->title )
351- ->assertDontSee ($ finished ->title );
362+ ->assertSee ($ upcoming ->title )
363+ ->assertDontSee ($ staleStartDate ->title )
364+ ->assertDontSee ($ startedThisMonth ->title );
352365 }
353366
354367 #[Test]
355- public function activities_already_under_way_are_listed_under_the_current_month (): void
368+ public function the_month_filter_only_offers_months_that_are_still_to_come (): void
356369 {
357370 $ this ->seed ('RolesAndPermissionsSeeder ' );
358371
359- $ startedFourMonthsAgo = Carbon::now ()->subMonths ( 4 );
372+ $ pastStart = Carbon::now ()->subYears ( 5 );
360373
361- $ ongoing = \App \Event::factory ()->create ([
362- 'start_date ' => $ startedFourMonthsAgo ,
363- 'end_date ' => Carbon::now ()->addMonths ( 6 ),
374+ \App \Event::factory ()->create ([
375+ 'start_date ' => $ pastStart ,
376+ 'end_date ' => Carbon::now ()->addYear ( ),
364377 'status ' => 'APPROVED ' ,
365378 'activity_type ' => 'open-online ' ,
366379 'highlighted_status ' => 'NONE ' ,
367380 'language ' => ['en ' ],
368- 'title ' => 'Ongoing Grouped Under Current Month ' ,
381+ 'title ' => 'Stale Start Date Activity ' ,
369382 ]);
370383
371- $ now = Carbon::now ();
384+ $ nextMonth = Carbon::now ()-> addMonthNoOverflow ()-> startOfMonth ();
372385
373- \Livewire \Livewire::test (\App \Livewire \OnlineCalendar::class)
374- ->set ('selectedDate ' , $ now ->month .'/ ' .$ now ->year )
375- ->assertSee ($ ongoing ->title );
386+ \App \Event::factory ()->create ([
387+ 'start_date ' => $ nextMonth ->copy ()->addDays (3 ),
388+ 'end_date ' => $ nextMonth ->copy ()->addDays (4 ),
389+ 'status ' => 'APPROVED ' ,
390+ 'activity_type ' => 'open-online ' ,
391+ 'highlighted_status ' => 'NONE ' ,
392+ 'language ' => ['en ' ],
393+ 'title ' => 'Next Month Activity ' ,
394+ ]);
376395
377396 $ monthIds = collect (\Livewire \Livewire::test (\App \Livewire \OnlineCalendar::class)->get ('months ' ))
378397 ->pluck ('id ' );
379398
380- $ this ->assertContains ($ now ->month .'/ ' .$ now ->year , $ monthIds );
399+ $ this ->assertContains ($ nextMonth ->month .'/ ' .$ nextMonth ->year , $ monthIds );
381400 $ this ->assertNotContains (
382- $ startedFourMonthsAgo ->month .'/ ' .$ startedFourMonthsAgo ->year ,
401+ $ pastStart ->month .'/ ' .$ pastStart ->year ,
383402 $ monthIds ,
384- 'The month filter should not offer a past month just because an ongoing activity started then . '
403+ 'A past month must not appear in the filter just because an activity carries a far-off end date . '
385404 );
386405 }
387406
0 commit comments