diff --git a/calendar/tests/behat/behat_calendar.php b/calendar/tests/behat/behat_calendar.php index 44b11d31e27..a350970faed 100644 --- a/calendar/tests/behat/behat_calendar.php +++ b/calendar/tests/behat/behat_calendar.php @@ -179,4 +179,21 @@ class behat_calendar extends behat_base { $url = new moodle_url('/calendar/view.php', ['view' => 'month']); $this->execute('behat_general::i_visit', [$url]); } + + /** + * Navigate to a specific view in the calendar. + * + * @Given /^I am viewing calendar in "([^"]+)" view$/ + * @param string $view The calendar view ('month', 'day' and 'upcoming') to navigate to. + * @return void + */ + public function i_am_viewing_calendar_in_view(string $view): void { + + if (!in_array($view, ['month', 'day', 'upcoming'])) { + throw new Exception("Invalid calendar view. Allowed values are: 'month', 'day' and 'upcoming'"); + } + + $url = new moodle_url('/calendar/view.php', ['view' => $view]); + $this->execute('behat_general::i_visit', [$url]); + } } diff --git a/mod/chat/tests/behat/chat_calendar_events.feature b/mod/chat/tests/behat/chat_calendar_events.feature index 164a576709f..a8d2c151755 100644 --- a/mod/chat/tests/behat/chat_calendar_events.feature +++ b/mod/chat/tests/behat/chat_calendar_events.feature @@ -22,7 +22,7 @@ Feature: Chat calendar entries | activity | name | intro | course | idnumber | schedule | | chat | Test chat name | Test chat description | C1 | chat1 | 0 | And I log in as "teacher1" - When I follow "Calendar" in the user menu + When I am viewing calendar in "upcoming" view Then I should not see "Test chat name" Scenario: Create a chat activity and publish the start date to the calendar