first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-09-30 18:11:26 -04:00
commit e592ca6823
27270 changed files with 5002257 additions and 0 deletions
+268
View File
@@ -0,0 +1,268 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Behat calendar-related steps definitions.
*
* @package core_calendar
* @category test
* @copyright 2013 Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// NOTE: no MOODLE_INTERNAL used, this file may be required by behat before including /config.php.
require_once(__DIR__ . '/../../../lib/behat/behat_base.php');
use Behat\Gherkin\Node\TableNode as TableNode;
/**
* Contains functions used by behat to test functionality.
*
* @package core_calendar
* @category test
* @copyright 2013 Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class behat_calendar extends behat_base {
/**
* Return the list of partial named selectors.
*
* @return array
*/
public static function get_partial_named_selectors(): array {
return [
new behat_component_named_selector('mini calendar block', [".//*[@data-block='calendar_month']"]),
new behat_component_named_selector('full calendar page', [".//*[@id='page-calendar-view']"]),
new behat_component_named_selector('calendar day', [".//*[@data-region='day'][@data-day=%locator%]"]),
new behat_component_named_selector(
'calendar day detail',
[".//*[@data-region='day'][@data-day=%locator%]//a[@data-action='view-day-link']"]
),
new behat_component_named_selector(
'responsive calendar day',
[".//*[@data-region='day'][@data-day=%locator%]/div[contains(@class, 'hidden-desktop')]"]
),
new behat_component_named_selector(
'responsive calendar day detail',
[".//*[@data-region='day'][@data-day=%locator%]" .
"/div[contains(@class, 'hidden-desktop')]//a[@data-action='view-day-link']"]
),
];
}
/**
* Create event when starting on the front page.
*
* @Given /^I create a calendar event with form data:$/
* @param TableNode $data
*/
public function i_create_a_calendar_event_with_form_data($data) {
// Go to current month page.
$this->execute("behat_general::click_link", get_string('fullcalendar', 'calendar'));
// Create event.
$this->i_create_a_calendar_event($data);
}
/**
* Create event.
*
* @Given /^I create a calendar event:$/
* @param TableNode $data
*/
public function i_create_a_calendar_event($data) {
// Get the event name.
$eventname = $data->getRow(1);
$eventname = $eventname[1];
$this->execute("behat_general::wait_until_the_page_is_ready");
if ($this->running_javascript()) {
// Click to create new event.
$this->execute("behat_general::i_click_on", array(get_string('newevent', 'calendar'), "button"));
// Set form fields.
$this->execute("behat_forms::i_set_the_following_fields_to_these_values", $data);
// Save event.
$this->execute("behat_forms::press_button", get_string('save'));
}
}
/**
* Hover over a specific day in the mini-calendar.
*
* @Given /^I hover over day "(?P<dayofmonth>\d+)" of this month in the mini-calendar block(?P<responsive> responsive view|)$/
* @param int $day The day of the current month
* @param string $responsive If not null, find the responsive version of the link.
*/
public function i_hover_over_day_of_this_month_in_mini_calendar_block(int $day, string $responsive = ''): void {
$this->execute(
"behat_general::i_hover_in_the",
[
$day,
empty($responsive) ? 'core_calendar > calendar day' : 'core_calendar > responsive calendar day',
'',
'core_calendar > mini calendar block',
],
);
}
/**
* Hover over a specific day in the full calendar page.
*
* @Given /^I hover over day "(?P<dayofmonth>\d+)" of this month in the full calendar page(?P<responsive> responsive view|)$/
* @param int $day The day of the current month
* @param string $responsive If not empty, use the repsonsive view.
*/
public function i_hover_over_day_of_this_month_in_full_calendar_page(int $day, string $responsive = ''): void {
$this->execute(
"behat_general::i_hover_in_the",
[
$day,
empty($responsive) ? 'core_calendar > calendar day' : 'core_calendar > responsive calendar day',
'',
'core_calendar > full calendar page',
],
);
}
/**
* Click on a specific day in the mini-calendar.
*
* @Given /^I click on day "(?P<dayofmonth>\d+)" of this month in the mini-calendar block(?P<responsive> responsive view|)$/
*
* @param int $day The day of the current month.
* @param string $responsive If not null, find the responsive version of the link.
* @param string $detail If not null, find the detail version of the link.
*/
public function i_click_on_day_of_this_month_in_mini_calendar_block(
int $day,
string $responsive = '',
string $detail = '',
): void {
$selectortype = 'core_calendar >';
if (!empty($responsive)) {
$selectortype .= ' responsive';
}
$selectortype .= ' calendar day';
if (!empty($detail)) {
$selectortype .= ' detail';
}
$this->execute(
contextapi: "behat_general::i_click_on_in_the",
params: [
$day,
$selectortype,
'',
'core_calendar > mini calendar block',
],
);
}
/**
* Hover over today in the mini-calendar.
*
* @Given /^I hover over today in the mini-calendar block( responsive view|)$/
*
* @param string $responsive If not empty, use the responsive calendar link.
*/
public function i_hover_over_today_in_mini_calendar_block(string $responsive = ''): void {
$todaysday = date('j');
$this->i_hover_over_day_of_this_month_in_mini_calendar_block($todaysday, $responsive);
}
/**
* Click on today in the mini-calendar.
*
* @Given /^I click on today in the mini-calendar block( responsive view|)( to view the detail|)$/
*
* @param string $responsive If not empty, use the responsive calendar link.
* @param string $detail If not empty, use the detail view calendar link.
*/
public function i_click_on_today_in_mini_calendar_block(string $responsive = '', string $detail = ''): void {
$this->i_click_on_day_of_this_month_in_mini_calendar_block(
day: date('j'),
responsive: $responsive,
detail: $detail,
);
}
/**
* Navigate to a specific month in the calendar.
*
* @Given /^I view the calendar for "(?P<month>\d+)" "(?P<year>\d+)"$/
* @param int $month the month selected as a number
* @param int $year the four digit year
*/
public function i_view_the_calendar_for($month, $year) {
$this->view_the_calendar('month', 1, $month, $year);
}
/**
* Navigate to a specific date in the calendar.
*
* @Given /^I view the calendar for "(?P<day>\d+)" "(?P<month>\d+)" "(?P<year>\d+)"$/
* @param int $day the day selected as a number
* @param int $month the month selected as a number
* @param int $year the four digit year
*/
public function i_view_the_calendar_day_view(int $day, int $month, int $year) {
$this->view_the_calendar('day', $day, $month, $year);
}
/**
* View the correct calendar view with specific day
*
* @param string $type type of calendar view: month or day
* @param int $day the day selected as a number
* @param int $month the month selected as a number
* @param int $year the four digit year
*/
private function view_the_calendar(string $type, int $day, int $month, int $year) {
$time = make_timestamp($year, $month, $day);
$this->execute('behat_general::i_visit', ['/calendar/view.php?view=' . $type . '&course=1&time=' . $time]);
}
/**
* Navigate to site calendar.
*
* @Given /^I am viewing site calendar$/
* @throws coding_exception
* @return void
*/
public function i_am_viewing_site_calendar() {
$this->i_am_viewing_calendar_in_view('month');
}
/**
* 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]);
}
}
@@ -0,0 +1,59 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php.
require_once(__DIR__ . '/../../../lib/behat/behat_deprecated_base.php');
/**
* Steps definitions that are now deprecated and will be removed in the next releases.
*
* This file only contains the steps that previously were in the behat_*.php files in the SAME DIRECTORY.
* When deprecating steps from other components or plugins, create a behat_COMPONENT_deprecated.php
* file in the same directory where the steps were defined.
*
* @package core_calendar
* @category test
* @copyright 2024 Mathew May <mathew.solutions>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class behat_calendar_deprecated extends behat_deprecated_base {
/**
* Hover over today in the calendar.
*
* @Given /^I hover over today in the calendar$/
*
* @deprecated since 4.4 MDL-73117.
* @TODO MDL-79721: This will be deleted in Moodle 4.8.
*/
public function i_hover_over_today_in_the_calendar() {
$this->deprecated_message('behat_calendar::i_hover_over_today_in_the_calendar');
$todaysday = date('j');
$summarytitle = userdate(time(), get_string('strftimemonthyear'));
// The current month table.
$currentmonth = "table[descendant::*[self::caption[contains(concat(' ', normalize-space(.), ' '), ' {$summarytitle} ')]]]";
// Strings for the class cell match.
$cellclasses = "contains(concat(' ', normalize-space(@class), ' '), ' day ')";
$daycontains = "text()[contains(concat(' ', normalize-space(.), ' '), ' {$todaysday} ')]";
$daycell = "td[{$cellclasses}]";
$dayofmonth = "a[{$daycontains}]";
$xpath = '//' . $currentmonth . '/descendant::' . $daycell . '/' . $dayofmonth;
$this->execute("behat_general::i_hover", [$xpath, "xpath_element"]);
}
}
+456
View File
@@ -0,0 +1,456 @@
@core @core_calendar
Feature: Perform basic calendar functionality
In order to ensure the calendar works as expected
As an admin
I need to create calendar data
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| student1 | Student | 1 | student1@example.com |
| student2 | Student | 2 | student2@example.com |
| student3 | Student | 3 | student3@example.com |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "categories" exist:
| name | category | idnumber |
| CatA | 0 | cata |
And the following "courses" exist:
| fullname | shortname | format | category |
| Course 1 | C1 | topics | cata |
| Course 2 | C2 | topics | cata |
| Course 3 | C3 | topics | cata |
| Course 4 | C4 | topics | cata |
And the following "course enrolments" exist:
| user | course | role |
| student1 | C1 | student |
| student3 | C1 | student |
| teacher1 | C1 | teacher |
| admin | C1 | editingteacher |
And the following "groups" exist:
| name | course | idnumber |
| Group 1 | C1 | G1 |
And the following "group members" exist:
| user | group |
| student1 | G1 |
| teacher1 | G1 |
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| calendar_month | Course | C1 | course-view-* | side-pre |
| calendar_upcoming | Course | C4 | course-view-* | side-pre |
@javascript
Scenario: Create a site event
Given I log in as "admin"
And I create a calendar event with form data:
| Type of event | site |
| Event title | Really awesome event! |
| Description | Come join this awesome event, sucka! |
And I log out
When I am on the "Course 1" course page logged in as student1
And I follow "Course calendar"
And I should see "Really awesome event!"
And I log out
And I log in as "student2"
And I follow "Full calendar"
Then I should see "Really awesome event!"
@javascript
Scenario: Create a course event
Given I log in as "teacher1"
And I create a calendar event with form data:
| Type of event | course |
| Course | Course 1 |
| Event title | Really awesome event! |
| Description | Come join this awesome event, sucka! |
And I log out
When I am on the "Course 1" course page logged in as student1
And I follow "Course calendar"
And I click on "Really awesome event!" "link"
And "Course 1" "link" should exist in the "Really awesome event!" "dialogue"
And I click on "Close" "button" in the "Really awesome event!" "dialogue"
And I log out
And I log in as "student2"
And I follow "Full calendar"
Then I should not see "Really awesome event!"
@javascript
Scenario: Create a group event
Given I log in as "teacher1"
And I follow "Full calendar"
And I set the field "course" to "C1"
And I create a calendar event:
| Type of event | group |
| Group | Group 1 |
| Event title | Really awesome event! |
| Description | Come join this awesome event |
And I log out
When I am on the "Course 1" course page logged in as student1
And I follow "Course calendar"
Then I follow "Really awesome event!"
@javascript
Scenario: Create a user event
Given I log in as "teacher1"
And I create a calendar event with form data:
| Type of event | user |
| Event title | Really awesome event! |
| Description | Come join this awesome event, sucka! |
And I log out
When I am on the "Course 1" course page logged in as student1
And I follow "Course calendar"
Then I should not see "Really awesome event!"
@javascript
Scenario: Create an event containing URL as location
Given I log in as "admin"
And I create a calendar event with form data:
| Type of event | site |
| Event title | Important webinar |
| Location | https://moodle.org |
When I click on "Important webinar" "link"
Then "https://moodle.org" "link" should exist in the "Important webinar" "dialogue"
@javascript
Scenario: Delete an event
Given I log in as "teacher1"
And I create a calendar event with form data:
| Type of event | user |
| Event title | Really awesome event! |
| Description | Come join this awesome event, sucka! |
And I am on "Course 1" course homepage
When I follow "Course calendar"
And I click on "Really awesome event!" "link"
And I click on "Delete" "button" in the "Really awesome event!" "dialogue"
And I click on "Delete event" "button"
And I wait to be redirected
Then I should not see "Really awesome event!"
@javascript
Scenario: Edit an event
Given I log in as "teacher1"
And I create a calendar event with form data:
| Type of event | user |
| Event title | Really awesome event! |
| Description | Come join this awesome event, sucka! |
| Location | Cube office |
And I am on "Course 1" course homepage
When I follow "Course calendar"
And I click on "Really awesome event!" "link"
And ".location-content" "css_element" should exist
And I should see "Cube office"
And I click on "Edit" "button"
And I set the following fields to these values:
| Event title | Mediocre event :( |
| Description | Wait, this event isn't that great. |
| Location | |
And I press "Save"
And I should see "Mediocre event"
And I click on "Mediocre event :(" "link"
Then I should see "Mediocre event"
And ".location-content" "css_element" should not exist
@javascript @editor_tiny
Scenario: Edit a newly created event using TinyMCE editor
Given I log in as "teacher1"
And I follow "Dashboard"
And I click on "New event" "button"
And I set the field "Event title" to "Newly created event"
When I press "Save"
Then I should see "Newly created event"
And I click on "Newly created event" "link"
And I click on "Edit" "button" in the "Newly created event" "dialogue"
And I click on "Show more..." "link"
And I click on the "Link" button for the "Description" TinyMCE editor
And I set the field "Text to display" to "Read more..."
And I set the field "Enter a URL" to "https://moodle.org/"
And I click on "Create link" "button" in the "Create link" "dialogue"
And I press "Save"
And I click on "Newly created event" "link"
And I should see "Read more..."
@javascript
Scenario: Module events editing
Given I log in as "teacher1"
And I am on "Course 1" course homepage
And the following "activities" exist:
| activity | course | idnumber | name | intro | timeopen | timeclose |
| choice | C1 | choice1 | Test choice | Test choice description | ##today## | ##today## |
When I follow "Course calendar"
Then I should see "Test choice opens"
And I should see "Test choice closes"
When I click on "Test choice opens" "link"
Then "Delete" "button" should not exist in the "Test choice opens" "dialogue"
And "Edit" "button" should not exist in the "Test choice opens" "dialogue"
And I should see "Course event"
When I click on "Go to activity" "link"
And I wait to be redirected
Then I should see "Test choice"
And I am on "Course 1" course homepage
And I follow "Course calendar"
When I click on "Test choice closes" "link"
Then "Delete" "button" should not exist in the "Test choice closes" "dialogue"
And "Edit" "button" should not exist in the "Test choice closes" "dialogue"
And I should see "Course event"
When I click on "Go to activity" "link"
And I wait to be redirected
Then I should see "Test choice"
@javascript
Scenario: Attempt to create event without fill required fields should display validation errors
Given I am on the "Course 1" course page logged in as teacher1
And I follow "Course calendar"
And I click on "New event" "button"
When I click on "Save" "button"
Then I should see "Required" in the "Event title" "form_row"
And I am on homepage
And I follow "Full calendar"
And I click on "New event" "button"
And I set the field "Event title" to "Really awesome event!"
And I set the field "Type of event" to "Course"
And I click on "Save" "button"
And I should see "Select a course" in the "Course" "form_row"
@javascript
Scenario: Default event type selection in the event form
Given I log in as "teacher1"
When I am viewing site calendar
And I click on "New event" "button"
Then the field "Type of event" matches value "User"
And I click on "Close" "button" in the "New event" "dialogue"
And I set the field "course" to "C1"
When I click on "New event" "button"
Then the field "Type of event" matches value "Course"
@javascript
Scenario: Admin can only see all courses if calendar_adminseesall setting is enabled.
Given I am on the "Course 1" course page logged in as admin
And I am viewing site calendar
And I click on "New event" "button"
And I set the field "Type of event" to "Course"
When I expand the "Course" autocomplete
Then "Course 1" "autocomplete_suggestions" should exist
And "Course 2" "autocomplete_suggestions" should not exist
And "Course 3" "autocomplete_suggestions" should not exist
And I click on "Close" "button" in the "New event" "dialogue"
And I am on site homepage
And I navigate to "Appearance > Calendar" in site administration
And I set the field "Admins see all" to "1"
And I press "Save changes"
And I am viewing site calendar
And I click on "New event" "button"
And I set the field "Type of event" to "Course"
When I expand the "Course" autocomplete
Then "Course 1" "autocomplete_suggestions" should exist
And "Course 2" "autocomplete_suggestions" should exist
And "Course 3" "autocomplete_suggestions" should exist
@javascript
Scenario: Students can not see event type field by default.
Given I log in as "student1"
And I am viewing site calendar
When I click on "New event" "button"
# Only "user" event type is available, so "Type of event" field should not be displayed.
Then "Type of event" "select" should not exist
@javascript
Scenario: "Student 2" has "manageentries" capability assigned but it's not enrolled in any course.
Given the following "permission overrides" exist:
| capability | permission | role | contextlevel | reference |
| moodle/calendar:manageentries | Allow | student | System | |
And I log in as "student2"
And I am viewing site calendar
When I click on "New event" "button"
# Only "user" event type is available, so "Type of event" field should not be displayed.
Then "Type of event" "select" should not exist
@javascript
Scenario: "Student 1" has "manageentries" capability assigned and it's enrolled in a course.
Given the following "permission overrides" exist:
| capability | permission | role | contextlevel | reference |
| moodle/calendar:manageentries | Allow | student | System | |
And I log in as "student1"
And I am viewing site calendar
When I click on "New event" "button"
# Student 1 is enrolled in a course and have the capability assigned.
# Then, the "Type of event" select box should be visible.
Then "Type of event" "select" should exist
And I should see "User" in the "Type of event" "select"
And I should see "Course" in the "Type of event" "select"
@javascript @accessibility
Scenario: The calendar page must be accessible
Given I am on the "Course 1" course page logged in as student1
When I follow "Course calendar"
Then the page should meet accessibility standards
And the page should meet "wcag131, wcag143, wcag412" accessibility standards
And the page should meet accessibility standards with "wcag131, wcag143, wcag412" extra tests
@javascript
Scenario: The calendar page should be responsive
Given I log in as "admin"
And I am viewing site calendar
And I create a calendar event:
| Type of event | site |
| Event title | Event 1:1 |
| timestart[day] | 1 |
When I change viewport size to "1200x1000"
Then I should see "Event 1:1"
And I change viewport size to "600x1000"
# We need to give the browser a couple seconds to re-render the page after the screen has been resized.
And I wait "1" seconds
And I should not see "Event 1:1"
And I hover over day "1" of this month in the full calendar page responsive view
And I should see "Event 1:1"
@javascript
Scenario: Admin can create and edit course events if calendar_adminseesall setting is disabled
Given I log in as "admin"
And the following config values are set as admin:
| calendar_adminseesall | 0 |
And I am on "Course 4" course homepage with editing mode on
And I click on "Go to calendar..." "link" in the "Upcoming events" "block"
And I click on "New event" "button"
And I should see "Course" in the "Type of event" "select"
And "Course 4" "autocomplete_selection" should exist
And I set the field "Event title" to "Test course event"
And I click on "Save" "button"
And I should see "Test course event"
When I click on "Edit" "link" in the "region-main" "region"
Then the field "Event title" matches value "Test course event"
And the field "Type of event" matches value "Course"
And "Course 4" "autocomplete_selection" should exist
@javascript
Scenario: Changing the event type should clear previous data
Given I am on the "Course 1" course page logged in as admin
And I follow "Course calendar"
And I press "New event"
And I set the following fields to these values:
| Event title | Group 1 event |
| Type of event | Group |
And I press "Save"
And I am on "Course 1" course homepage
And I follow "Course calendar"
And I click on "Group 1 event" "link"
And I should see "Group event"
And I should see "Group 1"
When I click on "Edit" "button" in the "Group 1 event" "dialogue"
And I set the following fields to these values:
| Event title | My own user event |
| Type of event | user |
And I press "Save"
And I click on "My own user event" "link"
Then I should see "User event"
And I should not see "Group 1"
And I click on "Edit" "button" in the "My own user event" "dialogue"
And I set the following fields to these values:
| Event title | Site event |
| Type of event | site |
And I press "Save"
And I click on "Site event" "link"
And I should see "Site event"
And I click on "Edit" "button" in the "Site event" "dialogue"
And I set the following fields to these values:
| Event title | Course 1 event |
| Type of event | course |
And I expand the "Course" autocomplete
And I click on "Course 1" item in the autocomplete list
And I press "Save"
And I click on "Course 1 event" "link"
And I should see "Course event"
And I click on "Edit" "button" in the "Course 1 event" "dialogue"
And I set the following fields to these values:
| Event title | Category event |
| Type of event | category |
| Category | CatA |
And I press "Save"
And I click on "Category event" "link"
And I should see "Category event"
@javascript
Scenario: Changing the event type from user to anything else should work
Given I log in as "teacher1"
# We need this so we can see the groups.
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And the following "role assigns" exist:
| user | role | contextlevel | reference |
| teacher1 | manager | Category | cata |
And I am on "Course 1" course homepage
And I follow "Course calendar"
And I press "New event"
And I set the following fields to these values:
| Event title | type change test event |
| Type of event | User |
And I press "Save"
And I am on "Course 1" course homepage
And I follow "Course calendar"
And I click on "type change test event" "link"
And I should see "User event"
When I click on "Edit" "button"
And I set the following fields to these values:
| Event title | type change test event |
| Type of event | Course |
And I expand the "Course" autocomplete
And I click on "Course 1" item in the autocomplete list
And I press "Save"
And I click on "type change test event" "link"
Then I should see "Course event"
# Reset to user event
And I click on "Edit" "button" in the "type change test event" "dialogue"
And I set the following fields to these values:
| Event title | type change test event |
| Type of event | User |
And I press "Save"
And I click on "type change test event" "link"
And I should see "User event"
# Now test changing from user to group event.
And I am on "Course 1" course homepage
And I follow "Course calendar"
And I click on "type change test event" "link"
And I click on "Edit" "button"
And I set the following fields to these values:
| Event title | type change test event |
| Type of event | Group |
And I click on "#fitem_id_groupcourseid .form-autocomplete-downarrow" "css_element"
And I click on "Course 1" item in the autocomplete list
And I set the following fields to these values:
| Group | Group 1 |
And I press "Save"
And I click on "type change test event" "link"
And I should see "Group event"
# Reset to user event
And I click on "Edit" "button" in the "type change test event" "dialogue"
And I set the following fields to these values:
| Event title | type change test event |
| Type of event | User |
And I press "Save"
And I click on "type change test event" "link"
And I should see "User event"
# Now test changing from user to course event.
And I click on "Edit" "button" in the "type change test event" "dialogue"
And I set the following fields to these values:
| Event title | Course 1 event |
| Type of event | Course |
And I expand the "Course" autocomplete
And I click on "Course 1" item in the autocomplete list
And I press "Save"
And I click on "Course 1 event" "link"
And I should see "Course event"
# Reset to user event
And I click on "Edit" "button" in the "Course 1 event" "dialogue"
And I set the following fields to these values:
| Event title | type change test event |
| Type of event | User |
And I press "Save"
And I click on "type change test event" "link"
And I should see "User event"
# Now test changing from user to category event.
And I click on "Edit" "button" in the "type change test event" "dialogue"
And I set the following fields to these values:
| Event title | type change test event |
| Type of event | Category |
And I press "Save"
And I click on "type change test event" "link"
And I should see "Category event"
@@ -0,0 +1,104 @@
@core @core_calendar @_file_upload @javascript
Feature: Import and edit calendar events
In order to manipulate imported calendar events
As an user
I need to import calendar events then edit them.
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | teacher | 1 | teacher1@example.com |
And the following "courses" exist:
| fullname | shortname | format |
| Course 1 | C1 | topics |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
Scenario: Import then edit a calendar event.
Given I log in as "teacher1"
And I view the calendar for "1" "2016"
And I click on "Import or export calendars" "link"
And "Calendar" "link" should exist in the ".breadcrumb" "css_element"
And "Import or export calendars" "text" should exist in the ".breadcrumb" "css_element"
And I press "Import calendar"
And "Calendar" "link" should exist in the ".breadcrumb" "css_element"
And "Import or export calendars" "link" should exist in the ".breadcrumb" "css_element"
And "Import calendar" "text" should exist in the ".breadcrumb" "css_element"
And I set the following fields to these values:
| Calendar name | Test Import |
| Import from | Calendar file (.ics) |
| Type of event | User |
And I upload "calendar/tests/fixtures/import.ics" file to "Calendar file (.ics)" filemanager
And I press "Import calendar"
And I should see "2 events were imported"
And I view the calendar for "2" "2017"
And I should see "February 2017"
And I should see "Event on 2-15-2017"
And I should see "Event on 2-25-2017"
And I click on "Event on 2-15-2017" "link"
And I should see "Some place"
And I click on "Edit" "button"
And I set the following fields to these values:
| Event title | Event on 2-20-2017 |
| Description | Event on 2-20-2017 |
| timestart[day] | 20 |
And I press "Save"
When I view the calendar for "2" "2017"
Then I should see "Event on 2-20-2017"
And I should see "Event on 2-25-2017"
And I should not see "Event on 2-15-2017"
And I click on "Import or export calendars" "link"
And I click on "Delete" "link"
And I should see "Are you sure you want to delete the \"Test Import\" calendar subscription?" in the ".modal .modal-body" "css_element"
And I click on "Yes" "button" in the ".modal.show" "css_element"
And I view the calendar for "2" "2017"
And I should not see "Event on 2-25-2017"
And I should not see "Event on 2-20-2017"
Scenario: Import events using different event types.
Given I log in as "admin"
And I view the calendar for "1" "2016"
And I click on "Import or export calendars" "link"
And I press "Import calendar"
And I set the following fields to these values:
| Calendar name | Test Import |
| Import from | Calendar file (.ics) |
| Type of event | User |
And I upload "calendar/tests/fixtures/import.ics" file to "Calendar file (.ics)" filemanager
And I press "Import calendar"
And I should see "User events"
And I press "Import calendar"
And I set the following fields to these values:
| Calendar name | Test Import |
| Import from | Calendar file (.ics) |
| Type of event | Category |
| Category | Category 1 |
And I upload "calendar/tests/fixtures/import.ics" file to "Calendar file (.ics)" filemanager
And I press "Import calendar"
And I should see "Category events"
And I press "Import calendar"
And I set the following fields to these values:
| Calendar name | Test Import |
| Import from | Calendar file (.ics) |
| Type of event | Site |
And I upload "calendar/tests/fixtures/import.ics" file to "Calendar file (.ics)" filemanager
And I press "Import calendar"
And I should see "Site events"
Scenario: Import iCalendar file with parameter.
Given I log in as "admin"
And I view the calendar for "7" "2022"
And I click on "Import or export calendars" "link"
And I press "Import calendar"
And I set the following fields to these values:
| Calendar name | Test Import |
| Import from | Calendar file (.ics) |
| Type of event | User |
And I upload "calendar/tests/fixtures/import_with_parameters.ics" file to "Calendar file (.ics)" filemanager
And I press "Import calendar"
When I view the calendar for "1" "7" "2022"
Then I should see "First event"
And I should see "Description of the first event"
And I should see "Second event"
And I should see "Description of the second event"
@@ -0,0 +1,42 @@
@core @core_calendar @javascript
Feature: Limit displayed upcoming events
In order to filter what is displayed on the calendar
As a user
I need to interact with the calendar
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | teacher | 1 | teacher1@example.com |
And the following "courses" exist:
| fullname | shortname | format |
| Course 1 | C1 | topics |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| calendar_month | Course | C1 | course-view-* | side-pre |
| calendar_upcoming | Course | C1 | course-view-* | side-pre |
And I log in as "teacher1"
Scenario: I view calendar details for a future event
Given I am on "Course 1" course homepage with editing mode on
And I follow "Course calendar"
And I click on "a.next" "css_element"
And I click on "a.next" "css_element"
When I create a calendar event:
| Type of event | course |
| Course | Course 1 |
| Event title | Two months away event |
And I am on "Course 1" course homepage
Then I should not see "Two months away event"
And I am on site homepage
And I follow "Preferences" in the user menu
And I follow "Calendar preferences"
When I set the following fields to these values:
| Upcoming events look-ahead | 3 months |
And I press "Save changes"
And I wait to be redirected
And I am on "Course 1" course homepage
Then I should see "Two months away event"
@@ -0,0 +1,27 @@
@core @core_calendar
Feature: Verify that the day and month names are displayed using UTF-8
In order to be able to use the calendar using different languages
As a user
I need to see the day and month names displayed properly
Background:
Given remote langimport tests are enabled
Scenario Outline: View the calendar for December 2012 with correct UTF-8
Given the following "language pack" exists:
| language | <lang> |
And I log in as "admin"
And I follow "Preferences" in the user menu
And I follow "Preferred language"
And I set the field "Preferred language" to "<lang>"
And I press "Save changes"
When I view the calendar for "12" "2022"
Then I should see "<month>"
And I should see "<day>"
Examples:
| lang | month | day |
| en_ar | December | Sat |
| es | diciembre | Sáb |
| fr | décembre | Sa |
| ru | декабря | Сб |
@@ -0,0 +1,75 @@
@core @core_calendar @javascript
Feature: Perform calendar filter actions
In order to test the calendar filters with preselected options
As a user
I need to filter calendar events by certain criteria
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "categories" exist:
| name | idnumber | category |
| Year | year | |
| Department C1 | department-c1 | year |
And the following "courses" exist:
| fullname | shortname | format | category |
| Course 1 | C1 | topics | department-c1 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And the following "groups" exist:
| name | course | idnumber |
| Group 1 | C1 | G1 |
And the following "group members" exist:
| user | group |
| teacher1 | G1 |
And the following "events" exist:
| name | eventtype |
| Site event | site |
And the following "events" exist:
| name | eventtype | course |
| C1 event | course | C1 |
And the following "events" exist:
| name | eventtype | category |
| Dep1a event | category | department-c1 |
And the following "events" exist:
| name | eventtype | group | course |
| Group1 event | group | G1 | C1 |
Scenario: Teacher of a Course can see his events and filter them
Given I log in as "teacher1"
When I follow "Calendar" in the user menu
Then I should see "C1 event"
And I should see "Dep1a event"
And I should see "Group1 event"
And I click on "Hide category events" "link"
And I should see "C1 event"
And I should not see "Dep1a event"
And I should see "Group1 event"
And I click on "Hide course events" "link"
And I should not see "C1 event"
And I should not see "Dep1a event"
And I should see "Group1 event"
Scenario: Teacher of a Course can see only non filtered events from user preferences calendar_savedflt
Given I log in as "teacher1"
And the following "user preferences" exist:
| user | preference | value |
| teacher1 | calendar_persistflt | 1 |
| teacher1 | calendar_savedflt | 13 |
When I follow "Calendar" in the user menu
Then I should not see "C1 event"
And I should see "Dep1a event"
And I should not see "Group1 event"
Scenario: Teacher of a Course can see all events because session is used and not user preference calendar_savedflt
Given I log in as "teacher1"
And the following "user preferences" exist:
| user | preference | value |
| teacher1 | calendar_persistflt | 0 |
| teacher1 | calendar_savedflt | 13 |
When I follow "Calendar" in the user menu
Then I should see "C1 event"
And I should see "Dep1a event"
And I should see "Group1 event"
@@ -0,0 +1,100 @@
@core @core_calendar
Feature: Course Category Events
In order to inform multiple courses of shared events
As a manager
I need to create catgory events
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| managera | Manager | A | managera@example.com |
| managera1 | Manager | A1 | managera1@example.com |
| managera2 | Manager | A2 | managera2@example.com |
| teachera1i | Teacher | A1i | teachera1i@example.com |
| managerb | Manager | B | managerb@example.com |
| managerb1 | Manager | B1 | managerb1@example.com |
| managerb2 | Manager | B2 | managerb2@example.com |
| teacherb1i | Teacher | B1i | teacherb1i@example.com |
| student1 | Student | 1 | student1@example.com |
| student2 | Student | 2 | student2@example.com |
And the following "categories" exist:
| name | idnumber | category |
| Year | year | |
| Faculty A | faculty-a | year |
| Faculty B | faculty-b | year |
| Department A1 | department-a1 | faculty-a |
| Department A2 | department-a2 | faculty-a |
| Department B1 | department-b1 | faculty-b |
| Department B2 | department-b2 | faculty-b |
And the following "courses" exist:
| fullname | shortname | idnumber | format | category |
| Course A1i | A1i | A1i | topics | department-a1 |
| Course A2i | A2i | A2i | topics | department-a2 |
| Course B1i | B1i | B1i | topics | department-b1 |
| Course B2i | B2i | B2i | topics | department-b2 |
And the following "role assigns" exist:
| user | role | contextlevel | reference |
| managera | manager | Category | faculty-a |
| managera1 | manager | Category | department-a1 |
| managerb | manager | Category | faculty-b |
| managerb1 | manager | Category | department-b1 |
And the following "course enrolments" exist:
| user | course | role |
| teachera1i | A1i | editingteacher |
| teacherb1i | B1i | editingteacher |
| student1 | A1i | student |
| student1 | A2i | student |
| student2 | B1i | student |
| student2 | B2i | student |
And the following "events" exist:
| name | eventtype |
| Site event | site |
And the following "events" exist:
| name | eventtype | course |
| CA1i event | course | A1i |
| CA2i event | course | A2i |
| CB1i event | course | B1i |
| CB2i event | course | B2i |
And the following "events" exist:
| name | eventtype | category |
| FA event | category | faculty-a |
| DA1 event | category | department-a1 |
| DA2 event | category | department-a1 |
| FB event | category | faculty-b |
| DB1 event | category | department-b1 |
| DB2 event | category | department-b1 |
@javascript
Scenario: Manager of a Category can see all child and parent events in their category
Given I log in as "managera"
When I follow "Calendar" in the user menu
Then I should see "FA event"
And I should see "DA1 event"
And I should see "DA2 event"
And I should not see "FB event"
And I should not see "DB1 event"
And I should not see "DB2 event"
And I log out
Given I log in as "managerb"
And I follow "Calendar" in the user menu
Then I should see "FB event"
And I should see "DB1 event"
And I should see "DB2 event"
And I should not see "FA event"
And I should not see "DA1 event"
And I should not see "DA2 event"
@javascript
Scenario: Users enrolled in a course can see all child and parent events in their category
Given I log in as "student1"
When I follow "Calendar" in the user menu
Then I should see "FA event"
And I should see "DA1 event"
And I should see "DA2 event"
And I should see "CA1i event"
And I should see "CA2i event"
And I should not see "FB event"
And I should not see "DB1 event"
And I should not see "DB2 event"
And I should not see "CB1i event"
And I should not see "CB2i event"
+95
View File
@@ -0,0 +1,95 @@
@core @core_calendar
Feature: Export calendar events
In order to be able to use my calendar events outside of Moodle
As a user
I need to export calendar events in iCalendar format
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| student1 | Student | 1 | student1@example.com |
And the following "courses" exist:
| fullname | shortname | format |
| Course 1 | C1 | topics |
And the following "course enrolments" exist:
| user | course | role |
| student1 | C1 | student |
And I log in as "student1"
Scenario: Viewing calendar export options
Given I follow "Full calendar"
When I click on "Import or export calendars" "link"
And "Calendar" "link" should exist in the ".breadcrumb" "css_element"
And "Import or export calendars" "text" should exist in the ".breadcrumb" "css_element"
And I click on "Export calendar" "button"
And "Calendar" "link" should exist in the ".breadcrumb" "css_element"
And "Import or export calendars" "link" should exist in the ".breadcrumb" "css_element"
And "Export calendar" "text" should exist in the ".breadcrumb" "css_element"
Then I should see "All events"
And I should see "Events related to courses"
And I should see "Events related to groups"
And I should see "My personal events"
@javascript
Scenario: Export calendar in ics format
And I follow "Full calendar"
And I press "New event"
And I set the following fields to these values:
| Event title | My event |
| id_timestart_hour | 13 |
| id_timestart_minute | 00 |
And I press "Save"
When I click on "Import or export calendars" "link"
And I click on "Export calendar" "button"
And I set the field "All events" to "1"
And I set the field "Recent and next 60 days" to "1"
And I press "Export"
And I should see "SUMMARY:My event"
# We need to split the step in two because Bennu library use days with leading zero and moodle removes it.
And I should see "##today##DTSTART:%Y%m##"
And I should see "##today##%dT050000Z##"
Scenario: Generating calendar URL for all events
Given I follow "Full calendar"
And I click on "Import or export calendars" "link"
And I click on "Export calendar" "button"
And I set the field "All events" to "1"
And I set the field "Recent and next 60 days" to "1"
When I click on "Get calendar URL" "button"
Then the "value" attribute of "Calendar URL" "field" should contain "&preset_what=all&"
Scenario: Generating calendar URL for course events
Given I follow "Full calendar"
And I click on "Import or export calendars" "link"
And I click on "Export calendar" "button"
And I set the field "Events related to courses" to "1"
And I set the field "Recent and next 60 days" to "1"
When I click on "Get calendar URL" "button"
Then the "value" attribute of "Calendar URL" "field" should contain "&preset_what=courses&"
Scenario: Generating calendar URL for group events
Given I follow "Full calendar"
And I click on "Import or export calendars" "link"
And I click on "Export calendar" "button"
And I set the field "Events related to groups" to "1"
And I set the field "Recent and next 60 days" to "1"
When I click on "Get calendar URL" "button"
Then the "value" attribute of "Calendar URL" "field" should contain "&preset_what=groups&"
Scenario: Generating calendar URL for category events
Given I follow "Full calendar"
And I click on "Import or export calendars" "link"
And I click on "Export calendar" "button"
And I set the field "Events related to categories" to "1"
And I set the field "Recent and next 60 days" to "1"
When I click on "Get calendar URL" "button"
Then the "value" attribute of "Calendar URL" "field" should contain "&preset_what=categories&"
Scenario: Generating calendar URL for user events
Given I follow "Full calendar"
And I click on "Import or export calendars" "link"
And I click on "Export calendar" "button"
And I set the field "My personal events" to "1"
And I set the field "Recent and next 60 days" to "1"
When I click on "Get calendar URL" "button"
Then the "value" attribute of "Calendar URL" "field" should contain "&preset_what=user&"
+47
View File
@@ -0,0 +1,47 @@
@core @core_calendar
Feature: Open calendar popup
In order to view calendar information
As a user
I need to interact with the calendar
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| student1 | Student | 1 | student1@example.com |
And the following "courses" exist:
| fullname | shortname | format |
| Course 1 | C1 | topics |
And the following "course enrolments" exist:
| user | course | role |
| student1 | C1 | student |
And I log in as "admin"
@javascript
Scenario: I view calendar details of a day with multiple events
Given I follow "Full calendar"
And I create a calendar event:
| Type of event | site |
| Event title | Event 1:1 |
| timestart[day] | 1 |
And I create a calendar event:
| Type of event | site |
| Event title | Event 1:2 |
| timestart[day] | 1 |
When I reload the page
Then I should see "Event 1:1"
And I should see "Event 1:2"
And I am on homepage
When I hover over day "1" of this month in the mini-calendar block
And I should see "Event 1:1"
And I should see "Event 1:2"
@javascript
Scenario: I view calendar details for today
Given I follow "Full calendar"
When I create a calendar event:
| Type of event | site |
| Event title | Today's event |
Then I should see "Today's event"
And I am on homepage
And I hover over today in the mini-calendar block
And I should see "Today's event"