From 81b0bbe8cb2e421ff4e4b2d65ec5600bb5f8d3db Mon Sep 17 00:00:00 2001 From: Ferran Recio Date: Thu, 13 Jan 2022 14:09:06 +0100 Subject: [PATCH] MDL-73340 behat: add mobile and table size --- .../tests/behat/course_courseindex.feature | 21 +++++++++++++++++++ lib/behat/classes/behat_session_trait.php | 14 +++++++++++-- lib/tests/behat/behat_general.php | 16 ++++++++++---- 3 files changed, 45 insertions(+), 6 deletions(-) diff --git a/course/format/tests/behat/course_courseindex.feature b/course/format/tests/behat/course_courseindex.feature index 7349e8b1c95..4dda2f929e5 100644 --- a/course/format/tests/behat/course_courseindex.feature +++ b/course/format/tests/behat/course_courseindex.feature @@ -247,3 +247,24 @@ Feature: Course index depending on role And I should not see "Activity sample 3" in the "region-main" "region" And I click on "Activity sample 3" "link" in the "courseindex-content" "region" Then I should see "Activity sample 3" in the "region-main" "region" + + @javascript + Scenario Outline: Course index is displayed by default depending on the screen size. + When I change window size to "" + And I am on the "C1" "Course" page logged in as "student1" + Then "courseindex-content" "region" should visible + And I reload the page + And "courseindex-content" "region" should visible + # Check whenever preferences are saved. + And I click on " course index" "button" + And I reload the page + And "courseindex-content" "region" should visible + And I click on " course index" "button" + And I reload the page + And "courseindex-content" "region" should visible + + Examples: + | device | bydefault | action1 | visible1 | action2 | visible2 | + | large | be | Close | not be | Open | be | + | tablet | not be | Open | not be | Open | not be | + | mobile | not be | Open | not be | Open | not be | diff --git a/lib/behat/classes/behat_session_trait.php b/lib/behat/classes/behat_session_trait.php index 09f9fb6ac5b..4819dae5ed3 100644 --- a/lib/behat/classes/behat_session_trait.php +++ b/lib/behat/classes/behat_session_trait.php @@ -739,8 +739,10 @@ trait behat_session_trait { /** * Change browser window size. - * - small: 640x480 - * - medium: 1024x768 + * - mobile: 425x750 + * - tablet: 768x1024 + * - small: 1024x768 + * - medium: 1366x768 * - large: 2560x1600 * * @param string $windowsize size of window. @@ -756,6 +758,14 @@ trait behat_session_trait { } switch ($windowsize) { + case "mobile": + $width = 425; + $height = 750; + break; + case "tablet": + $width = 768; + $height = 1024; + break; case "small": $width = 1024; $height = 768; diff --git a/lib/tests/behat/behat_general.php b/lib/tests/behat/behat_general.php index 42b74cec455..431fa6b2dd2 100644 --- a/lib/tests/behat/behat_general.php +++ b/lib/tests/behat/behat_general.php @@ -1250,16 +1250,24 @@ EOF; } /** - * Change browser window size small: 640x480, medium: 1024x768, large: 2560x1600, custom: widthxheight + * Change browser window size + * + * Allowed sizes: + * - mobile: 425x750 + * - tablet: 768x1024 + * - small: 1024x768 + * - medium: 1366x768 + * - large: 2560x1600 + * - custom: widthxheight * * Example: I change window size to "small" or I change window size to "1024x768" * or I change viewport size to "800x600". The viewport option is useful to guarantee that the * browser window has same viewport size even when you run Behat on multiple operating systems. * * @throws ExpectationException - * @Then /^I change (window|viewport) size to "(small|medium|large|\d+x\d+)"$/ - * @Then /^I change the (window|viewport) size to "(small|medium|large|\d+x\d+)"$/ - * @param string $windowsize size of the window (small|medium|large|wxh). + * @Then /^I change (window|viewport) size to "(mobile|tablet|small|medium|large|\d+x\d+)"$/ + * @Then /^I change the (window|viewport) size to "(mobile|tablet|small|medium|large|\d+x\d+)"$/ + * @param string $windowsize size of the window (mobile|tablet|small|medium|large|wxh). */ public function i_change_window_size_to($windowviewport, $windowsize) { $this->resize_window($windowsize, $windowviewport === 'viewport');