MDL-83331 behat: enable navigation direct to mod/.../index.php

This commit is contained in:
Tim Hunt 2024-10-01 18:14:43 +01:00
parent d7e3bea9fa
commit b72b37c974
2 changed files with 14 additions and 1 deletions

View File

@ -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]);
}
}

View File

@ -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 |