From 6be69d61006a1ff241468deb223e1c71bd1fcafe Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Wed, 1 Mar 2017 14:19:14 +0100 Subject: [PATCH] Add announcement test + exercise with one question test --- .travis.yml | 5 -- tests/behat/features/announcement.feature | 25 +++++++++ .../features/bootstrap/FeatureContext.php | 15 +++++- tests/behat/features/exercise.feature | 53 ++++++++++++------- 4 files changed, 74 insertions(+), 24 deletions(-) create mode 100644 tests/behat/features/announcement.feature diff --git a/.travis.yml b/.travis.yml index 83fc805fbb..71cfed720e 100755 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,6 @@ services: - mysql -addons: - apt: - packages: - - oracle-java8-installer - language: php php: diff --git a/tests/behat/features/announcement.feature b/tests/behat/features/announcement.feature new file mode 100644 index 0000000000..7ce65fbeca --- /dev/null +++ b/tests/behat/features/announcement.feature @@ -0,0 +1,25 @@ +Feature: Announcement tool + In order to use the Announcement tool + The teachers should be able to create Announcements + + Background: + Given I am a platform administrator + And I am on course "TEMP" homepage + + Scenario: Create an announcement + Given I am on "/main/announcements/announcements.php?action=add&cidReq=TEMP" + When I fill in the following: + | title | Announcement test | + And I select "admin admin" from "users-f" + And I press "add" + And I fill in ckeditor field "content" with "Announcement description" + And I press "submit" + Then I should see "Announcement has been added" + + Scenario: Delete all announcements + Given I am on "/main/announcements/announcements.php?cidReq=TEMP" + When I follow "Clear list of announcements" +# And I confirm the popup + Then I should see "All announcements have been deleted" + + diff --git a/tests/behat/features/bootstrap/FeatureContext.php b/tests/behat/features/bootstrap/FeatureContext.php index ac1e504410..6383aa7724 100644 --- a/tests/behat/features/bootstrap/FeatureContext.php +++ b/tests/behat/features/bootstrap/FeatureContext.php @@ -277,7 +277,7 @@ class FeatureContext extends MinkContext } /** - * @Then /^I fill in wysiwyg field "([^"]*)" with "([^"]*)"$/ + * @Then /^I fill in ckeditor field "([^"]*)" with "([^"]*)"$/ */ public function iFillInWysiwygOnFieldWith($locator, $value) { @@ -371,4 +371,17 @@ class FeatureContext extends MinkContext //$this->getSession()->wait(10000, "document.readyState === 'complete'"); $this->getSession()->wait(3000); } + + /** + * @When /^I check the "([^"]*)" radio button$/ + */ + public function iCheckTheRadioButton($radioLabel) + { + $radioButton = $this->getSession()->getPage()->findField($radioLabel); + if (null === $radioButton) { + throw new Exception("Cannot find radio button ".$radioLabel); + } + //$value = $radioButton->getAttribute('value'); + $this->getSession()->getDriver()->click($radioButton->getXPath()); + } } diff --git a/tests/behat/features/exercise.feature b/tests/behat/features/exercise.feature index 6f24747dfe..9bb154b618 100644 --- a/tests/behat/features/exercise.feature +++ b/tests/behat/features/exercise.feature @@ -8,28 +8,45 @@ Feature: Exercise tool Scenario: Create an exercise Given I am on "/main/exercise/exercise_admin.php?cidReq=TEMP" + And I follow "Advanced settings" When I fill in the following: | exercise_title | Exercise 1 | - | exerciseDescription | Exercise description | + And I fill in ckeditor field "exerciseDescription" with "Exercise description" And I press "submitExercise" Then I should see "Exercise added" -# Scenario: Create an exercise with a question -# Given I am on "/main/exercise/exercise.php?cidReq=TEMP" -# And I follow "Exercise 1" -# And I follow "Edit" -# And I follow "Multiple choice" -# When I fill in the following: -# | questionName | Question Multiple choice | -## | answer[1] | Answer 1 | -## | answer[2] | Answer 2 | -## | answer[3] | Answer 3 | -## | answer[4] | Answer 4 | -## | weighting[1] | 10 | -## Then I fill in wysiwyg field "answer[1]" with "Answer 1" -# And I press "submitQuestion" -# Then I should see "Item added" -# -# + Scenario: Add question to exercise created "Exercise 1" + Given I am on "/main/exercise/exercise.php?cidReq=TEMP" + And I follow "Exercise 1" + And I follow "Edit" + And I follow "Multiple choice" + When I fill in the following: + | questionName | Question Multiple choice | + | weighting[1] | 10 | + Then I fill in ckeditor field "answer[1]" with "Answer true" + Then I fill in ckeditor field "answer[2]" with "Answer false" + Then I fill in ckeditor field "answer[3]" with "Answer false" + Then I fill in ckeditor field "answer[4]" with "Answer false" + + Then I fill in ckeditor field "comment[1]" with "Comment true" + Then I fill in ckeditor field "comment[2]" with "Comment false" + Then I fill in ckeditor field "comment[3]" with "Comment false" + Then I fill in ckeditor field "comment[4]" with "Comment false" + And I press "submitQuestion" + Then I should see "Item added" + Scenario: Try exercise "Exercise 1" + Given I am on "/main/exercise/exercise.php?cidReq=TEMP" + And I follow "Exercise 1" + And I follow "Start test" + Then I should see "Question Multiple choice" + And I check the "Answer true" radio button + Then I follow "End test" + And wait for the page to be loaded + Then I should see "Score for the test: 100 / 100" + Scenario: Delete an exercise + Given I am on "/main/exercise/exercise.php?cidReq=TEMP" + And I follow "Delete" + And I confirm the popup + Then I should see "The test has been deleted" \ No newline at end of file