From 710607ce5f751a3ec86318aeebd2110856c38b7c Mon Sep 17 00:00:00 2001 From: Angelia Dela Cruz Date: Tue, 27 Sep 2022 09:59:14 +0800 Subject: [PATCH] MDL-75830 behat: Book behat tests optimised Replace steps that manually add Book instances via the UI and use Behat generators. This improves the speed of the Behat test runs. Additionally, performed Behat cleanup and optimisation to affected files. --- ...ck_recentlyaccesseditems_dashboard.feature | 2 +- blocks/tests/behat/manage_blocks.feature | 17 ++--- blocks/tests/behat/move_blocks.feature | 16 ++--- .../tests/behat/content_preferences.feature | 2 +- .../tests/behat/course_courseindex.feature | 9 ++- .../behat/courseindex_keyboardnav.feature | 2 +- .../tests/behat/movecm_keyboard.feature | 2 +- .../tests/behat/movesection_keyboard.feature | 2 +- .../tests/behat/edit_delete_sections.feature | 2 +- .../tests/behat/edit_delete_sections.feature | 2 +- .../behat/course_collapse_sections.feature | 10 ++- .../behat/book_activity_completion.feature | 3 - mod/book/tests/behat/create_chapters.feature | 26 ++++---- .../behat/display_book_description.feature | 37 ++++------- .../behat/edit_navigation_options.feature | 4 +- mod/book/tests/behat/edit_tags.feature | 2 - mod/book/tests/behat/log_entries.feature | 2 +- .../tests/behat/reorganize_chapters.feature | 45 ++++--------- .../tests/behat/show_hide_chapters.feature | 43 ++++-------- report/outline/tests/behat/filter.feature | 31 +++------ report/outline/tests/behat/outline.feature | 65 +++++-------------- .../tests/behat/filter_participation.feature | 22 ++----- .../tests/behat/message_participants.feature | 11 +--- 23 files changed, 111 insertions(+), 246 deletions(-) diff --git a/blocks/recentlyaccesseditems/tests/behat/block_recentlyaccesseditems_dashboard.feature b/blocks/recentlyaccesseditems/tests/behat/block_recentlyaccesseditems_dashboard.feature index 44046e795b8..73605ac4ab1 100644 --- a/blocks/recentlyaccesseditems/tests/behat/block_recentlyaccesseditems_dashboard.feature +++ b/blocks/recentlyaccesseditems/tests/behat/block_recentlyaccesseditems_dashboard.feature @@ -37,7 +37,7 @@ Feature: The recently accessed items block allows users to easily access their m Given the following "activities" exist: | activity | name | intro | course | idnumber | | assign | Test assignment name | Test assignment description | C1 | assign1 | - | book | Test book name | Test book description | C1 | book1 | + | book | Test book name | | C1 | book1 | | choice | Test choice name | Test choice description | C1 | choice1 | | data | Test database name | Test database description | C1 | data1 | And I change window size to "large" diff --git a/blocks/tests/behat/manage_blocks.feature b/blocks/tests/behat/manage_blocks.feature index ad2c6541a4d..1a86e24df6e 100644 --- a/blocks/tests/behat/manage_blocks.feature +++ b/blocks/tests/behat/manage_blocks.feature @@ -15,16 +15,13 @@ Feature: Block appearances | user | course | role | | teacher1 | C1 | editingteacher | And the following "activities" exist: - | activity | name | description | course | idnumber | section | template | - | survey | Test survey name | | C1 | survey1 | 1 | 4 | - | book | Test book name | Test book description | C1 | book1 | 1 | | - And I log in as "admin" - And I am on "Course 1" course homepage with editing mode on - And I click on "Test book name" "link" in the "region-main" "region" - And I set the following fields to these values: - | Chapter title | Book title | - | Content | Book content test test | - And I press "Save changes" + | activity | name | course | idnumber | template | + | survey | Test survey name | C1 | survey1 | 4 | + | book | Test book name | C1 | book1 | | + And the following "mod_book > chapter" exists: + | book | Test book name | + | title | Book title | + | content | Book content test test | And I am on the "Course 1" course page logged in as teacher1 And I turn editing mode on And I add the "Comments" block diff --git a/blocks/tests/behat/move_blocks.feature b/blocks/tests/behat/move_blocks.feature index 88e30319b99..c16b6fe0896 100644 --- a/blocks/tests/behat/move_blocks.feature +++ b/blocks/tests/behat/move_blocks.feature @@ -17,17 +17,11 @@ Feature: Block region moving And the following "activities" exist: | activity | course | name | template | | survey | C1 | Test survey name | 4 | - And I log in as "admin" - And I am on "Course 1" course homepage with editing mode on - And I add a "Book" to section "1" and I fill the form with: - | Name | Test book name | - | Description | Test book description | - And I follow "Test book name" - And I set the following fields to these values: - | Chapter title | Book title | - | Content | Book content test test | - And I press "Save changes" - And I log out + | book | C1 | Test book name | | + And the following "mod_book > chapter" exists: + | book | Test book name | + | title | Book title | + | content | Book content test test | And I log in as "teacher1" And I am on "Course 1" course homepage with editing mode on And I add the "Comments" block diff --git a/course/format/tests/behat/content_preferences.feature b/course/format/tests/behat/content_preferences.feature index 82caaad2604..31e8de3a3a4 100644 --- a/course/format/tests/behat/content_preferences.feature +++ b/course/format/tests/behat/content_preferences.feature @@ -18,7 +18,7 @@ Feature: Course content collapsed user preferences And the following "activities" exist: | activity | name | intro | course | idnumber | section | | assign | Activity sample 1 | Test assignment description | C1 | sample1 | 1 | - | book | Activity sample 2 | Test book description | C1 | sample2 | 2 | + | book | Activity sample 2 | | C1 | sample2 | 2 | | choice | Activity sample 3 | Test choice description | C1 | sample3 | 3 | | assign | Activity sample 4 | Test assignment description | C1 | sample1 | 4 | | assign | Activity sample 5 | Test assignment description | C1 | sample1 | 5 | diff --git a/course/format/tests/behat/course_courseindex.feature b/course/format/tests/behat/course_courseindex.feature index 8c0bd9e52d6..acbf7591d2d 100644 --- a/course/format/tests/behat/course_courseindex.feature +++ b/course/format/tests/behat/course_courseindex.feature @@ -18,7 +18,7 @@ Feature: Course index depending on role And the following "activities" exist: | activity | name | intro | course | idnumber | section | | assign | Activity sample 1 | Test assignment description | C1 | sample1 | 1 | - | book | Activity sample 2 | Test book description | C1 | sample2 | 2 | + | book | Activity sample 2 | | C1 | sample2 | 2 | | choice | Activity sample 3 | Test choice description | C1 | sample3 | 3 | And the following "course enrolments" exist: | user | course | role | @@ -129,10 +129,9 @@ Feature: Course index depending on role @javascript Scenario: Course index toggling Given the following "activities" exist: - | activity | name | intro | course | idnumber | section | - | book | Second activity in section 1 | Test book description | C1 | sample4 | 1 | - And I log in as "teacher1" - When I am on "Course 1" course homepage + | activity | name | course | idnumber | section | + | book | Second activity in section 1 | C1 | sample4 | 1 | + When I am on the "Course 1" course page logged in as teacher1 # Sections should be opened by default. Then I should see "Topic 1" in the "courseindex-content" "region" And I should see "Activity sample 1" in the "courseindex-content" "region" diff --git a/course/format/tests/behat/courseindex_keyboardnav.feature b/course/format/tests/behat/courseindex_keyboardnav.feature index 82129b41474..7f6d629c951 100644 --- a/course/format/tests/behat/courseindex_keyboardnav.feature +++ b/course/format/tests/behat/courseindex_keyboardnav.feature @@ -14,7 +14,7 @@ Feature: Verify that courseindex is usable with the keyboard And the following "activities" exist: | activity | name | intro | course | idnumber | section | | assign | Activity sample 1 | Test assignment description | C1 | sample1 | 1 | - | book | Activity sample 2 | Test book description | C1 | sample2 | 2 | + | book | Activity sample 2 | | C1 | sample2 | 2 | | choice | Activity sample 3 | Test choice description | C1 | sample3 | 3 | Given I am on the "C1" "Course" page logged in as "admin" And I change window size to "large" diff --git a/course/format/tests/behat/movecm_keyboard.feature b/course/format/tests/behat/movecm_keyboard.feature index a2181b53b4d..bd81af5bf96 100644 --- a/course/format/tests/behat/movecm_keyboard.feature +++ b/course/format/tests/behat/movecm_keyboard.feature @@ -14,7 +14,7 @@ Feature: Move activity using keyboard And the following "activities" exist: | activity | name | intro | course | idnumber | section | | assign | Activity sample 1 | Test assignment description | C1 | sample1 | 1 | - | book | Activity sample 2 | Test book description | C1 | sample2 | 2 | + | book | Activity sample 2 | | C1 | sample2 | 2 | | choice | Activity sample 3 | Test choice description | C1 | sample3 | 3 | | choice | Other sample 3 | Test choice description | C1 | sample31 | 3 | And I log in as "admin" diff --git a/course/format/tests/behat/movesection_keyboard.feature b/course/format/tests/behat/movesection_keyboard.feature index 9873be19568..0653f8bdbad 100644 --- a/course/format/tests/behat/movesection_keyboard.feature +++ b/course/format/tests/behat/movesection_keyboard.feature @@ -14,7 +14,7 @@ Feature: Move a section using keyboard And the following "activities" exist: | activity | name | intro | course | idnumber | section | | assign | Activity sample 1 | Test assignment description | C1 | sample1 | 1 | - | book | Activity sample 2 | Test book description | C1 | sample2 | 2 | + | book | Activity sample 2 | | C1 | sample2 | 2 | | choice | Activity sample 3 | Test choice description | C1 | sample3 | 3 | | choice | Other sample 3 | Test choice description | C1 | sample31 | 3 | And I log in as "admin" diff --git a/course/format/topics/tests/behat/edit_delete_sections.feature b/course/format/topics/tests/behat/edit_delete_sections.feature index 11683e11d8c..cc5efb21116 100644 --- a/course/format/topics/tests/behat/edit_delete_sections.feature +++ b/course/format/topics/tests/behat/edit_delete_sections.feature @@ -14,7 +14,7 @@ Feature: Sections can be edited and deleted in topics format And the following "activities" exist: | activity | name | intro | course | idnumber | section | | assign | Test assignment name | Test assignment description | C1 | assign1 | 0 | - | book | Test book name | Test book description | C1 | book1 | 1 | + | book | Test book name | | C1 | book1 | 1 | | chat | Test chat name | Test chat description | C1 | chat1 | 4 | | choice | Test choice name | Test choice description | C1 | choice1 | 5 | And the following "course enrolments" exist: diff --git a/course/format/weeks/tests/behat/edit_delete_sections.feature b/course/format/weeks/tests/behat/edit_delete_sections.feature index 4cd1416b85d..f91d48aec19 100644 --- a/course/format/weeks/tests/behat/edit_delete_sections.feature +++ b/course/format/weeks/tests/behat/edit_delete_sections.feature @@ -14,7 +14,7 @@ Feature: Sections can be edited and deleted in weeks format And the following "activities" exist: | activity | name | intro | course | idnumber | section | | assign | Test assignment name | Test assignment description | C1 | assign1 | 0 | - | book | Test book name | Test book description | C1 | book1 | 1 | + | book | Test book name | | C1 | book1 | 1 | | chat | Test chat name | Test chat description | C1 | chat1 | 4 | | choice | Test choice name | Test choice description | C1 | choice1 | 5 | And the following "course enrolments" exist: diff --git a/course/tests/behat/course_collapse_sections.feature b/course/tests/behat/course_collapse_sections.feature index ec81055a521..ecda98465d2 100644 --- a/course/tests/behat/course_collapse_sections.feature +++ b/course/tests/behat/course_collapse_sections.feature @@ -22,8 +22,8 @@ Feature: Collapse course sections | activity | name | intro | course | idnumber | section | completion | | assign | Assignment 1 | Test assignment description1 | C1 | assign1 | 1 | 1 | | assign | Assignment 2 | Test assignment description2 | C1 | assign2 | 2 | 1 | - | book | Book 2 | Test book description2 | C1 | book2 | 2 | 1 | - | book | Book 3 | Test book description3 | C1 | book3 | 3 | 1 | + | book | Book 2 | | C1 | book2 | 2 | 1 | + | book | Book 3 | | C1 | book3 | 3 | 1 | | forum | Forum 4 | Test forum description4 | C1 | forum4 | 4 | 1 | | forum | Forum 5 | Test forum description5 | C1 | forum5 | 5 | 1 | And the following "course enrolments" exist: @@ -58,8 +58,7 @@ Feature: Collapse course sections @javascript Scenario: Expand/collapse sections for Topics format. - Given I log in as "student1" - And I am on "Course 1" course homepage + Given I am on the "Course 1" course page logged in as student1 And "[data-toggle=collapse]" "css_element" should exist in the "region-main" "region" And I should see "Assignment 1" in the "region-main" "region" And I should see "Assignment 2" in the "region-main" "region" @@ -97,8 +96,7 @@ Feature: Collapse course sections @javascript Scenario: Expand/collapse sections for Weeks format. - Given I log in as "teacher1" - And I am on "Course 1" course homepage + Given I am on the "Course 1" course page logged in as teacher1 When I navigate to "Settings" in current page administration And I expand all fieldsets And I set the following fields to these values: diff --git a/mod/book/tests/behat/book_activity_completion.feature b/mod/book/tests/behat/book_activity_completion.feature index 1f5534a7f8d..8722ab480cd 100644 --- a/mod/book/tests/behat/book_activity_completion.feature +++ b/mod/book/tests/behat/book_activity_completion.feature @@ -21,7 +21,6 @@ Feature: View activity completion information in the book activity | course | C1 | | idnumber | mh1 | | name | Music history | - | section | 1 | | completion | 2 | | completionview | 1 | @@ -32,7 +31,6 @@ Feature: View activity completion information in the book activity | content | Rudiments are important | And I am on the "Music history" "book activity" page logged in as teacher1 And "Music history" should have the "View" completion condition - And I log out # Student view. When I am on the "Music history" "book activity" page logged in as student1 Then the "View" completion condition of "Music history" is displayed as "done" @@ -50,7 +48,6 @@ Feature: View activity completion information in the book activity And I am on the "Music history" "book activity" page # Teacher view. And the manual completion button for "Music history" should be disabled - And I log out # Student view. Given I am on the "Music history" "book activity" page logged in as student1 Then the manual completion button of "Music history" is displayed as "Mark as done" diff --git a/mod/book/tests/behat/create_chapters.feature b/mod/book/tests/behat/create_chapters.feature index 2a2afd19081..ef38f78701c 100644 --- a/mod/book/tests/behat/create_chapters.feature +++ b/mod/book/tests/behat/create_chapters.feature @@ -17,18 +17,17 @@ Feature: In a book, create chapters and sub chapters | teacher1 | C1 | editingteacher | | student1 | C1 | student | And the following "activities" exist: - | activity | name | intro | course | section | - | book | Test book | A book about dreams! | C1 | 1 | + | activity | name | course | section | + | book | Test book | C1 | 1 | And I log in as "teacher1" And I am on "Course 1" course homepage with editing mode on Scenario: Create chapters and sub chapters and navigate between them - Given I am on the "Test book" Activity page - And I should see "Add new chapter" - And I set the following fields to these values: - | Chapter title | Dummy first chapter | - | Content | Dream is the start of a journey | - And I press "Save changes" + Given the following "mod_book > chapter" exists: + | book | Test book | + | title | Dummy first chapter | + | content | Dream is the start of a journey | + And I am on the "Test book" "book activity" page And I should not see "No content has been added to this book yet." And I should see "1. Dummy first chapter" in the "Table of contents" "block" And I click on "Add new chapter after \"Dummy first chapter\"" "link" in the "Table of contents" "block" @@ -65,12 +64,11 @@ Feature: In a book, create chapters and sub chapters And I should see "1. Dummy first chapter" in the "strong" "css_element" Scenario: Change editing mode for an individual chapter - Given I am on the "Test book" Activity page - And I should see "Add new chapter" - And I set the following fields to these values: - | Chapter title | Dummy first chapter | - | Content | Dream is the start of a journey | - And I press "Save changes" + Given the following "mod_book > chapter" exists: + | book | Test book | + | title | Dummy first chapter | + | content | Dream is the start of a journey | + And I am on the "Test book" "book activity" page And I should see "1. Dummy first chapter" in the "Table of contents" "block" And "Edit chapter \"1. Dummy first chapter\"" "link" should exist in the "Table of contents" "block" And "Delete chapter \"1. Dummy first chapter\"" "link" should exist in the "Table of contents" "block" diff --git a/mod/book/tests/behat/display_book_description.feature b/mod/book/tests/behat/display_book_description.feature index 47c67f5ab8a..c4212ade98f 100644 --- a/mod/book/tests/behat/display_book_description.feature +++ b/mod/book/tests/behat/display_book_description.feature @@ -17,50 +17,39 @@ Feature: Display the book description in the book and optionally in the course | teacher1 | C1 | editingteacher | | student1 | C1 | student | And the following "activities" exist: - | activity | name | intro | course | idnumber | section | - | book | Test book | A book about dreams! | C1 | book1 | 1 | - And I log in as "teacher1" - And I am on "Course 1" course homepage - And I am on the "Test book" "book activity" page - And I should see "Add new chapter" - And I set the following fields to these values: - | Chapter title | Dummy first chapter | - | Content | Dream is the start of a journey | - And I press "Save changes" + | activity | name | intro | course | idnumber | + | book | Test book | A book about dreams! | C1 | book1 | + And the following "mod_book > chapter" exists: + | book | Test book | + | title | Dummy first chapter | + | content | Dream is the start of a journey | Scenario: Description is displayed in the book - Given I am on "Course 1" course homepage - When I am on the "Test book" "book activity" page + When I am on the "Test book" "book activity" page logged in as teacher1 Then I should see "A book about dreams!" Scenario: Show book description in the course homepage - Given I am on "Course 1" course homepage - And I am on the "Test book" "book activity" page - And I navigate to "Settings" in current page administration + Given I am on the "Test book" "book activity editing" page logged in as teacher1 And the following fields match these values: | Display description on course page | | And I set the following fields to these values: | Display description on course page | 1 | - And I press "Save and return to course" - When I am on "Course 1" course homepage + When I press "Save and return to course" Then I should see "A book about dreams!" Scenario: Hide book description in the course homepage - Given I am on "Course 1" course homepage - And I am on the "Test book" "book activity" page - And I navigate to "Settings" in current page administration + Given I am on the "Test book" "book activity editing" page logged in as teacher1 And the following fields match these values: | Display description on course page | | - And I press "Save and return to course" - When I am on "Course 1" course homepage + When I press "Save and return to course" Then I should not see "A book about dreams!" @javascript Scenario: Description is displayed in the book for students when there are no chapters added yet - Given I am on "Course 1" course homepage with editing mode on + Given I log in as "teacher1" + And I am on "Course 1" course homepage with editing mode on And I am on the "Test book" "book activity" page And I click on "Delete chapter \"1. Dummy first chapter\"" "link" in the "Table of contents" "block" And I click on "Yes" "button" in the "Confirmation" "dialogue" - And I log out And I am on the "Test book" "book activity" page logged in as student1 Then I should see "A book about dreams!" diff --git a/mod/book/tests/behat/edit_navigation_options.feature b/mod/book/tests/behat/edit_navigation_options.feature index 6e4a0c489f0..0a7feb52214 100644 --- a/mod/book/tests/behat/edit_navigation_options.feature +++ b/mod/book/tests/behat/edit_navigation_options.feature @@ -19,8 +19,8 @@ Feature: In a book, change the navigation options # The option to "Style of navigation" is removed from the settings. Scenario: Change navigation options Given the following "activities" exist: - | activity | name | intro | course | idnumber | section | navstyle | - | book | Test book | A book about lorem ipsum | C1 | book1 | 1 | 0 | + | activity | name | course | idnumber | navstyle | + | book | Test book | C1 | book1 | 0 | And I am on "Course 1" course homepage with editing mode on And I follow "Test book" And I should see "Add new chapter" diff --git a/mod/book/tests/behat/edit_tags.feature b/mod/book/tests/behat/edit_tags.feature index 8737d6f8c1b..ac3a03d5f85 100644 --- a/mod/book/tests/behat/edit_tags.feature +++ b/mod/book/tests/behat/edit_tags.feature @@ -17,7 +17,6 @@ Feature: Edited book chapters handle tags correctly | course | C1 | | idnumber | book1 | | name | Test book | - | description | A book about dreams | And the following "course enrolments" exist: | user | course | role | | teacher1 | C1 | editingteacher | @@ -48,7 +47,6 @@ Feature: Edited book chapters handle tags correctly And I follow "Add standard tags" And I set the field "Enter comma-separated list of new tags" to "OT1, OT2, OT3" And I press "Continue" - And I log out And I am on the "Test book" "book activity" page logged in as teacher1 And I open the autocomplete suggestions list And I should see "OT1" in the ".form-autocomplete-suggestions" "css_element" diff --git a/mod/book/tests/behat/log_entries.feature b/mod/book/tests/behat/log_entries.feature index 44f4a8a3d3c..40a4153a861 100644 --- a/mod/book/tests/behat/log_entries.feature +++ b/mod/book/tests/behat/log_entries.feature @@ -14,7 +14,7 @@ Feature: In a book, verify log entries | activity | book | | name | Test book | And I am on the "Course 1" course page logged in as admin - And I am on "Course 1" course homepage with editing mode on + And I turn editing mode on And I am on the "Test book" "book activity" page And I set the following fields to these values: | Chapter title | First chapter | diff --git a/mod/book/tests/behat/reorganize_chapters.feature b/mod/book/tests/behat/reorganize_chapters.feature index 4a4601b4921..fff4a99d67c 100644 --- a/mod/book/tests/behat/reorganize_chapters.feature +++ b/mod/book/tests/behat/reorganize_chapters.feature @@ -15,44 +15,22 @@ Feature: In a book, chapters and subchapters can be rearranged | user | course | role | | teacher1 | C1 | editingteacher | And the following "activities" exist: - | activity | name | intro | course | idnumber | section | - | book | Test book | A book about rearrangements! | C1 | book1 | 1 | + | activity | name | course | idnumber | + | book | Test book | C1 | book1 | + And the following "mod_book > chapters" exist: + | book | title | content | pagenum |subchapter | + | Test book | Originally first chapter | #1 chapter content | 1 | 0 | + | Test book | A great second chapter | #2 chapter content | 2 | 0 | + | Test book | Second chapter, subchapter 1 | #21 subchapter content | 3 | 1 | + | Test book | Second chapter, subchapter 2 | #22 subchapter content | 4 | 1 | + | Test book | There aren't 2 without 3 | #3 subchapter content | 5 | 0 | And I log in as "teacher1" And I am on "Course 1" course homepage with editing mode on And I follow "Test book" - And I should see "Add new chapter" - And I set the following fields to these values: - | Chapter title | Originally first chapter | - | Content | #1 chapter content | - And I press "Save changes" - And I click on "Add new chapter after \"Originally first chapter\"" "link" - And I set the following fields to these values: - | Chapter title | A great second chapter | - | Content | #2 chapter content | - And I press "Save changes" - And I click on "Add new chapter after \"A great second chapter\"" "link" - And I set the following fields to these values: - | Chapter title | Second chapter, subchapter 1 | - | Content | #21 subchapter content | - | Subchapter | 1 | - And I press "Save changes" - And I click on "Add new chapter after \"Second chapter, subchapter 1\"" "link" - And I set the following fields to these values: - | Chapter title | Second chapter, subchapter 2 | - | Content | #22 subchapter content | - | Subchapter | 1 | - And I press "Save changes" - And I click on "Add new chapter after \"Second chapter, subchapter 2\"" "link" - And I set the following fields to these values: - | Chapter title | There aren't 2 without 3 | - | Content | #3 subchapter content | - | Subchapter | 0 | - And I press "Save changes" Scenario: Moving chapters down rearranges them properly Given I click on "Move chapter down \"1. Originally first chapter\"" "link" - When I am on "Course 1" course homepage - And I follow "Test book" + When I am on the "Test book" "book activity" page Then I should see "1. A great second chapter" And I should see "#2 chapter content" And I should see "1.1. Second chapter, subchapter 1" @@ -62,8 +40,7 @@ Feature: In a book, chapters and subchapters can be rearranged Scenario: Moving chapters up rearranges them properly Given I click on "Move chapter up \"3. There aren't 2 without 3\"" "link" - When I am on "Course 1" course homepage - And I follow "Test book" + When I am on the "Test book" "book activity" page Then I should see "1. Originally first chapter" And I should see "#1 chapter content" And I should see "2. There aren't 2 without 3" diff --git a/mod/book/tests/behat/show_hide_chapters.feature b/mod/book/tests/behat/show_hide_chapters.feature index 5bc3eabde6b..7ec70045469 100644 --- a/mod/book/tests/behat/show_hide_chapters.feature +++ b/mod/book/tests/behat/show_hide_chapters.feature @@ -20,36 +20,17 @@ Feature: Book activity chapter visibility management | course | C1 | | activity | book | | name | Test book | - And I am on the "Test book" "book activity" page logged in as teacher1 - And I set the following fields to these values: - | Chapter title | First chapter | - | Content | First chapter | - And I press "Save changes" - And I am on "Course 1" course homepage + And the following "mod_book > chapters" exist: + | book | title | content | pagenum |subchapter | + | Test book | First chapter | First chapter | 1 | 0 | + | Test book | Second chapter | Second chapter | 2 | 0 | + | Test book | Sub chapter | Sub chapter | 3 | 1 | + | Test book | Third chapter | Third chapter | 4 | 0 | + | Test book | Fourth chapter | Fourth chapter | 5 | 0 | + And I am on the "Course 1" course page logged in as teacher1 And I turn editing mode on - And I click on "Test book" "link" in the "region-main" "region" - And I click on "Add new chapter after \"First chapter\"" "link" - And I set the following fields to these values: - | Chapter title | Second chapter | - | Content | Second chapter | - And I press "Save changes" - And I click on "Add new chapter after \"Second chapter\"" "link" - And I set the following fields to these values: - | Chapter title | Sub chapter | - | subchapter | 1 | - | Content | Sub chapter | - And I press "Save changes" - And I click on "Add new chapter after \"Sub chapter\"" "link" - And I set the following fields to these values: - | Chapter title | Third chapter | - | subchapter | 0 | - | Content | Third chapter | - And I press "Save changes" - And I click on "Add new chapter after \"Third chapter\"" "link" - And I set the following fields to these values: - | Chapter title | Fourth chapter | - | Content | Fourth chapter | - And I press "Save changes" + And I am on the "Test book" "book activity" page + And I click on "4. Fourth chapter" "link" in the "Table of contents" "block" @javascript Scenario: Show/hide chapters and subchapters @@ -61,8 +42,7 @@ Feature: Book activity chapter visibility management And I click on "Test book" "link" in the "region-main" "region" Then the "class" attribute of "a[title='Second chapter']" "css_element" should contain "dimmed_text" And the "class" attribute of "a[title='Third chapter']" "css_element" should contain "dimmed_text" - And I am on "Course 1" course homepage - And I turn editing mode on + And I am on "Course 1" course homepage with editing mode on And I click on "Test book" "link" in the "region-main" "region" And I follow "Next" And I should see "Second chapter" in the ".book_content" "css_element" @@ -72,7 +52,6 @@ Feature: Book activity chapter visibility management And I should see "Third chapter" in the ".book_content" "css_element" And I follow "Next" And I should see "Fourth chapter" in the ".book_content" "css_element" - And I log out And I am on the "Test book" "book activity" page logged in as student1 And I should not see "Second chapter" in the "Table of contents" "block" And I should not see "Third chapter" in the "Table of contents" "block" diff --git a/report/outline/tests/behat/filter.feature b/report/outline/tests/behat/filter.feature index f8b0678bb82..b4c9071c02b 100644 --- a/report/outline/tests/behat/filter.feature +++ b/report/outline/tests/behat/filter.feature @@ -21,30 +21,22 @@ Feature: Filter an outline report And the following "activities" exist: | activity | name | description | course | idnumber | section | | forum | Forum name | Forum description | C1 | FORUM01 | 1 | - | book | Book name | Book description | C1 | BOOK01 | 1 | - When I log in as "admin" - And I am on "Course 1" course homepage + | book | Book name | | C1 | BOOK01 | 1 | + When I am on the "Course 1" course page logged in as admin Scenario: Filter the outline report by start date Given I navigate to "Plugins > Logging > Manage log stores" in site administration And "Enable" "link" should exist in the "Legacy log" "table_row" And "Disable" "link" should exist in the "Standard log" "table_row" - And I log out - And I log in as "student1" - And I am on "Course 1" course homepage + And I am on the "Course 1" course page logged in as student1 And I follow "Forum name" And the log timestamp for "student1" and "FORUM01" is set to "12 June 2017 12:49:00" And I am on "Course 1" course homepage And I follow "Book name" And the log timestamp for "student1" and "BOOK01" is set to "10 June 2017 14:01:00" - And I log out - And I log in as "student2" - And I am on "Course 1" course homepage - And I follow "Book name" + And I am on the "Book name" "book activity" page logged in as student2 And the log timestamp for "student2" and "BOOK01" is set to "14 June 2017 11:02:00" - And I log out - And I log in as "admin" - And I am on "Course 1" course homepage + And I am on the "Course 1" course page logged in as admin And I navigate to "Reports" in current page administration And I click on "Activity report" "link" And I should see "2 views by 2 users" in the "Book name" "table_row" @@ -62,22 +54,15 @@ Feature: Filter an outline report Given I navigate to "Plugins > Logging > Manage log stores" in site administration And "Enable" "link" should exist in the "Legacy log" "table_row" And "Disable" "link" should exist in the "Standard log" "table_row" - And I log out - And I log in as "student1" - And I am on "Course 1" course homepage + And I am on the "Course 1" course page logged in as student1 And I follow "Forum name" And the log timestamp for "student1" and "FORUM01" is set to "12 June 2017 12:49:00" And I am on "Course 1" course homepage And I follow "Book name" And the log timestamp for "student1" and "BOOK01" is set to "10 June 2017 14:01:00" - And I log out - And I log in as "student2" - And I am on "Course 1" course homepage - And I follow "Book name" + And I am on the "Book name" "book activity" page logged in as student2 And the log timestamp for "student2" and "BOOK01" is set to "14 June 2017 11:02:00" - And I log out - And I log in as "admin" - And I am on "Course 1" course homepage + And I am on the "Course 1" course page logged in as admin And I navigate to "Reports" in current page administration And I click on "Activity report" "link" And I should see "2 views by 2 users" in the "Book name" "table_row" diff --git a/report/outline/tests/behat/outline.feature b/report/outline/tests/behat/outline.feature index 76c2812841b..6e6526ab248 100644 --- a/report/outline/tests/behat/outline.feature +++ b/report/outline/tests/behat/outline.feature @@ -21,9 +21,8 @@ Feature: View an outline report And the following "activities" exist: | activity | name | intro | course | idnumber | | forum | Forum name | Forum description | C1 | forum1 | - | book | Book name | Book description | C1 | book1 | - When I log in as "admin" - And I am on "Course 1" course homepage + | book | Book name | | C1 | book1 | + When I am on the "Course 1" course page logged in as admin Scenario: View the outline report when only the legacy log reader is enabled Given I navigate to "Plugins > Logging > Manage log stores" in site administration @@ -31,19 +30,13 @@ Feature: View an outline report And I click on "Disable" "link" in the "Standard log" "table_row" And the following config values are set as admin: | loglegacy | 1 | logstore_legacy | - And I log out - And I log in as "student1" - And I am on "Course 1" course homepage + And I am on the "Course 1" course page logged in as student1 And I follow "Forum name" And I am on "Course 1" course homepage And I follow "Book name" - And I log out - And I log in as "student2" - And I am on "Course 1" course homepage + And I am on the "Course 1" course page logged in as student2 And I follow "Book name" - And I log out - And I log in as "teacher1" - And I am on "Course 1" course homepage + And I am on the "Course 1" course page logged in as teacher1 When I navigate to "Reports" in current page administration And I click on "Activity report" "link" Then I should see "2 views by 2 users" in the "Book name" "table_row" @@ -53,19 +46,13 @@ Feature: View an outline report Given I navigate to "Plugins > Logging > Manage log stores" in site administration And "Enable" "link" should exist in the "Legacy log" "table_row" And "Disable" "link" should exist in the "Standard log" "table_row" - And I log out - And I log in as "student1" - And I am on "Course 1" course homepage + And I am on the "Course 1" course page logged in as student1 And I follow "Forum name" And I am on "Course 1" course homepage And I follow "Book name" - And I log out - And I log in as "student2" - And I am on "Course 1" course homepage + And I am on the "Course 1" course page logged in as student2 And I follow "Book name" - And I log out - And I log in as "admin" - And I am on "Course 1" course homepage + And I am on the "Course 1" course page logged in as admin When I navigate to "Reports" in current page administration And I click on "Activity report" "link" Then I should see "2 views by 2 users" in the "Book name" "table_row" @@ -77,19 +64,13 @@ Feature: View an outline report And "Disable" "link" should exist in the "Standard log" "table_row" And the following config values are set as admin: | loglegacy | 1 | logstore_legacy | - And I log out - And I log in as "student1" - And I am on "Course 1" course homepage + And I am on the "Course 1" course page logged in as student1 And I follow "Forum name" And I am on "Course 1" course homepage And I follow "Book name" - And I log out - And I log in as "student2" - And I am on "Course 1" course homepage + And I am on the "Course 1" course page logged in as student2 And I follow "Book name" - And I log out - And I log in as "teacher1" - And I am on "Course 1" course homepage + And I am on the "Course 1" course page logged in as teacher1 When I navigate to "Reports" in current page administration And I click on "Activity report" "link" Then I should see "2 views by 2 users" in the "Book name" "table_row" @@ -105,54 +86,42 @@ Feature: View an outline report Then I should see "No log reader enabled" Scenario: Multiple views from a single user are identified as not distinct - Given I log out - And I log in as "student1" - And I am on "Course 1" course homepage + Given I am on the "Course 1" course page logged in as student1 And I follow "Forum name" And I am on "Course 1" course homepage And I follow "Forum name" And I am on "Course 1" course homepage And I follow "Forum name" And I am on site homepage - And I log out - When I log in as "teacher1" - And I am on "Course 1" course homepage + When I am on the "Course 1" course page logged in as teacher1 And I navigate to "Reports" in current page administration And I click on "Activity report" "link" Then I should see "3 views by 1 users" in the "Forum name" "table_row" And I should see "-" in the "Book name" "table_row" Scenario: Multiple views from multiple users are identified as not distinct - Given I log out - And I log in as "student1" - And I am on "Course 1" course homepage + Given I am on the "Course 1" course page logged in as student1 And I follow "Forum name" And I am on "Course 1" course homepage And I follow "Forum name" And I am on "Course 1" course homepage And I follow "Forum name" And I am on site homepage - And I log out - And I log in as "student2" - And I am on "Course 1" course homepage + Given I am on the "Course 1" course page logged in as student2 And I follow "Forum name" And I am on "Course 1" course homepage And I follow "Forum name" And I am on "Course 1" course homepage And I follow "Forum name" And I am on site homepage - And I log out - When I log in as "teacher1" - And I am on "Course 1" course homepage + When I am on the "Course 1" course page logged in as teacher1 And I navigate to "Reports" in current page administration And I click on "Activity report" "link" Then I should see "6 views by 2 users" in the "Forum name" "table_row" And I should see "-" in the "Book name" "table_row" Scenario: No views from any users - Given I log out - When I log in as "teacher1" - And I am on "Course 1" course homepage + When I am on the "Course 1" course page logged in as teacher1 And I navigate to "Reports" in current page administration And I click on "Activity report" "link" Then I should see "-" in the "Forum name" "table_row" diff --git a/report/participation/tests/behat/filter_participation.feature b/report/participation/tests/behat/filter_participation.feature index 0bf0bb0383c..ff36a51c749 100644 --- a/report/participation/tests/behat/filter_participation.feature +++ b/report/participation/tests/behat/filter_participation.feature @@ -20,13 +20,11 @@ Feature: In a participation report, admin can filter student actions | course | C1 | | activity | book | | name | Test book name | - | description | Test book | | idnumber | book1 | - And I am on the "Test book name" "book activity" page logged in as teacher1 - And I set the following fields to these values: - | Chapter title | Test chapter | - | Content | Test chapter content | - And I log out + And the following "mod_book > chapter" exists: + | book | Test book name | + | title | Test chapter | + | content | Test chapter content | @javascript Scenario: Filter participation report when only legacy log reader is enabled @@ -36,10 +34,8 @@ Feature: In a participation report, admin can filter student actions And I click on "Enable" "link" in the "Legacy log" "table_row" And the following config values are set as admin: | loglegacy | 1 | logstore_legacy | - And I log out And I am on the "Test book name" "book activity" page logged in as student1 - And I log out When I am on the "Course 1" course page logged in as admin When I navigate to "Reports" in current page administration @@ -57,7 +53,6 @@ Feature: In a participation report, admin can filter student actions And I click on "Enable" "link" in the "Legacy log" "table_row" And the following config values are set as admin: | loglegacy | 1 | logstore_legacy | - And I log out And I am on the "Test book name" "book activity" page logged in as student1 And I log out @@ -65,13 +60,10 @@ Feature: In a participation report, admin can filter student actions And I log in as "admin" And I navigate to "Plugins > Logging > Manage log stores" in site administration And I click on "Enable" "link" in the "Standard log" "table_row" - And I log out And I am on the "Test book name" "book activity" page logged in as student1 - And I log out - And I log in as "admin" - And I am on "Course 1" course homepage + And I am on the "Course 1" course page logged in as admin When I navigate to "Reports" in current page administration And I click on "Course participation" "link" And I set the field "instanceid" to "Test book name" @@ -82,10 +74,8 @@ Feature: In a participation report, admin can filter student actions @javascript Scenario: Filter participation report when only standard log reader is enabled by default Given I am on the "Test book name" "book activity" page logged in as student1 - And I log out - And I log in as "admin" - And I am on "Course 1" course homepage + And I am on the "Course 1" course page logged in as admin And I navigate to "Reports" in current page administration And I click on "Course participation" "link" And I set the field "instanceid" to "Test book name" diff --git a/report/participation/tests/behat/message_participants.feature b/report/participation/tests/behat/message_participants.feature index 4e776474782..91781aff29d 100644 --- a/report/participation/tests/behat/message_participants.feature +++ b/report/participation/tests/behat/message_participants.feature @@ -25,14 +25,11 @@ Feature: Use the particiaption report to message groups of students | activity | book | | name | Test book name | | idnumber | Test book name | - | description | Test book | | idnumber | book1 | And I am on the "Test book name" "book activity" page logged in as student1 - And I log out Scenario: Message all students from the participation report - Given I log in as "teacher1" - And I am on "Course 1" course homepage + Given I am on the "Course 1" course page logged in as teacher1 And I navigate to "Reports" in current page administration And I click on "Course participation" "link" And I set the field "instanceid" to "Test book name" @@ -46,8 +43,7 @@ Feature: Use the particiaption report to message groups of students And I should see "Message sent to 3 people" Scenario: Message students who have not participated in book - Given I log in as "teacher1" - And I am on "Course 1" course homepage + Given I am on the "Course 1" course page logged in as teacher1 And I navigate to "Reports" in current page administration And I click on "Course participation" "link" And I set the field "instanceid" to "Test book name" @@ -66,8 +62,7 @@ Feature: Use the particiaption report to message groups of students Scenario: Ensure no message options when messaging is disabled Given the following config values are set as admin: | messaging | 0 | - And I log in as "teacher1" - And I am on "Course 1" course homepage + And I am on the "Course 1" course page logged in as teacher1 And I navigate to "Reports" in current page administration And I click on "Course participation" "link" When I set the field "instanceid" to "Test book name"