From 94611e82ec5c304eb1a565e0cb75c63bff9daf69 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 b90af3cc75aff..1269400f752b3 100644 --- a/lib/tests/behat/behat_navigation.php +++ b/lib/tests/behat/behat_navigation.php @@ -937,10 +937,12 @@ protected function resolve_core_page_instance_url(string $type, string $identifi ]); } + // 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) { @@ -962,6 +964,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 203e056e7ad99..a62745e7b8dc0 100644 --- a/mod/forum/tests/behat/add_forum.feature +++ b/mod/forum/tests/behat/add_forum.feature @@ -42,6 +42,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" + Scenario: Test forum settings validation Given the following "courses" exist: | fullname | shortname | category |