MDL-71500 calendar_threemonth: add behat step and coverage

This commit is contained in:
boygr49p
2021-07-16 14:46:51 +08:00
committed by Simey Lameze
parent 15e311a1fd
commit 897300cbbd
2 changed files with 42 additions and 2 deletions
+25 -2
View File
@@ -77,6 +77,30 @@ class behat_calendar extends behat_base {
}
}
/**
* Click a specific day in the calendar.
*
* @Given /^I click day "(?P<dayofmonth>\d+)" of this month in the calendar$/
* @param int $day The day of the current month
*/
public function i_click_day_of_this_month_in_calendar($day) {
$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(.), ' '), ' {$day} ')]";
$daycell = "td[{$cellclasses}]";
$dayofmonth = "a[{$daycontains}]";
$xpath = '//' . $currentmonth . '/descendant::' . $daycell . '/' . $dayofmonth;
$this->execute("behat_general::wait_until_the_page_is_ready");
$this->execute("behat_general::i_click_on", array($xpath, "xpath_element"));
$this->execute("behat_general::wait_until_the_page_is_ready");
}
/**
* Hover over a specific day in the calendar.
*
@@ -96,8 +120,7 @@ class behat_calendar extends behat_base {
$xpath = '//' . $currentmonth . '/descendant::' . $daycell . '/' . $dayofmonth;
$this->execute("behat_general::wait_until_the_page_is_ready");
$this->execute("behat_general::i_hover", array($xpath, "xpath_element"));
$this->execute("behat_general::i_hover", [$xpath, "xpath_element"]);
}
/**
+17
View File
@@ -36,6 +36,23 @@ Feature: Open calendar popup
And I should see "Event 1:1"
And I should see "Event 1:2"
@javascript
Scenario: I view a day event then another day event
Given I follow "This month"
And I create a calendar event:
| Type of event | site |
| Event title | Event 3:1 |
| timestart[day] | 3 |
And I create a calendar event:
| Type of event | site |
| Event title | Event 4:1 |
| timestart[day] | 4 |
And I reload the page
When I click day "3" of this month in the calendar
Then I should see "Event 3:1" in the ".eventlist" "css_element"
And I click day "4" of this month in the calendar
And I should see "Event 4:1" in the ".eventlist" "css_element"
@javascript
Scenario: I view calendar details for today
Given I follow "This month"