MDL-81766 mod_subsection: Update behat tests

Update the existing behat tests and add new ones with the new
modification that renders the subsection in the course page.
This commit is contained in:
Mikel Martín 2024-07-17 16:15:37 +02:00 committed by ferranrecio
parent 1b8ec78421
commit 63b46b415f
5 changed files with 76 additions and 23 deletions

View File

@ -64,10 +64,12 @@
aria-label="{{name}}">
<span class="expanded-icon icon-no-margin p-2" title="{{#str}} collapse, core {{/str}}">
{{#pix}} t/expandedchevron, core {{/pix}}
<span class="sr-only">{{#str}} collapse, core {{/str}}</span>
</span>
<span class="collapsed-icon icon-no-margin p-2" title="{{#str}} expand, core {{/str}}">
<span class="dir-rtl-hide">{{#pix}} t/collapsedchevron, core {{/pix}}</span>
<span class="dir-ltr-hide">{{#pix}} t/collapsedchevron_rtl, core {{/pix}}</span>
<span class="sr-only">{{#str}} expand, core {{/str}}</span>
</span>
</a>
<h{{headinglevel}} class="h4 sectionname course-content-item d-flex align-self-stretch align-items-center mb-0"

View File

@ -101,7 +101,7 @@ Feature: The module menu replaces the delegated section menu
When I choose "Edit settings" in the open action menu
And the field "Section name" matches value "Subsection1"
And I click on "Cancel" "button"
And I am on the "Subsection1" "subsection activity" page
And I am on the "C1 > Subsection1" "course > section" page
# Subsection page. Open the section header action menu.
And I click on "Edit" "icon" in the "[data-region='header-actions-container']" "css_element"
And I choose "Edit settings" in the open action menu
@ -120,7 +120,7 @@ Feature: The module menu replaces the delegated section menu
When I choose "Permalink" in the open action menu
Then I click on "Copy to clipboard" "link"
And I should see "Text copied to clipboard"
And I am on the "Subsection1" "subsection activity" page
And I am on the "C1 > Subsection1" "course > section" page
# Subsection page. Open the section header action menu.
And I click on "Edit" "icon" in the "[data-region='header-actions-container']" "css_element"
And I choose "Permalink" in the open action menu
@ -153,7 +153,7 @@ Feature: The module menu replaces the delegated section menu
And I choose "Delete" in the open action menu
And I click on "Delete" "button" in the "Delete activity?" "dialogue"
And "Subsection2" "link" should not exist in the "#region-main-box" "css_element"
And I am on the "Subsection3" "subsection activity" page
And I am on the "C1 > Subsection3" "course > section" page
# Subsection page. Open the section header action menu.
And I click on "Edit" "icon" in the "[data-region='header-actions-container']" "css_element"
And "Delete" "link" should not exist in the "[data-region='header-actions-container']" "css_element"

View File

@ -0,0 +1,66 @@
@mod @mod_subsection
Feature: Users view subsections on course page
In order to use subsections
As an user
I need to view subsections on course page
Background:
Given I enable "subsection" "mod" plugin
And the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
| student1 | Student | 1 | student1@example.com |
And the following "courses" exist:
| fullname | shortname | category | numsections |
| Course 1 | C1 | 0 | 2 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And the following "activities" exist:
| activity | name | course | idnumber | section |
| subsection | Subsection1 | C1 | sub1 | 1 |
| page | Page1 in Subsection1 | C1 | page11 | 3 |
| subsection | Subsection2 | C1 | sub2 | 1 |
@javascript
Scenario: Student can view, expand and collapse subsections on course page
When I log in as "student1"
And I am on "Course 1" course homepage
Then I should see "Subsection1" in the "region-main" "region"
And I should see "Page1 in Subsection1" in the "Subsection1" "activity"
And I click on "Collapse" "link" in the "Subsection1" "activity"
And I should not see "Page1 in Subsection1" in the "Subsection1" "activity"
And I click on "Expand" "link" in the "Subsection1" "activity"
And I click on "Page1 in Subsection1" "link" in the "Subsection1" "activity"
@javascript
Scenario: Teacher can create activities inside subsections on course page
When I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
# Add an assignment to the top of Subsection1.
And I hover "Insert an activity or resource before 'Page1 in Subsection1'" "button"
And I press "Insert an activity or resource before 'Page1 in Subsection1'"
And I click on "Add a new Assignment" "link" in the "Add an activity or resource" "dialogue"
And I set the following fields to these values:
| Assignment name | Assignment1 in Subsection1 |
And I press "Save and return to course"
Then I should see "Assignment1 in Subsection1" in the "Subsection1" "activity"
# Add an assignment to the empty Subsection2.
And I add an "assign" activity to course "Course 1" section "4" and I fill the form with:
| Assignment name | Assignment1 in Subsection2 |
And I should see "Assignment1 in Subsection2" in the "Subsection2" "activity"
@javascript
Scenario: Teacher can create activities between subsections on course page
When I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I hover "Insert an activity or resource before 'Subsection2'" "button"
And I press "Insert an activity or resource before 'Subsection2'"
And I click on "Add a new Assignment" "link" in the "Add an activity or resource" "dialogue"
And I set the following fields to these values:
| Assignment name | Assignment between subsections |
And I press "Save and return to course"
And I wait "5" seconds
And "Assignment between subsections" "link" should appear after "Page1 in Subsection1" "text"
And "Assignment between subsections" "link" should appear before "Subsection2" "text"

View File

@ -25,10 +25,11 @@ Feature: Teachers can rename subsections
@javascript
Scenario: Renaming the subsection activity changes the subsection name
Given I should see "Subsection activity" in the "page-content" "region"
When I set the field "Edit title" in the "Subsection activity" "activity" to "New name"
When I set the field "Edit section name" in the "Subsection activity" "activity" to "New name"
And I should not see "Subsection activity" in the "region-main" "region"
And I should see "New name" in the "page-content" "region"
Then I click on "New name" "link" in the "page-content" "region"
Then I open "New name" actions menu
And I choose "View" in the open action menu
And I should see "New name" in the "page" "region"
And I should see "Subactivity" in the "region-main" "region"

View File

@ -1,6 +1,6 @@
@mod @mod_subsection
Feature: Teachers create and destroy subsections
In order to use subsections
Feature: Teachers create and destroy subsections on section page
In order to use subsections on section page
As an teacher
I need to create and destroy subsections
@ -17,18 +17,6 @@ Feature: Teachers create and destroy subsections
| teacher1 | C1 | editingteacher |
And I log in as "teacher1"
Scenario: Subsections are not listed as regular sections
Given the following "activities" exist:
| activity | name | course | idnumber | section |
| subsection | Subsection1 | C1 | forum1 | 1 |
| data | Subactivity1 | C1 | data1 | 3 |
When I am on "Course 1" course homepage
Then "Subsection1" "section" should not exist
And I should not see "Subactivity1" in the "region-main" "region"
And I click on "Subsection1" "link" in the "region-main" "region"
And I should see "Subsection1" in the "page" "region"
And I should see "Subactivity1" in the "region-main" "region"
Scenario: Activities can be created in a subsection
Given the following "activities" exist:
| activity | name | course | idnumber | section |
@ -40,8 +28,6 @@ Feature: Teachers create and destroy subsections
And I am on "Course 1" course homepage
And I click on "Subsection1" "link" in the "region-main" "region"
Then I should see "Test assignment name" in the "region-main" "region"
And I am on "Course 1" course homepage
And I should not see "Test assignment name" in the "region-main" "region"
@javascript
Scenario: Teacher can create activities in a subsection page with the activity chooser
@ -57,5 +43,3 @@ Feature: Teachers create and destroy subsections
| Description | Test assignment description |
And I press "Save and return to course"
Then I should see "Test assignment name" in the "region-main" "region"
And I am on "Course 1" course homepage
And I should not see "Test assignment name" in the "region-main" "region"