From b72b37c9747f91c0524b6ca2a1dceb898258d55a 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 f82d48e4468..915522b9d1f 100644 --- a/lib/tests/behat/behat_navigation.php +++ b/lib/tests/behat/behat_navigation.php @@ -937,10 +937,12 @@ class behat_navigation extends behat_base { ]); } + // 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 @@ class behat_navigation extends behat_base { // 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 203e056e7ad..a62745e7b8d 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 |