Skip to content

Commit

Permalink
MDL-71914 feedback: Updated feedback behat tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Dias committed Oct 26, 2021
1 parent f1ca375 commit 57220ca
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 86 deletions.
8 changes: 4 additions & 4 deletions mod/feedback/tests/behat/anonymous.feature
Expand Up @@ -101,7 +101,7 @@ Feature: Anonymous feedback
And I log in as "manager"
And I am on site homepage
And I follow "Site feedback"
And I navigate to "Show responses" in current page administration
And I navigate to "Responses" in current page administration
And I should not see "Username"
And I should see "Anonymous entries (2)"
And I follow "Response number: 1"
Expand Down Expand Up @@ -164,7 +164,7 @@ Feature: Anonymous feedback
And I log in as "manager"
And I am on site homepage
And I follow "Site feedback"
And I navigate to "Show responses" in current page administration
And I navigate to "Responses" in current page administration
And I should see "Anonymous entries (2)"
And I follow "Response number: 1"
And I should see "Response number: 1 (Anonymous)"
Expand Down Expand Up @@ -216,7 +216,7 @@ Feature: Anonymous feedback
And I should see "Do you like this course?"
And I press "Continue"
And I should not see "Answer the questions"
And I navigate to "Show responses" in current page administration
And I navigate to "Responses" in current page administration
And I should not see "Username"
And I should see "Anonymous entries (2)"
And I follow "Response number: 1"
Expand Down Expand Up @@ -268,7 +268,7 @@ Feature: Anonymous feedback
And I log out
# Now check the responses are correct.
And I am on the "Course feedback" "feedback activity" page logged in as teacher
And I follow "Show responses"
And I follow "Responses"
And I should see "Anonymous entries (1)"
And I should see "Non anonymous entries (1)"
And I click on "," "link" in the "Username 1" "table_row"
Expand Down
10 changes: 3 additions & 7 deletions mod/feedback/tests/behat/behat_mod_feedback.php
Expand Up @@ -50,9 +50,7 @@ class behat_mod_feedback extends behat_base {
public function i_add_question_to_the_feedback_with($questiontype, TableNode $questiondata) {

$questiontype = $this->escape($questiontype);
$additem = $this->escape(get_string('add_item', 'feedback'));

$this->execute('behat_forms::i_select_from_the_singleselect', array($questiontype, $additem));
$this->execute('behat_forms::i_select_from_the_singleselect', array($questiontype, 'typ'));

// Wait again, for page to reloaded.
$this->execute('behat_general::i_wait_to_be_redirected');
Expand All @@ -69,7 +67,7 @@ public function i_add_question_to_the_feedback_with($questiontype, TableNode $qu

$this->execute("behat_forms::i_set_the_following_fields_to_these_values", $newdata);

$saveitem = $this->escape(get_string('save_item', 'feedback'));
$saveitem = $this->escape(get_string('save'));
$this->execute("behat_forms::press_button", $saveitem);
}

Expand All @@ -83,9 +81,7 @@ public function i_add_question_to_the_feedback_with($questiontype, TableNode $qu
public function i_add_a_page_break_to_the_feedback() {

$questiontype = $this->escape(get_string('add_pagebreak', 'feedback'));
$additem = $this->escape(get_string('add_item', 'feedback'));

$this->execute('behat_forms::i_select_from_the_singleselect', array($questiontype, $additem));
$this->execute('behat_forms::i_select_from_the_singleselect', array($questiontype, 'typ'));

// Wait again, for page to reloaded.
$this->execute('behat_general::i_wait_to_be_redirected');
Expand Down
17 changes: 7 additions & 10 deletions mod/feedback/tests/behat/export_import.feature
Expand Up @@ -39,7 +39,7 @@ Feature: Exporting and importing feedbacks
| Label | multichoice1 |
| Multiple choice type | Multiple choice - single answer |
| Multiple choice values | option a\noption b\noption c |
And I select "Add a page break" from the "Add question" singleselect
And I select "Add a page break" from the "typ" singleselect
And I add a "Multiple choice" question to the feedback with:
| Question | this is a multiple choice 2 |
| Label | multichoice2 |
Expand All @@ -66,7 +66,6 @@ Feature: Exporting and importing feedbacks
| Question | this is a short text answer |
| Label | shorttext |
| Maximum characters accepted | 200 |
And I follow "Templates"
Then following "Export questions" should export feedback identical to "mod/feedback/tests/fixtures/testexport.xml"
And I log out

Expand All @@ -78,11 +77,10 @@ Feature: Exporting and importing feedbacks
| Question | Existing question |
| Label | numeric |
| Range to | 100 |
And I follow "Templates"
And I follow "Import questions"
And I select "Import questions" from the "jump" singleselect
And I upload "mod/feedback/tests/fixtures/testexport.xml" file to "File" filemanager
And I press "Yes"
And I click on "Edit questions" "link" in the "[role=main]" "css_element"
And I press "Save"
And I select "Add question" from the "jump" singleselect
Then I should not see "Existing question"
And I should see "this is an information question"
And I should see "label text"
Expand All @@ -102,12 +100,11 @@ Feature: Exporting and importing feedbacks
| Question | Existing question |
| Label | numeric |
| Range to | 100 |
And I follow "Templates"
And I follow "Import questions"
And I select "Import questions" from the "jump" singleselect
And I set the field "Append new items" to "1"
And I upload "mod/feedback/tests/fixtures/testexport.xml" file to "File" filemanager
And I press "Yes"
And I click on "Edit questions" "link" in the "[role=main]" "css_element"
And I press "Save"
And I select "Add question" from the "jump" singleselect
Then I should see "Existing question"
And "Existing question" "text" should appear before "this is an information question" "text"
And I should see "this is an information question"
Expand Down
6 changes: 4 additions & 2 deletions mod/feedback/tests/behat/groups.feature
Expand Up @@ -139,7 +139,8 @@ Feature: Feedbacks in courses with groups
And I show chart data for the "multichoice1" feedback
And I should see "0" in the "Yes of course" "table_row"
And I should see "2 (66.67 %)" in the "Not at all" "table_row"
And I follow "Show responses"
And I am on the "Course feedback" "feedback activity" page
And I navigate to "Responses" in current page administration
And the field "Separate groups" matches value "Group 2"
And I should not see "Username 1"
And I should see "Username 3"
Expand Down Expand Up @@ -234,7 +235,8 @@ Feature: Feedbacks in courses with groups
And I show chart data for the "multichoice1" feedback
And I should see "0" in the "Yes of course" "table_row"
And I should see "2 (66.67 %)" in the "Not at all" "table_row"
And I follow "Show responses"
And I am on the "Course anon feedback" "feedback activity" page
And I navigate to "Responses" in current page administration
# The response numbers were randomly allocated, we only can assert the number of visible responses here:
And the field "Separate groups" matches value "Group 2"
And "//tr[contains(@id,'_r2') and contains(.,'Response number')]" "xpath_element" should exist
Expand Down
24 changes: 15 additions & 9 deletions mod/feedback/tests/behat/multichoice.feature
Expand Up @@ -33,7 +33,7 @@ Feature: Testing multichoice questions in feedback
| Multiple choice values | option a\noption b\noption c |
And I add a "Label" question to the feedback with:
| Contents | this is the first page of the feedback |
And I select "Add a page break" from the "Add question" singleselect
And I select "Add a page break" from the "typ" singleselect
And I add a "Multiple choice" question to the feedback with:
| Question | this is a multiple choice 2 |
| Label | multichoice2 |
Expand All @@ -42,7 +42,7 @@ Feature: Testing multichoice questions in feedback
| Required | 1 |
And I add a "Label" question to the feedback with:
| Contents | this is the second page of the feedback |
And I select "Add a page break" from the "Add question" singleselect
And I select "Add a page break" from the "typ" singleselect
And I add a "Multiple choice" question to the feedback with:
| Question | this is a multiple choice 3 |
| Label | multichoice3 |
Expand Down Expand Up @@ -149,12 +149,14 @@ Feature: Testing multichoice questions in feedback
And I should not see "%" in the "option h" "table_row"
And I should see "1 (100.00 %)" in the "option i" "table_row"
# Change the settings so we don't analyse empty submits
And I am on the "Learning experience" "feedback activity" page
And I click on "Edit questions" "link" in the "[role=main]" "css_element"
And I open the action menu in "//div[contains(@class, 'feedback_itemlist') and contains(.,'multichoice1')]" "xpath_element"
And I choose "Edit question" in the open action menu
And I set the field "Do not analyse empty submits" to "Yes"
And I press "Save changes to question"
And I follow "Analysis"
And I am on the "Learning experience" "feedback activity" page
And I navigate to "Analysis" in current page administration
And I show chart data for the "multichoice1" feedback
And I should see "1 (100.00 %)" in the "option a" "table_row"
And I should not see "%" in the "option b" "table_row"
Expand All @@ -171,7 +173,7 @@ Feature: Testing multichoice questions in feedback
| Multiple choice values | option a\noption b\noption c |
And I add a "Label" question to the feedback with:
| Contents | this is the first page of the feedback |
And I select "Add a page break" from the "Add question" singleselect
And I select "Add a page break" from the "typ" singleselect
And I add a "Multiple choice" question to the feedback with:
| Question | this is a multiple choice 2 |
| Label | multichoice2 |
Expand All @@ -180,7 +182,7 @@ Feature: Testing multichoice questions in feedback
| Required | 1 |
And I add a "Label" question to the feedback with:
| Contents | this is the second page of the feedback |
And I select "Add a page break" from the "Add question" singleselect
And I select "Add a page break" from the "typ" singleselect
And I add a "Multiple choice" question to the feedback with:
| Question | this is a multiple choice 3 |
| Label | multichoice3 |
Expand Down Expand Up @@ -287,12 +289,14 @@ Feature: Testing multichoice questions in feedback
And I should not see "%" in the "option h" "table_row"
And I should see "1 (100.00 %)" in the "option i" "table_row"
# Change the settings so we don't analyse empty submits
And I am on the "Learning experience" "feedback activity" page
And I click on "Edit questions" "link" in the "[role=main]" "css_element"
And I open the action menu in "//div[contains(@class, 'feedback_itemlist') and contains(.,'multichoice1')]" "xpath_element"
And I choose "Edit question" in the open action menu
And I set the field "Do not analyse empty submits" to "Yes"
And I press "Save changes to question"
And I follow "Analysis"
And I am on the "Learning experience" "feedback activity" page
And I navigate to "Analysis" in current page administration
And I show chart data for the "multichoice1" feedback
And I should see "1 (100.00 %)" in the "option a" "table_row"
And I should see "1 (100.00 %)" in the "option b" "table_row"
Expand All @@ -308,7 +312,7 @@ Feature: Testing multichoice questions in feedback
| Multiple choice values | option a\noption b\noption c |
And I add a "Label" question to the feedback with:
| Contents | this is the first page of the feedback |
And I select "Add a page break" from the "Add question" singleselect
And I select "Add a page break" from the "typ" singleselect
And I add a "Multiple choice" question to the feedback with:
| Question | this is a multiple choice 2 |
| Label | multichoice2 |
Expand All @@ -317,7 +321,7 @@ Feature: Testing multichoice questions in feedback
| Required | 1 |
And I add a "Label" question to the feedback with:
| Contents | this is the second page of the feedback |
And I select "Add a page break" from the "Add question" singleselect
And I select "Add a page break" from the "typ" singleselect
And I add a "Multiple choice" question to the feedback with:
| Question | this is a multiple choice 3 |
| Label | multichoice3 |
Expand Down Expand Up @@ -404,12 +408,14 @@ Feature: Testing multichoice questions in feedback
And I should not see "%" in the "option h" "table_row"
And I should see "1 (100.00 %)" in the "option i" "table_row"
# Change the settings so we don't analyse empty submits
And I am on the "Learning experience" "feedback activity" page
And I click on "Edit questions" "link" in the "[role=main]" "css_element"
And I open the action menu in "//div[contains(@class, 'feedback_itemlist') and contains(.,'multichoice1')]" "xpath_element"
And I choose "Edit question" in the open action menu
And I set the field "Do not analyse empty submits" to "Yes"
And I press "Save changes to question"
And I follow "Analysis"
And I am on the "Learning experience" "feedback activity" page
And I navigate to "Analysis" in current page administration
And I show chart data for the "multichoice1" feedback
And I should see "1 (100.00 %)" in the "option a" "table_row"
And I should not see "%" in the "option b" "table_row"
Expand Down
5 changes: 2 additions & 3 deletions mod/feedback/tests/behat/non_anonymous.feature
Expand Up @@ -83,10 +83,9 @@ Feature: Non anonymous feedback
And I should see "Do you like our site?"
And I should see "1 (50.00 %)" in the "Yes of course" "table_row"
And I should see "1 (50.00 %)" in the "Not at all" "table_row"
And I should not see "Show responses"
And I log out
And I am on the "Site feedback" "feedback activity" page logged in as manager
And I navigate to "Show responses" in current page administration
And I navigate to "Responses" in current page administration
And I should see "Username"
And I should see "Non anonymous entries (2)"
And I should not see "Anonymous entries"
Expand Down Expand Up @@ -134,7 +133,7 @@ Feature: Non anonymous feedback
And I should see "Do you like this course?"
And I press "Continue"
And I should not see "Answer the questions"
And I navigate to "Show responses" in current page administration
And I navigate to "Responses" in current page administration
And I should see "Non anonymous entries (2)"
And I should not see "Anonymous"
And I click on "," "link" in the "Username 1" "table_row"
Expand Down
8 changes: 3 additions & 5 deletions mod/feedback/tests/behat/show_nonrespondents.feature
Expand Up @@ -46,10 +46,8 @@ Feature: Show users who have not responded to the feedback survey
| Access restrictions | Grouping: GX1 |
And I am on the Frogs "feedback activity" page
And I click on "Edit questions" "link" in the "[role=main]" "css_element"
And I set the field "Add question" to "Short text answer"
And I set the following fields to these values:
And I add a "Short text answer" question to the feedback with:
| Question | Y/N? |
And I press "Save question"
And I log out

# Go in as student 1 and do the feedback.
Expand All @@ -61,8 +59,8 @@ Feature: Show users who have not responded to the feedback survey

# Go in as teacher and check the users who haven't completed it.
And I am on the Frogs "feedback activity" page logged in as teacher1
And I navigate to "Show non-respondents" in current page administration

And I navigate to "Responses" in current page administration
And I select "Show non-respondents" from the "jump" singleselect
# Should only show student 2; not student 1 (they did it) or 3 (not in grouping).
Then I should see "Student 2"
And I should not see "Student 1"
Expand Down

0 comments on commit 57220ca

Please sign in to comment.