From bc1335635a5254f71eca1ef792bf69a85aacfb32 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Fri, 7 Sep 2018 12:31:59 +0200 Subject: [PATCH] Remove "I am a student subscribed to session" shortcut - Use behat instructions to create a session on the fly for a test - Add message after adding users to a session Refs: https://github.com/chamilo/chamilo-lms/commit/407536472f49e450c8e9c12db1ddb87512d629c6 --- main/session/add_users_to_session.php | 1 + .../features/bootstrap/FeatureContext.php | 24 ------ tests/behat/features/toolExercise.feature | 80 ++++++++++++------- 3 files changed, 51 insertions(+), 54 deletions(-) diff --git a/main/session/add_users_to_session.php b/main/session/add_users_to_session.php index c00cb53a56..f230d13a33 100644 --- a/main/session/add_users_to_session.php +++ b/main/session/add_users_to_session.php @@ -336,6 +336,7 @@ if (isset($_POST['form_sent']) && $_POST['form_sent']) { null, !$notEmptyList ); + Display::addFlash(Display::return_message(get_lang('Updated'))); header('Location: resume_session.php?id_session='.$id_session); exit; } diff --git a/tests/behat/features/bootstrap/FeatureContext.php b/tests/behat/features/bootstrap/FeatureContext.php index 4e0fa9cd5c..f891fb5788 100644 --- a/tests/behat/features/bootstrap/FeatureContext.php +++ b/tests/behat/features/bootstrap/FeatureContext.php @@ -473,30 +473,6 @@ class FeatureContext extends MinkContext return false; } - /** - * @Given /^I am a student subscribed to session "([^"]*)"$/ - * - * @param string$sessionName - */ - public function iAmStudentSubscribedToXSession($sessionName) - { - $this->iAmAPlatformAdministrator(); - $this->visit('/main/session/session_add.php'); - $this->fillField('name', $sessionName); - $this->pressButton('Next step'); - $this->selectOption('NoSessionCoursesList[]', 'TEMP (TEMP)'); - $this->pressButton('add_course'); - $this->pressButton('Next step'); - $this->assertPageContainsText('Update successful'); - $this->fillField('user_to_add', 'acostea'); - $this->waitForThePageToBeLoaded(); - $this->clickLink('Costea Andrea (acostea)'); - $this->pressButton('Finish session creation'); - $this->assertPageContainsText('Session overview'); - //$this->assertPageContainsText('Costea Andrea (acostea)'); - $this->iAmAStudent(); - } - /** * Example: Then I should see the table "#category_results": * | Categories | Absolute score | Relative score | diff --git a/tests/behat/features/toolExercise.feature b/tests/behat/features/toolExercise.feature index c689d8ae4b..a9184a225c 100644 --- a/tests/behat/features/toolExercise.feature +++ b/tests/behat/features/toolExercise.feature @@ -232,6 +232,29 @@ Feature: Exercise tool And I press "submitQuestion" Then I should see "Item added" + Scenario: Duplicate exercise + Given I am on "/main/exercise/exercise.php?cidReq=TEMP" + And I follow "Copy this exercise as a new one" + And I confirm the popup + Then I should see "Exercise copied" + And I should see "Exercise 1 - Copy" + + Scenario: Import exercise to test questions categories + Given I am on "/main/exercise/upload_exercise.php?cidReq=TEMP" + And I should see "Import quiz from Excel" + And I attach the file "/tests/behat/uploadable_files/exercise.xls" to "user_upload_quiz" + When I press "Upload" + And wait for the page to be loaded + Then I should see "Exercise for Behat test" + + Scenario: Import exercise from excel + Given I am on "/main/exercise/upload_exercise.php?cidReq=TEMP" + Then I should see "Import quiz from Excel" + Then I attach the file "/main/exercise/quiz_template.xls" to "user_upload_quiz" + And I press "Upload" + And wait for the page to be loaded + Then I should see "Definition of oligarchy" + Scenario: Try exercise "Exercise 1" Given I am on "/main/exercise/exercise.php?cidReq=TEMP" And I follow "Exercise 1" @@ -303,28 +326,28 @@ Feature: Exercise tool And I follow "Grade activity" Then I should see "Score for the test: 83 / 117" - Scenario: Duplicate exercise - Given I am on "/main/exercise/exercise.php?cidReq=TEMP" - And I follow "Copy this exercise as a new one" - And I confirm the popup - Then I should see "Exercise copied" - And I should see "Exercise 1 - Copy" - - Scenario: Import exercise to test questions categories - Given I am on "/main/exercise/upload_exercise.php?cidReq=TEMP" - And I should see "Import quiz from Excel" - And I attach the file "/tests/behat/uploadable_files/exercise.xls" to "user_upload_quiz" - When I press "Upload" - And wait for the page to be loaded - Then I should see "Exercise for Behat test" + Scenario: Create a session "Session Exercise" and add user "acostea" + Given I am on "/main/session/session_add.php" + When I fill in the following: + | name | Session Exercise | + And I fill in select2 input "#coach_username" with id "1" and value "admin" + And I press "submit" + Then wait for the page to be loaded + Then I should see "Add courses to this session (Session Exercise)" + Then I select "TEMP (TEMP)" from "NoSessionCoursesList[]" + And I press "add_course" + And I press "next" + Then I should see "Update successful" + Then I follow "Multiple registration" + Then I select "Costea Andrea (acostea)" from "nosessionUsersList[]" + And I press "add_user" + And I press "next" + Then I should see "Update successful" Scenario: Try exercise with categorized questions as student - Given I am a student subscribed to session "Session Exercise" - And I am on "/user_portal.php" - And I follow "Session Exercise" - And wait for the page to be loaded - And I follow "tabs2" - And I follow "TEMP" + Given I am a student + And I am on course "TEMP" homepage in session "Session Exercise" + Then I should see "TEMP (Session Exercise)" And I am on "/main/exercise/exercise.php?cidReq=TEMP" And I follow "Exercise for Behat test" And I follow "Start test" @@ -363,10 +386,8 @@ Feature: Exercise tool Scenario: Teacher see exercise results by categories Given I am on "/user_portal.php" - And I follow "Session Exercise" - And wait for the page to be loaded - And I follow "tabs2" - And I follow "TEMP" + And I am on course "TEMP" homepage in session "Session Exercise" + Then I should see "TEMP (Session Exercise)" And I am on "/main/exercise/exercise.php?cidReq=TEMP" And I follow "Exercise for Behat test" And I follow "Results and feedback" @@ -397,10 +418,9 @@ Feature: Exercise tool And I follow "Delete" Then I should see "Category deleted" - Scenario: Import exercise from excel - Given I am on "/main/exercise/upload_exercise.php?cidReq=TEMP" - Then I should see "Import quiz from Excel" - Then I attach the file "/main/exercise/quiz_template.xls" to "user_upload_quiz" - And I press "Upload" + Scenario: Delete session + Given I am on "/main/session/session_list.php?keyword=Session+Exercise" And wait for the page to be loaded - Then I should see "Definition of oligarchy" + And I follow "Delete" + And I confirm the popup + Then I should see "Deleted"