From 68db5be0e9be280b4070aa272af08085bd7f5705 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Tue, 19 Dec 2017 15:38:09 -0500 Subject: [PATCH] Behat: Add test to check access to sessions and rename session feature to sessionManagement - refs #2035 --- .../features/bootstrap/FeatureContext.php | 8 ++ tests/behat/features/sessionAccess.feature | 75 +++++++++++++++++++ ...sion.feature => sessionManagement.feature} | 2 +- 3 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 tests/behat/features/sessionAccess.feature rename tests/behat/features/{session.feature => sessionManagement.feature} (99%) diff --git a/tests/behat/features/bootstrap/FeatureContext.php b/tests/behat/features/bootstrap/FeatureContext.php index a1623e2986..0659af0e68 100644 --- a/tests/behat/features/bootstrap/FeatureContext.php +++ b/tests/behat/features/bootstrap/FeatureContext.php @@ -142,6 +142,14 @@ class FeatureContext extends MinkContext $this->assertElementNotOnPage('.alert-danger'); } + /** + * @Given /^I am on course "([^"]*)" homepage in session "([^"]*)"$/ + */ + public function iAmOnCourseXHomepageInSessionY($courseArgument, $sessionArgument) + { + $this->visit('/courses/'.$courseArgument.'/index.php?id_session='.$sessionArgument); + } + /** * @Given /^I am a "([^"]*)" user$/ */ diff --git a/tests/behat/features/sessionAccess.feature b/tests/behat/features/sessionAccess.feature new file mode 100644 index 0000000000..f4e3319ca8 --- /dev/null +++ b/tests/behat/features/sessionAccess.feature @@ -0,0 +1,75 @@ +Feature: Session access + In order to access a session + The teacher must be registered as a session coach for this course + + @javascript + Scenario: Create session 1 + Given I am a platform administrator + And I am on "/main/session/session_add.php" + When I fill in the following: + | name | Session1 | + And I fill in select2 input "#coach_username" with id "1" and value "admin" + And I press "submit" + Then I should see "Add courses to this session (Session1)" + Then I select "TEMP (TEMP)" from "NoSessionCoursesList[]" + And I press "add_course" + And I press "next" + Then I should see "Update successful" + Then I should see "Subscribe users to this session" + Then I press "Multiple registration" + Then I select "Warnier Yannick (ywarnier)" from "nosessionUsersList[]" + And I press "add_user" + And I press "next" + Then I should see "Session1" + Then I should see "TEMP" + Then I should see "ywarnier" + + @javascript + Scenario: Create session 2 + Given I am a platform administrator + And I am on "/main/session/session_add.php" + When I fill in the following: + | name | Session2 | + And I fill in select2 input "#coach_username" with id "1" and value "admin" + And I press "submit" + Then I should see "Add courses to this session (Session2)" + Then I select "TEMP (TEMP)" from "NoSessionCoursesList[]" + And I press "add_course" + And I press "next" + Then I should see "Update successful" + Then I should see "Subscribe users to this session" + Then I press "Multiple registration" + Then I select "Mosquera Michela (mmosquera)" from "nosessionUsersList[]" + And I press "add_user" + And I press "next" + Then I should see "Session2" + Then I should see "TEMP" + Then I should see "mmosquera" + + Scenario: Connect to session 2 + Given I am logged as "ywarnier" + And I am on course "TEMP" homepage in session "1" + Then I should not see "You are not allowed" + And I am on course "TEMP" homepage in session "2" + Then I should see "You are not allowed" + + Scenario: Connect to session 2 + Given I am logged as "mmosquera" + And I am on course "TEMP" homepage in session "2" + Then I should not see "You are not allowed" + And I am on course "TEMP" homepage in session "1" + Then I should see "You are not allowed" + + Scenario: Delete session "Session2" + Given I am on "/main/session/session_list.php?keyword=Session2" + And wait for the page to be loaded + And I follow "Delete" + And I confirm the popup + Then I should see "Deleted" + + Scenario: Delete session "Session1" + Given I am on "/main/session/session_list.php?keyword=Session1" + And wait for the page to be loaded + And I follow "Delete" + And I confirm the popup + Then I should see "Deleted" diff --git a/tests/behat/features/session.feature b/tests/behat/features/sessionManagement.feature similarity index 99% rename from tests/behat/features/session.feature rename to tests/behat/features/sessionManagement.feature index 64db8ae89d..81e4431528 100644 --- a/tests/behat/features/session.feature +++ b/tests/behat/features/sessionManagement.feature @@ -1,4 +1,4 @@ -Feature: Session tool +Feature: Session management tool In order to use the session tool The admin should be able to create a session