From 2e994893f6df8d799534e91336de6686e22208aa Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Tue, 1 Oct 2024 18:14:43 +0100 Subject: [PATCH] MDL-83331 behat: enable navigation direct to mod/.../index.php --- lib/tests/behat/behat_navigation.php | 11 ++++++++++- mod/forum/tests/behat/add_forum.feature | 4 ++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/tests/behat/behat_navigation.php b/lib/tests/behat/behat_navigation.php index fea39c60279b8..2b17a179ee069 100644 --- a/lib/tests/behat/behat_navigation.php +++ b/lib/tests/behat/behat_navigation.php @@ -887,10 +887,12 @@ protected function resolve_core_page_instance_url(string $type, string $identifi return new moodle_url('/enrol/otherusers.php', ['id' => $courseid]); } + // This next section handles page types starting with an activity name. For example: + // "forum activity" or "quiz activity editing". $parts = explode(' ', $type); if (count($parts) > 1) { + $modname = $parts[0]; if ($parts[1] === 'activity') { - $modname = $parts[0]; $cm = $this->get_cm_by_activity_name($modname, $identifier); if (count($parts) == 2) { @@ -912,6 +914,13 @@ protected function resolve_core_page_instance_url(string $type, string $identifi // Permissions page. return new moodle_url('/admin/roles/permissions.php', ['contextid' => $cm->context->id]); } + + } else if ($parts[1] === 'index' && count($parts) == 2) { + $courseid = $this->get_course_id($identifier); + if (!$courseid) { + throw $coursenotfoundexception; + } + return new moodle_url("/mod/$modname/index.php", ['id' => $courseid]); } } diff --git a/mod/forum/tests/behat/add_forum.feature b/mod/forum/tests/behat/add_forum.feature index e88dd30c7e3eb..36b1158e34015 100644 --- a/mod/forum/tests/behat/add_forum.feature +++ b/mod/forum/tests/behat/add_forum.feature @@ -43,6 +43,10 @@ Feature: Add forum activities and discussions And I follow "Edit" And the field "Attachment" matches value "empty.txt" + # Check the page that lists all the forums in a course. + And I am on the "C1" "forum index" page + And I should see "Test forum name" + @javascript Scenario: Test forum settings validation Given the following "courses" exist: